From ead61f4ac85a2bf0fffa436dd034812bbfb5738d Mon Sep 17 00:00:00 2001 From: eregon Date: Tue, 25 Apr 2017 11:42:43 +0000 Subject: no longer rescue exceptions of #<=> when initializing a Range * range.c (range_init): no longer hide the user exception with a ArgumentError, just let the user exception go through. * test/ruby/test_range.rb (test_new): add tests. [Feature #7688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_range.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 3743e9dda6..66c4682d8d 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -9,6 +9,14 @@ class TestRange < Test::Unit::TestCase assert_equal((0..2), Range.new(0, 2)) assert_equal((0..2), Range.new(0, 2, false)) assert_equal((0...2), Range.new(0, 2, true)) + + assert_raise(ArgumentError) { (1.."3") } + + obj = Object.new + def obj.<=>(other) + raise RuntimeError, "cmp" + end + assert_raise_with_message(RuntimeError, "cmp") { (obj..3) } end def test_frozen_initialize -- cgit v1.2.3