2003-09-04 12:18:59 -04:00
|
|
|
require 'test/unit'
|
|
|
|
|
|
|
|
class TestCase < Test::Unit::TestCase
|
|
|
|
def test_case
|
|
|
|
case 5
|
|
|
|
when 1, 2, 3, 4, 6, 7, 8
|
|
|
|
assert(false)
|
|
|
|
when 5
|
|
|
|
assert(true)
|
|
|
|
end
|
2003-09-05 11:15:43 -04:00
|
|
|
|
2003-09-04 12:18:59 -04:00
|
|
|
case 5
|
|
|
|
when 5
|
|
|
|
assert(true)
|
|
|
|
when 1..10
|
|
|
|
assert(false)
|
|
|
|
end
|
2003-09-05 11:15:43 -04:00
|
|
|
|
2003-09-04 12:18:59 -04:00
|
|
|
case 5
|
|
|
|
when 1..10
|
|
|
|
assert(true)
|
|
|
|
else
|
|
|
|
assert(false)
|
|
|
|
end
|
2003-09-05 11:15:43 -04:00
|
|
|
|
2003-09-04 12:18:59 -04:00
|
|
|
case 5
|
|
|
|
when 5
|
|
|
|
assert(true)
|
|
|
|
else
|
|
|
|
assert(false)
|
|
|
|
end
|
2003-09-05 11:15:43 -04:00
|
|
|
|
2003-09-04 12:18:59 -04:00
|
|
|
case "foobar"
|
|
|
|
when /^f.*r$/
|
|
|
|
assert(true)
|
|
|
|
else
|
|
|
|
assert(false)
|
|
|
|
end
|
2003-10-30 04:36:41 -05:00
|
|
|
|
|
|
|
case
|
|
|
|
when true
|
|
|
|
assert(true)
|
|
|
|
when false, nil
|
|
|
|
assert(false)
|
|
|
|
else
|
|
|
|
assert(false)
|
|
|
|
end
|
2003-09-04 12:18:59 -04:00
|
|
|
end
|
|
|
|
end
|