зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
ac8b1869c0
Коммит
b104e2524d
|
@ -1,3 +1,12 @@
|
|||
Thu Jan 10 04:23:07 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* 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
|
||||
|
||||
Thu Jan 10 03:38:40 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/lib/psych/visitors/yaml_tree.rb: ascii only binary strings
|
||||
|
|
|
@ -96,7 +96,7 @@ module Psych
|
|||
@string_cache[string] = true
|
||||
string
|
||||
else
|
||||
Float(string.gsub(/[,_]/, ''))
|
||||
Float(string.gsub(/[,_]|\.$/, ''))
|
||||
end
|
||||
else
|
||||
int = parse_int string.gsub(/[,_]/, '')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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|
|
||||
|
|
Загрузка…
Ссылка в новой задаче