summaryrefslogtreecommitdiff
path: root/test/visitors/test_to_ruby.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-10-05 11:08:19 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-10-05 11:08:19 -0700
commit3027b4d69c2fe2e3f4f254e102af3834fddff2f6 (patch)
tree5125565c50a2e63f1819ddaae1798aeaf4618057 /test/visitors/test_to_ruby.rb
parent81929a6aa2b6d26958401e67b83019e31275ef5c (diff)
downloadpsych-3027b4d69c2fe2e3f4f254e102af3834fddff2f6.zip
rationals supported
Diffstat (limited to 'test/visitors/test_to_ruby.rb')
-rw-r--r--test/visitors/test_to_ruby.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb
index 39a4567..7265316 100644
--- a/test/visitors/test_to_ruby.rb
+++ b/test/visitors/test_to_ruby.rb
@@ -9,6 +9,16 @@ module Psych
@visitor = ToRuby.new
end
+ def test_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')
+ mapping.children << Nodes::Scalar.new('1')
+
+ assert_equal Rational(1,2), mapping.to_ruby
+ end
+
def test_complex
mapping = Nodes::Mapping.new nil, 'ruby/object:Complex'
mapping.children << Nodes::Scalar.new('image')