summaryrefslogtreecommitdiff
path: root/test/visitors
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-10-05 10:47:00 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-10-05 10:47:00 -0700
commit81929a6aa2b6d26958401e67b83019e31275ef5c (patch)
treed9e554ce338dc75b22578ebc746fdd6f1c7669e4 /test/visitors
parentb1cec69c840b12bb6351a40b9a97ebac029b1b6e (diff)
downloadpsych-81929a6aa2b6d26958401e67b83019e31275ef5c.zip
supporting complex numbers
Diffstat (limited to 'test/visitors')
-rw-r--r--test/visitors/test_to_ruby.rb11
-rw-r--r--test/visitors/test_yast_builder.rb4
2 files changed, 15 insertions, 0 deletions
diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb
index c252573..39a4567 100644
--- a/test/visitors/test_to_ruby.rb
+++ b/test/visitors/test_to_ruby.rb
@@ -1,5 +1,6 @@
require 'minitest/autorun'
require 'psych'
+require 'complex'
module Psych
module Visitors
@@ -8,6 +9,16 @@ module Psych
@visitor = ToRuby.new
end
+ def test_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')
+ mapping.children << Nodes::Scalar.new('1')
+
+ assert_equal Complex(1,2), mapping.to_ruby
+ end
+
def test_integer
i = Nodes::Scalar.new('1', nil, 'tag:yaml.org,2002:int')
assert_equal 1, i.to_ruby
diff --git a/test/visitors/test_yast_builder.rb b/test/visitors/test_yast_builder.rb
index d00a21c..6681575 100644
--- a/test/visitors/test_yast_builder.rb
+++ b/test/visitors/test_yast_builder.rb
@@ -8,6 +8,10 @@ module Psych
@v = Visitors::YASTBuilder.new
end
+ def test_complex
+ assert_round_trip Complex(1,2)
+ end
+
def test_circular_list
a = []
2.times { a << a }