summaryrefslogtreecommitdiff
path: root/test/visitors/test_to_ruby.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-10-05 14:14:39 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-10-05 14:14:39 -0700
commita5aa707138e05d42b7448c1ab2e229ac887506e5 (patch)
treea999c1bc407517adcd78b76afd1c80161ace2378 /test/visitors/test_to_ruby.rb
parent3d54485fc149b65344db0272df0ed1820bbb03f3 (diff)
downloadpsych-a5aa707138e05d42b7448c1ab2e229ac887506e5.zip
fixing complex numbers in 1.9
Diffstat (limited to 'test/visitors/test_to_ruby.rb')
-rw-r--r--test/visitors/test_to_ruby.rb13
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