diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/drb/test_drb.rb | 134 | ||||
-rw-r--r-- | test/ruby/test_case.rb | 9 |
2 files changed, 79 insertions, 64 deletions
diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb index bd16e8636..753ff0933 100644 --- a/test/drb/test_drb.rb +++ b/test/drb/test_drb.rb @@ -16,86 +16,92 @@ class TestDRbYield < Test::Unit::TestCase end def test_01_one - one = nil - @there.echo_yield_1([]) {|one|} - assert_equal([], one) + @there.echo_yield_1([]) {|one| + assert_equal([], one) + } - one = nil - @there.echo_yield_1(1) {|one|} - assert_equal(1, one) + @there.echo_yield_1(1) {|one| + assert_equal(1, one) + } - one = nil - @there.echo_yield_1(nil) {|one|} - assert_equal(nil, one) + @there.echo_yield_1(nil) {|one| + assert_equal(nil, one) + } end def test_02_two - one = two = nil - @there.echo_yield_2([], []) {|one, two|} - assert_equal([], one) - assert_equal([], two) - - one = two = nil - @there.echo_yield_2(1, 2) {|one, two|} - assert_equal(1, one) - assert_equal(2, two) - - one = two = nil - @there.echo_yield_2(3, nil) {|one, two|} - assert_equal(3, one) - assert_equal(nil, two) - - one = two = nil - @there.echo_yield_1([:key, :value]) {|one, two|} - assert_equal([:key, :value], one) - assert_equal(nil, two) + @there.echo_yield_2([], []) {|one, two| + assert_equal([], one) + assert_equal([], two) + } + + @there.echo_yield_2(1, 2) {|one, two| + assert_equal(1, one) + assert_equal(2, two) + } + + @there.echo_yield_2(3, nil) {|one, two| + assert_equal(3, one) + assert_equal(nil, two) + } + + @there.echo_yield_1([:key, :value]) {|one, two| + assert_equal(:key, one) + assert_equal(:value, two) + } end def test_03_many - s = nil - @there.echo_yield_0 {|*s|} - assert_equal([], s) - @there.echo_yield(nil) {|*s|} - assert_equal([nil], s) - @there.echo_yield(1) {|*s|} - assert_equal([1], s) - @there.echo_yield(1, 2) {|*s|} - assert_equal([1, 2], s) - @there.echo_yield(1, 2, 3) {|*s|} - assert_equal([1, 2, 3], s) - @there.echo_yield([], []) {|*s|} - assert_equal([[], []], s) - @there.echo_yield([]) {|*s|} - if RUBY_VERSION >= '1.8' + @there.echo_yield_0 {|*s| + assert_equal([], s) + } + @there.echo_yield(nil) {|*s| + assert_equal([nil], s) + } + @there.echo_yield(1) {|*s| + assert_equal([1], s) + } + @there.echo_yield(1, 2) {|*s| + assert_equal([1, 2], s) + } + @there.echo_yield(1, 2, 3) {|*s| + assert_equal([1, 2, 3], s) + } + @there.echo_yield([], []) {|*s| + assert_equal([[], []], s) + } + @there.echo_yield([]) {|*s| assert_equal([[]], s) # ! - else - assert_equal([], s) # ! - end + } end def test_04_many_to_one - s = nil - @there.echo_yield_0 {|*s|} - assert_equal([], s) - @there.echo_yield(nil) {|*s|} - assert_equal([nil], s) - @there.echo_yield(1) {|*s|} - assert_equal([1], s) - @there.echo_yield(1, 2) {|*s|} - assert_equal([1, 2], s) - @there.echo_yield(1, 2, 3) {|*s|} - assert_equal([1, 2, 3], s) - @there.echo_yield([], []) {|*s|} - assert_equal([[], []], s) - @there.echo_yield([]) {|*s|} - assert_equal([[]], s) + @there.echo_yield_0 {|*s| + assert_equal([], s) + } + @there.echo_yield(nil) {|*s| + assert_equal([nil], s) + } + @there.echo_yield(1) {|*s| + assert_equal([1], s) + } + @there.echo_yield(1, 2) {|*s| + assert_equal([1, 2], s) + } + @there.echo_yield(1, 2, 3) {|*s| + assert_equal([1, 2, 3], s) + } + @there.echo_yield([], []) {|*s| + assert_equal([[], []], s) + } + @there.echo_yield([]) {|*s| + assert_equal([[]], s) + } end def test_05_array_subclass @there.xarray_each {|x| assert_kind_of(XArray, x)} - if RUBY_VERSION >= '1.8' - @there.xarray_each {|*x| assert_kind_of(XArray, x[0])} - end + @there.xarray_each {|*x| assert_kind_of(XArray, x[0])} end end diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb index 504619366..240735696 100644 --- a/test/ruby/test_case.rb +++ b/test/ruby/test_case.rb @@ -38,5 +38,14 @@ class TestCase < Test::Unit::TestCase else assert(false) end + + case + when true + assert(true) + when false, nil + assert(false) + else + assert(false) + end end end |