diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2009-10-08 21:57:27 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2009-10-08 21:57:27 -0700 |
commit | df10175978d74736fde61dca28d5129fa5b65b98 (patch) | |
tree | 3113ad8e0242f89ca15d3a583b300b1a137d8248 /test | |
parent | c7893568eab3e1eeab3febaa011dc43cea505abe (diff) | |
download | psych-df10175978d74736fde61dca28d5129fa5b65b98.zip |
more object serialization
Diffstat (limited to 'test')
-rw-r--r-- | test/visitors/test_to_ruby.rb | 9 | ||||
-rw-r--r-- | test/visitors/test_yast_builder.rb | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb index f993c49..dcd4738 100644 --- a/test/visitors/test_to_ruby.rb +++ b/test/visitors/test_to_ruby.rb @@ -11,6 +11,15 @@ module Psych @visitor = ToRuby.new end + def test_object + mapping = Nodes::Mapping.new nil, "!ruby/object" + mapping.children << Nodes::Scalar.new('foo') + mapping.children << Nodes::Scalar.new('bar') + + o = mapping.to_ruby + assert_equal 'bar', o.instance_variable_get(:@foo) + end + def test_awesome Psych.load('1900-01-01T00:00:00+00:00') end diff --git a/test/visitors/test_yast_builder.rb b/test/visitors/test_yast_builder.rb index 532ab09..8645a4d 100644 --- a/test/visitors/test_yast_builder.rb +++ b/test/visitors/test_yast_builder.rb @@ -8,6 +8,11 @@ module Psych @v = Visitors::YASTBuilder.new end + def test_object_has_no_class + yaml = Psych.dump(Object.new) + assert(Psych.dump(Object.new) !~ /Object/, yaml) + end + def test_struct_const foo = Struct.new("Foo", :bar) assert_round_trip foo.new('bar') |