From 283b3d8f99c01a13e727b2edf0a7643a67d16361 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 18 Jan 2019 04:19:32 +0000 Subject: merge revision(s) 66796,66797: [Backport #15525] No TypeError at nil if exception: false [ruby-core:91021] [Bug #15525] No FloatDomainError at non-finitive number if exception: false [ruby-core:91021] [Bug #15525] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@66862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_complex.rb | 6 ++++++ test/ruby/test_integer.rb | 9 +++++++++ test/ruby/test_rational.rb | 6 ++++++ 3 files changed, 21 insertions(+) (limited to 'test') diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index 4aa3eda1d4..0161ce8ffe 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -863,9 +863,15 @@ class Complex_Test < Test::Unit::TestCase assert_nothing_raised(ArgumentError){ assert_equal(nil, Complex('5x', exception: false)) } + assert_nothing_raised(ArgumentError){ + assert_equal(nil, Complex(nil, exception: false)) + } assert_nothing_raised(ArgumentError){ assert_equal(nil, Complex(Object.new, exception: false)) } + assert_nothing_raised(ArgumentError){ + assert_equal(nil, Complex(1, nil, exception: false)) + } assert_nothing_raised(ArgumentError){ assert_equal(nil, Complex(1, Object.new, exception: false)) } diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index a73992787d..69347b6b11 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -175,6 +175,15 @@ class TestInteger < Test::Unit::TestCase def o.to_int; raise; end assert_equal(nil, Integer(o, exception: false)) } + assert_nothing_raised(FloatDomainError) { + assert_equal(nil, Integer(Float::INFINITY, exception: false)) + } + assert_nothing_raised(FloatDomainError) { + assert_equal(nil, Integer(-Float::INFINITY, exception: false)) + } + assert_nothing_raised(FloatDomainError) { + assert_equal(nil, Integer(Float::NAN, exception: false)) + } assert_raise(ArgumentError) { Integer("1z", exception: true) diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index b289753347..a8cdf22a49 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -815,9 +815,15 @@ class Rational_Test < Test::Unit::TestCase assert_nothing_raised(ZeroDivisionError) { assert_equal(nil, Rational("1/0", exception: false)) } + assert_nothing_raised(TypeError) { + assert_equal(nil, Rational(nil, exception: false)) + } assert_nothing_raised(TypeError) { assert_equal(nil, Rational(Object.new, exception: false)) } + assert_nothing_raised(TypeError) { + assert_equal(nil, Rational(1, nil, exception: false)) + } assert_nothing_raised(TypeError) { assert_equal(nil, Rational(1, Object.new, exception: false)) } -- cgit v1.2.3