2011-10-03 17:21:31 -04:00
|
|
|
require 'psych/helper'
|
2011-12-17 22:44:09 -05:00
|
|
|
require 'bigdecimal'
|
2011-10-03 17:21:31 -04:00
|
|
|
|
|
|
|
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
|
2011-12-17 22:44:09 -05:00
|
|
|
|
|
|
|
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
|
2011-10-03 17:21:31 -04:00
|
|
|
end
|
|
|
|
end
|