diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-09 19:26:45 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-09 19:26:45 +0000 |
commit | b104e2524ddd8f8c34918a31dbfca54169dd0535 (patch) | |
tree | 47d1c761f052d29ef1bb248530a3e8b10e9cfbf1 /test | |
parent | ac8b1869c0b80fd948a6a50d2a737123b5fa5bd2 (diff) | |
download | ruby-b104e2524ddd8f8c34918a31dbfca54169dd0535.tar.gz |
* ext/psych/lib/psych/scalar_scanner.rb: strip trailing dots from
floats so that Float() will not raise an exception.
* test/psych/test_numeric.rb: test to ensure "1." can be loaded
* test/psych/test_string.rb: make sure "1." can round trip
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/psych/test_numeric.rb | 4 | ||||
-rw-r--r-- | test/psych/test_string.rb | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/test/psych/test_numeric.rb b/test/psych/test_numeric.rb index 200a9f0171..0858e799aa 100644 --- a/test/psych/test_numeric.rb +++ b/test/psych/test_numeric.rb @@ -16,6 +16,10 @@ module Psych $DEBUG = @old_debug end + def test_load_float_with_dot + assert_equal 1.0, Psych.load('--- 1.') + end + def test_non_float_with_0 str = Psych.load('--- 090') assert_equal '090', str diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index 0c5d4d2625..aa6866b618 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -102,6 +102,10 @@ module Psych assert_cycle string end + def test_float_confusion + assert_cycle '1.' + end + def binary_string percentage = 0.31, length = 100 string = '' (percentage * length).to_i.times do |i| |