From 33ce8650bac29190dde937b1b7d3e21fd06926e7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 17 Dec 2011 19:45:07 -0800 Subject: * ext/psych/lib/psych/visitors/to_ruby.rb: BigDecimals can be restored from YAML. * ext/psych/lib/psych/visitors/yaml_tree.rb: BigDecimals can be dumped to YAML. * test/psych/test_numeric.rb: tests for BigDecimal serialization Fixes #31 --- test/psych/test_numeric.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/psych/test_numeric.rb b/test/psych/test_numeric.rb index 9adb058..bae723a 100644 --- a/test/psych/test_numeric.rb +++ b/test/psych/test_numeric.rb @@ -1,4 +1,5 @@ require 'psych/helper' +require 'bigdecimal' module Psych ### @@ -10,5 +11,15 @@ module Psych str = Psych.load('--- 090') assert_equal '090', str end + + def test_big_decimal_tag + decimal = BigDecimal("12.34") + assert_match "!ruby/object:BigDecimal", Psych.dump(decimal) + end + + def test_big_decimal_round_trip + decimal = BigDecimal("12.34") + assert_cycle decimal + end end end -- cgit v1.2.3