diff options
Diffstat (limited to 'test/visitors/test_to_ruby.rb')
-rw-r--r-- | test/visitors/test_to_ruby.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb index fa7c539..3cb1ead 100644 --- a/test/visitors/test_to_ruby.rb +++ b/test/visitors/test_to_ruby.rb @@ -1,6 +1,8 @@ require 'minitest/autorun' require 'psych' require 'complex' +require 'date' +require 'rational' module Psych module Visitors @@ -19,7 +21,7 @@ module Psych end def test_rational - mapping = Nodes::Mapping.new nil, 'ruby/object:Rational' + mapping = Nodes::Mapping.new nil, '!ruby/object:Rational' mapping.children << Nodes::Scalar.new('denominator') mapping.children << Nodes::Scalar.new('2') mapping.children << Nodes::Scalar.new('numerator') @@ -29,7 +31,7 @@ module Psych end def test_complex - mapping = Nodes::Mapping.new nil, 'ruby/object:Complex' + mapping = Nodes::Mapping.new nil, '!ruby/object:Complex' mapping.children << Nodes::Scalar.new('image') mapping.children << Nodes::Scalar.new('2') mapping.children << Nodes::Scalar.new('real') @@ -38,6 +40,13 @@ module Psych assert_equal Complex(1,2), mapping.to_ruby end + if RUBY_VERSION >= '1.9' + def test_complex_string + node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex" + assert_equal Complex(3, 4), node.to_ruby + end + end + def test_integer i = Nodes::Scalar.new('1', nil, 'tag:yaml.org,2002:int') assert_equal 1, i.to_ruby |