aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_sprintf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_sprintf.rb')
-rw-r--r--test/ruby/test_sprintf.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb
index 15424d98ac..f8dbbd511e 100644
--- a/test/ruby/test_sprintf.rb
+++ b/test/ruby/test_sprintf.rb
@@ -191,6 +191,19 @@ class TestSprintf < Test::Unit::TestCase
assert_equal(" Inf", sprintf("% 0e", 1.0/0.0), "moved from btest/knownbug")
end
+ def test_float_hex
+ assert_equal("-0x0p+0", sprintf("%a", -0.0))
+ assert_equal("0x0p+0", sprintf("%a", 0.0))
+ assert_equal("0x1p-1", sprintf("%a", 0.5))
+ assert_equal("0x1p+0", sprintf("%a", 1.0))
+ assert_equal("0x1p+1", sprintf("%a", 2.0))
+ assert_equal("0x1.193ea7aad030ap+0", sprintf("%a", Math.log(3)))
+ assert_equal("0X1.193EA7AAD030AP+0", sprintf("%A", Math.log(3)))
+ assert_equal("0x1p+10", sprintf("%a", 1024))
+ assert_equal("0x1.23456p+789", sprintf("%a", 3.704450999893983e+237))
+ assert_equal("0x1p-1074", sprintf("%a", 4.9e-324))
+ end
+
BSIZ = 120
def test_skip