diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-23 10:44:04 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-23 10:53:23 +0900 |
| commit | 6f46f8887334d99fb2ccec7688f99c8bda080408 (patch) | |
| tree | d31d1640c199d12edd03e70c00f8aac78b91aa05 /test | |
| parent | 11cfe77eb1675d461709bda4e413ee2966945195 (diff) | |
| download | mruby-6f46f8887334d99fb2ccec7688f99c8bda080408.tar.gz mruby-6f46f8887334d99fb2ccec7688f99c8bda080408.zip | |
numeric.c: fix: `-0.0.abs` returned `-0.0`.
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/float.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/t/float.rb b/test/t/float.rb index a76dbf39b..e4c25b34e 100644 --- a/test/t/float.rb +++ b/test/t/float.rb @@ -303,4 +303,16 @@ assert('Float#eql?') do assert_not_operator(5.0, :eql?, "5.0") end +assert('Float#abs') do + f = 1.0 + assert_equal(1.0, f.abs) + f = -1.0 + assert_equal(1.0, f.abs) + f = 0.0 + assert_equal(0.0, f.abs) + # abs(negative zero) should be positive zero + f = -0.0 + assert_equal(0.0, f.abs) +end + end # const_defined?(:Float) |
