aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-06 12:59:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-06 12:59:59 +0000
commit9deecfc4531cc038a0c27a72c316dafb9aa2bc23 (patch)
tree41cc1280bbd257487739a78032c874bd6583b0a3 /test
parent814b7b544848ffd41e97b3a0af2db7baee146764 (diff)
downloadruby-9deecfc4531cc038a0c27a72c316dafb9aa2bc23.tar.gz
range.c: return nil for empty range
* range.c (range_last): return nil for empty range, or in the case the predecessor is smaller than the begin. [Bug #8739] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_range.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb
index c50139ef9c..d738e56294 100644
--- a/test/ruby/test_range.rb
+++ b/test/ruby/test_range.rb
@@ -254,6 +254,7 @@ class TestRange < Test::Unit::TestCase
assert_equal(10, (0..10).last)
assert_equal("a", ("a".."c").first)
assert_equal("c", ("a".."c").last)
+ assert_equal(0, (2..0).last)
bug8739 = '[ruby-dev:47587] [Bug #8739] from exclusive range'
assert_equal([0, 1, 2], (0...10).first(3), bug8739)
@@ -262,6 +263,7 @@ class TestRange < Test::Unit::TestCase
assert_equal(9, (0...10).last, bug8739)
assert_equal("a", ("a"..."c").first, bug8739)
assert_equal("b", ("a"..."c").last, bug8739)
+ assert_nil((2...0).last)
end
def test_to_s