summaryrefslogtreecommitdiff
path: root/test/psych/test_numeric.rb
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-06 11:57:02 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-06 11:57:02 -0800
commit3b35de2a90e26b99e2a6d4f61dc56d6ce7ded748 (patch)
treef66334a0ad8cf59590dd682d95d6244e8b454853 /test/psych/test_numeric.rb
downloadruby-3b35de2a90e26b99e2a6d4f61dc56d6ce7ded748.tar.gz
ruby-3b35de2a90e26b99e2a6d4f61dc56d6ce7ded748.tar.bz2
ruby-3b35de2a90e26b99e2a6d4f61dc56d6ce7ded748.zip
Imported Upstream version 1.9.3.p194upstream/1.9.3.p194
Diffstat (limited to 'test/psych/test_numeric.rb')
-rw-r--r--test/psych/test_numeric.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/psych/test_numeric.rb b/test/psych/test_numeric.rb
new file mode 100644
index 0000000..bae723a
--- /dev/null
+++ b/test/psych/test_numeric.rb
@@ -0,0 +1,25 @@
+require 'psych/helper'
+require 'bigdecimal'
+
+module Psych
+ ###
+ # Test numerics from YAML spec:
+ # http://yaml.org/type/float.html
+ # http://yaml.org/type/int.html
+ class TestNumeric < TestCase
+ def test_non_float_with_0
+ 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