diff options
| author | Ray Chason <[email protected]> | 2019-08-09 00:08:36 -0400 |
|---|---|---|
| committer | Ray Chason <[email protected]> | 2019-08-09 00:08:36 -0400 |
| commit | 1cd0ff0d42ea4fb385288d3bd2c440a1f46e08af (patch) | |
| tree | ce1ecd89ddb7d67171dfda216e6e82ac79c0b373 /mrbgems/mruby-complex/test/complex.rb | |
| parent | c181d1e7fa80b1cc0551f8fbd85ab6f7419b7887 (diff) | |
| download | mruby-1cd0ff0d42ea4fb385288d3bd2c440a1f46e08af.tar.gz mruby-1cd0ff0d42ea4fb385288d3bd2c440a1f46e08af.zip | |
Avoid overflow and underflow in Complex#/
Diffstat (limited to 'mrbgems/mruby-complex/test/complex.rb')
| -rw-r--r-- | mrbgems/mruby-complex/test/complex.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/mrbgems/mruby-complex/test/complex.rb b/mrbgems/mruby-complex/test/complex.rb index dcc0f3bef..d996e8277 100644 --- a/mrbgems/mruby-complex/test/complex.rb +++ b/mrbgems/mruby-complex/test/complex.rb @@ -59,6 +59,15 @@ assert 'Complex#/' do assert_complex Complex(-2, 9) / Complex(-9, 2), ((36 / 85) - (77i / 85)) assert_complex Complex(9, 8) / 4 , ((9 / 4) + 2i) assert_complex Complex(20, 9) / 9.8 , (2.0408163265306123 + 0.9183673469387754i) + if 1e39.infinite? then + # MRB_USE_FLOAT in effect + ten = 1e21 + one = 1e20 + else + ten = 1e201 + one = 1e200 + end + assert_complex Complex(ten, ten) / Complex(one, one), Complex(10.0, 0.0) end assert 'Complex#==' do @@ -76,8 +85,8 @@ assert 'Complex#abs' do else exp = 1021 end - assert_true Complex(3.0*2**exp, 4.0*2**exp).abs.finite? - assert_float Complex(3.0*2**exp, 4.0*2**exp).abs, 5.0*2**exp + assert_true Complex(3.0*2.0**exp, 4.0*2.0**exp).abs.finite? + assert_float Complex(3.0*2.0**exp, 4.0*2.0**exp).abs, 5.0*2.0**exp end assert 'Complex#abs2' do |
