diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/comparable.rb | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/test/t/comparable.rb b/test/t/comparable.rb index b5718d2d2..2ee28de7b 100644 --- a/test/t/comparable.rb +++ b/test/t/comparable.rb @@ -3,22 +3,26 @@ assert('Comparable#<', '15.3.3.2.1') do class Foo include Comparable def <=>(x) - 0 + x end end - - assert_false(Foo.new < Foo.new) + assert_false(Foo.new < 0) + assert_false(Foo.new < 1) + assert_true(Foo.new < -1) + assert_raise(ArgumentError){ Foo.new < nil } end assert('Comparable#<=', '15.3.3.2.2') do class Foo include Comparable def <=>(x) - 0 + x end end - - assert_true(Foo.new <= Foo.new) + assert_true(Foo.new <= 0) + assert_false(Foo.new <= 1) + assert_true(Foo.new <= -1) + assert_raise(ArgumentError){ Foo.new <= nil } end assert('Comparable#==', '15.3.3.2.3') do @@ -36,22 +40,26 @@ assert('Comparable#>', '15.3.3.2.4') do class Foo include Comparable def <=>(x) - 0 + x end end - - assert_false(Foo.new > Foo.new) + assert_false(Foo.new > 0) + assert_true(Foo.new > 1) + assert_false(Foo.new > -1) + assert_raise(ArgumentError){ Foo.new > nil } end assert('Comparable#>=', '15.3.3.2.5') do class Foo include Comparable def <=>(x) - 0 + x end end - - assert_true(Foo.new >= Foo.new) + assert_true(Foo.new >= 0) + assert_true(Foo.new >= 1) + assert_false(Foo.new >= -1) + assert_raise(ArgumentError){ Foo.new >= nil } end assert('Comparable#between?', '15.3.3.2.6') do |
