diff options
Diffstat (limited to 'test/ruby/test_float.rb')
| -rw-r--r-- | test/ruby/test_float.rb | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index fbf0d87f8e..7fabfd351d 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -305,7 +305,6 @@ class TestFloat < Test::Unit::TestCase assert_equal(1.0, 1.0 ** (2**32)) assert_equal(1.0, 1.0 ** 1.0) assert_raise(TypeError) { 1.0 ** nil } - assert_equal(9.0, 3.0 ** 2) end def test_eql @@ -765,9 +764,6 @@ class TestFloat < Test::Unit::TestCase assert_raise_with_message(ArgumentError, /xxx/) { 1.0.round(half: "\0xxx") } - assert_raise_with_message(Encoding::CompatibilityError, /ASCII incompatible/) { - 1.0.round(half: "up".force_encoding("utf-16be")) - } end def test_Float @@ -792,15 +788,9 @@ class TestFloat < Test::Unit::TestCase assert_raise(ArgumentError) { Float('0xf.p0') } assert_raise(ArgumentError) { Float('0xf.f') } assert_raise(ArgumentError) { Float('0xf.fp') } - begin - verbose_bak, $VERBOSE = $VERBOSE, nil - assert_equal(Float::INFINITY, Float('0xf.fp1000000000000000')) - ensure - $VERBOSE = verbose_bak - end + assert_equal(Float::INFINITY, Float('0xf.fp1000000000000000')) assert_equal(1, suppress_warning {Float("1e10_00")}.infinite?) assert_raise(TypeError) { Float(nil) } - assert_raise(TypeError) { Float(:test) } o = Object.new def o.to_f; inf = Float::INFINITY; inf/inf; end assert_predicate(Float(o), :nan?) @@ -811,49 +801,6 @@ class TestFloat < Test::Unit::TestCase assert_raise(ArgumentError, bug4310) {under_gc_stress {Float('a'*10000)}} end - def test_Float_with_invalid_exception - assert_raise(ArgumentError) { - Float("0", exception: 1) - } - end - - def test_Float_with_exception_keyword - assert_raise(ArgumentError) { - Float(".", exception: true) - } - assert_nothing_raised(ArgumentError) { - assert_equal(nil, Float(".", exception: false)) - } - assert_raise(RangeError) { - Float(1i, exception: true) - } - assert_nothing_raised(RangeError) { - assert_equal(nil, Float(1i, exception: false)) - } - assert_raise(TypeError) { - Float(nil, exception: true) - } - assert_nothing_raised(TypeError) { - assert_equal(nil, Float(nil, exception: false)) - } - assert_nothing_raised(TypeError) { - assert_equal(nil, Float(:test, exception: false)) - } - assert_nothing_raised(TypeError) { - assert_equal(nil, Float(Object.new, exception: false)) - } - assert_nothing_raised(TypeError) { - o = Object.new - def o.to_f; 3.14; end - assert_equal(3.14, Float(o, exception: false)) - } - assert_nothing_raised(RuntimeError) { - o = Object.new - def o.to_f; raise; end - assert_equal(nil, Float(o, exception: false)) - } - end - def test_num2dbl assert_raise(ArgumentError, "comparison of String with 0 failed") do 1.0.step(2.0, "0.5") {} @@ -893,8 +840,7 @@ class TestFloat < Test::Unit::TestCase a = rand b = a+rand*1000 s = (b - a) / 10 - seq = (a...b).step(s) - assert_equal(10, seq.to_a.length, seq.inspect) + assert_equal(10, (a...b).step(s).to_a.length) end assert_equal([1.0, 2.9, 4.8, 6.699999999999999], (1.0...6.8).step(1.9).to_a) |
