aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_sprintf.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-18 08:06:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-18 08:06:48 +0000
commit1d196e0d2bd99590d03a73d7e59aa87f7266f8e3 (patch)
tree34ff56a3fc2ec4852c9b7cea5bebfba8585c2c24 /test/ruby/test_sprintf.rb
parent22892ca6c2f68df005622b2e4daf246a649a4d1b (diff)
downloadruby-1d196e0d2bd99590d03a73d7e59aa87f7266f8e3.tar.gz
sprintf.c: rational 'f' format
* sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_sprintf.rb')
-rw-r--r--test/ruby/test_sprintf.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb
index 7994e99e5e..3cfb9ac7db 100644
--- a/test/ruby/test_sprintf.rb
+++ b/test/ruby/test_sprintf.rb
@@ -148,6 +148,11 @@ class TestSprintf < Test::Unit::TestCase
assert_equal(" Inf", sprintf("% e", inf), '[ruby-dev:34002]')
end
+ def test_rational
+ assert_match(/\A0\.10+\z/, sprintf("%.60f", 0.1r))
+ assert_match(/\A0\.3+\z/, sprintf("%.60f", 1/3r))
+ end
+
def test_hash
options = {:capture=>/\d+/}
assert_equal("with options {:capture=>/\\d+/}", sprintf("with options %p" % options))