1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/yaml/rubytypes.rb: anonymous struct fix. [ruby-core:01946]

* test/yaml/test_yaml.rb: add test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
why 2003-12-12 18:08:58 +00:00
parent 30e14294a7
commit ff2a47eb99
3 changed files with 19 additions and 2 deletions

View file

@ -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> 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, * lib/csv.rb: add Cell#to_str and Cell#to_s for /.../ =~ aCell,

View file

@ -155,8 +155,8 @@ class Struct
# #
# Basic struct is passed as a YAML map # Basic struct is passed as a YAML map
# #
struct_name = self.class.name.gsub( "Struct:", "" ) struct_name = self.class.name.gsub( "Struct::", "" )
out.map( "!ruby/struct#{struct_name}" ) { |map| out.map( "!ruby/struct:#{struct_name}" ) { |map|
self.members.each { |m| self.members.each { |m|
map.add( m, self[m] ) map.add( m, self[m] )
} }

View file

@ -4,6 +4,11 @@
require 'test/unit' require 'test/unit'
require 'yaml' require 'yaml'
# [ruby-core:01946]
module YAML_Tests
StructTest = Struct::new( :c )
end
class YAML_Unit_Tests < Test::Unit::TestCase class YAML_Unit_Tests < Test::Unit::TestCase
# #
# Convert between YAML and the object to verify correct parsing and # Convert between YAML and the object to verify correct parsing and
@ -1058,6 +1063,12 @@ EOY
isbn: None isbn: None
EOY EOY
) )
assert_to_yaml( YAML_Tests::StructTest.new( 123 ), <<EOY )
--- !ruby/struct:Test::StructTest
c: 123
EOY
end end
def test_emitting_indicators def test_emitting_indicators