summaryrefslogtreecommitdiff
path: root/test/psych/test_numeric.rb
diff options
context:
space:
mode:
authorSeth Boyles <sethboyles@gmail.com>2022-01-14 19:58:20 +0000
committerSeth Boyles <sethboyles@gmail.com>2022-01-14 20:09:47 +0000
commit75bebb37b80c7c3f3c6a157e1dd25112cfae8029 (patch)
treea6531188e9c0b33bd8b14a2bf83f6fafb1af545b /test/psych/test_numeric.rb
parentba203f19c03763e6f7b7b97a76ce89e3ae488a6f (diff)
downloadpsych-75bebb37b80c7c3f3c6a157e1dd25112cfae8029.tar.gz
Add strict_integer option to parse numbers with commas as strings
Authored-by: Seth Boyles <sethboyles@gmail.com>
Diffstat (limited to 'test/psych/test_numeric.rb')
-rw-r--r--test/psych/test_numeric.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/psych/test_numeric.rb b/test/psych/test_numeric.rb
index 8c3dcd1..9c75c01 100644
--- a/test/psych/test_numeric.rb
+++ b/test/psych/test_numeric.rb
@@ -43,5 +43,16 @@ module Psych
str = Psych.load('--- 1.1.1')
assert_equal '1.1.1', str
end
+
+ # This behavior is not to YML spec, but is kept for backwards compatibility
+ def test_string_with_commas
+ number = Psych.load('--- 12,34,56')
+ assert_equal 123456, number
+ end
+
+ def test_string_with_commas_with_strict_integer
+ str = Psych.load('--- 12,34,56', strict_integer: true)
+ assert_equal '12,34,56', str
+ end
end
end