diff options
Diffstat (limited to 'test/psych/test_numeric.rb')
-rw-r--r-- | test/psych/test_numeric.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/test/psych/test_numeric.rb b/test/psych/test_numeric.rb index 8c3dcd173c..4c012e4562 100644 --- a/test/psych/test_numeric.rb +++ b/test/psych/test_numeric.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true require_relative 'helper' -require 'bigdecimal' +begin + require 'bigdecimal' +rescue LoadError +end module Psych ### @@ -29,13 +32,13 @@ module Psych def test_big_decimal_tag decimal = BigDecimal("12.34") assert_match "!ruby/object:BigDecimal", Psych.dump(decimal) - end + end if defined?(BigDecimal) def test_big_decimal_round_trip decimal = BigDecimal("12.34") $DEBUG = false assert_cycle decimal - end + end if defined?(BigDecimal) def test_does_not_attempt_numeric str = Psych.load('--- 4 roses') @@ -43,5 +46,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 |