diff options
author | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-12 18:08:58 +0000 |
---|---|---|
committer | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-12 18:08:58 +0000 |
commit | 1954eec80d7b9111920aa758b4c85405f907f671 (patch) | |
tree | 8dd656aa4d4dc33f73a13c8a5d490c0770f3e0f7 | |
parent | 232af9efc706919b271b89824d3d546d208c6b90 (diff) | |
download | ruby-1954eec80d7b9111920aa758b4c85405f907f671.tar.gz ruby-1954eec80d7b9111920aa758b4c85405f907f671.tar.xz ruby-1954eec80d7b9111920aa758b4c85405f907f671.zip |
* lib/yaml/rubytypes.rb: anonymous struct fix. [ruby-core:01946]
* test/yaml/test_yaml.rb: add test.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/yaml/rubytypes.rb | 4 | ||||
-rw-r--r-- | test/yaml/test_yaml.rb | 11 |
3 files changed, 19 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Sat Dec 13 03:09:14 2003 why the lucky stiff <why@ruby-lang.org> + + * lib/yaml/rubytypes.rb: anonymous struct fix. [ruby-core:01946] + + * test/yaml/test_yaml.rb: add test. + Fri Dec 12 22:36:44 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org> * lib/csv.rb: add Cell#to_str and Cell#to_s for /.../ =~ aCell, diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index fed437027..f718df9b9 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -155,8 +155,8 @@ class Struct # # Basic struct is passed as a YAML map # - struct_name = self.class.name.gsub( "Struct:", "" ) - out.map( "!ruby/struct#{struct_name}" ) { |map| + struct_name = self.class.name.gsub( "Struct::", "" ) + out.map( "!ruby/struct:#{struct_name}" ) { |map| self.members.each { |m| map.add( m, self[m] ) } diff --git a/test/yaml/test_yaml.rb b/test/yaml/test_yaml.rb index cfb6407c2..35bb7c5f7 100644 --- a/test/yaml/test_yaml.rb +++ b/test/yaml/test_yaml.rb @@ -4,6 +4,11 @@ require 'test/unit' require 'yaml' +# [ruby-core:01946] +module YAML_Tests + StructTest = Struct::new( :c ) +end + class YAML_Unit_Tests < Test::Unit::TestCase # # Convert between YAML and the object to verify correct parsing and @@ -1058,6 +1063,12 @@ EOY isbn: None EOY ) + + assert_to_yaml( YAML_Tests::StructTest.new( 123 ), <<EOY ) +--- !ruby/struct:Test::StructTest +c: 123 +EOY + end def test_emitting_indicators |