Files
ruby_koans/src/about_true_and_false.rb
Jim Weirich 6592f3d36e Back ported a lot of changes made to the Koans directory.
Evidently, a lot of changes / pull requests were made to the koans
directory and not to the src directory.  Perhaps we should remove the
koans directory entirely from the repo.
2011-12-04 02:00:22 -05:00

34 lines
864 B
Ruby

require File.expand_path(File.dirname(__FILE__) + '/edgecase')
class AboutTrueAndFalse < EdgeCase::Koan
def truth_value(condition)
if condition
:true_stuff
else
:false_stuff
end
end
def test_true_is_treated_as_true
assert_equal __(:true_stuff), truth_value(true)
end
def test_false_is_treated_as_false
assert_equal __(:false_stuff), truth_value(false)
end
def test_nil_is_treated_as_false_too
assert_equal __(:false_stuff), truth_value(nil)
end
def test_everything_else_is_treated_as_true
assert_equal __(:true_stuff), truth_value(1)
assert_equal __(:true_stuff), truth_value(0)
assert_equal __(:true_stuff), truth_value([])
assert_equal __(:true_stuff), truth_value({})
assert_equal __(:true_stuff), truth_value("Strings")
assert_equal __(:true_stuff), truth_value("")
end
end