mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
cf2bbc89d2
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
25 lines
559 B
Ruby
25 lines
559 B
Ruby
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
|