From 3027b4d69c2fe2e3f4f254e102af3834fddff2f6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 5 Oct 2009 11:08:19 -0700 Subject: rationals supported --- test/visitors/test_to_ruby.rb | 10 ++++++++++ test/visitors/test_yast_builder.rb | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'test') 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') diff --git a/test/visitors/test_yast_builder.rb b/test/visitors/test_yast_builder.rb index 6681575..f5423e9 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_rational + assert_round_trip Rational(1,2) + end + def test_complex assert_round_trip Complex(1,2) end -- cgit v1.2.3