aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-15 08:15:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-15 08:15:32 +0000
commit71388fa4e159f614b52371ef1f35e3d1e5789c70 (patch)
treee11cbc65cf3da0f728bb02c481fb620056ccd192 /test/ruby
parente5052b18f0553b56586dfd67dff05774ba07f855 (diff)
downloadruby-71388fa4e159f614b52371ef1f35e3d1e5789c70.tar.gz
object.c: make String#to_f consistent with literal
* object.c (rb_cstr_to_dbl): stop at successive underscores, as well as Float literals. [ruby-core:80098] [Bug #13105] * `_` should be within digits * only one `_` allowed between digits git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_float.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
index dfe636045d..2b6724a963 100644
--- a/test/ruby/test_float.rb
+++ b/test/ruby/test_float.rb
@@ -755,6 +755,12 @@ class TestFloat < Test::Unit::TestCase
def test_Float
assert_in_delta(0.125, Float("0.1_2_5"), 0.00001)
assert_in_delta(0.125, "0.1_2_5__".to_f, 0.00001)
+ assert_in_delta(0.0, "0_.125".to_f, 0.00001)
+ assert_in_delta(0.0, "0._125".to_f, 0.00001)
+ assert_in_delta(0.1, "0.1__2_5".to_f, 0.00001)
+ assert_in_delta(0.1, "0.1_e10".to_f, 0.00001)
+ assert_in_delta(0.1, "0.1e_10".to_f, 0.00001)
+ assert_in_delta(1.0, "0.1e1__0".to_f, 0.00001)
assert_equal(1, suppress_warning {Float(([1] * 10000).join)}.infinite?)
assert_not_predicate(Float(([1] * 10000).join("_")), :infinite?) # is it really OK?
assert_raise(ArgumentError) { Float("1.0\x001") }