diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-22 02:58:40 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-22 02:58:40 +0000 |
commit | cae45174190b49ca3c67ca606c5f4b71e3847842 (patch) | |
tree | 1090eca387b2ffca29e09e54c9392c7f948ceab2 /test | |
parent | 342619300ce26f9a134249002270c5d38d5993b3 (diff) | |
download | ruby-cae45174190b49ca3c67ca606c5f4b71e3847842.tar.gz |
range.c: Range#last and #max raises a RangeError if it is endless
Also, Range#min raises an error if it is endless and a comparison method
is specified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_range.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index a57cf18bbf..cc9e67053c 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -99,8 +99,8 @@ class TestRange < Test::Unit::TestCase assert_equal(2, (1..2).max) assert_equal(nil, (2..1).max) assert_equal(1, (1...2).max) - assert_equal(nil, (1..).max) - assert_equal(nil, (1...).max) + assert_raise(RangeError) { (1..).max } + assert_raise(RangeError) { (1...).max } assert_equal(2.0, (1.0..2.0).max) assert_equal(nil, (2.0..1.0).max) @@ -115,7 +115,8 @@ class TestRange < Test::Unit::TestCase assert_equal([10,9,8], (0..10).max(3)) assert_equal([9,8,7], (0...10).max(3)) - # XXX: How should (0...).max(3) behave? + assert_raise(RangeError) { (1..).max(3) } + assert_raise(RangeError) { (1...).max(3) } end def test_initialize_twice @@ -405,7 +406,8 @@ class TestRange < Test::Unit::TestCase assert_equal([0, 1, 2], (0..nil).first(3)) assert_equal(0, (0..nil).first) assert_equal("a", ("a"..nil).first) - # XXX: How should (0...).last(3) behave? + assert_raise(RangeError) { (0..nil).last } + assert_raise(RangeError) { (0..nil).last(3) } end def test_to_s |