Skip to content

Commit

Permalink
* lib/yaml/rubytypes.rb: anonymous struct fix. [ruby-core:01946]
Browse files Browse the repository at this point in the history
* test/yaml/test_yaml.rb: add test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
why committed Dec 12, 2003
1 parent 30e1429 commit ff2a47e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Sat Dec 13 03:09:14 2003 why the lucky stiff <[email protected]>

* 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 <[email protected]>

* lib/csv.rb: add Cell#to_str and Cell#to_s for /.../ =~ aCell,
Expand Down
4 changes: 2 additions & 2 deletions lib/yaml/rubytypes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def to_yaml( opts = {} )
#
# 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] )
}
Expand Down
11 changes: 11 additions & 0 deletions test/yaml/test_yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1058,6 +1063,12 @@ def test_ruby_struct
isbn: None
EOY
)

assert_to_yaml( YAML_Tests::StructTest.new( 123 ), <<EOY )
--- !ruby/struct:Test::StructTest
c: 123
EOY

end

def test_emitting_indicators
Expand Down

0 comments on commit ff2a47e

Please sign in to comment.