summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-09 00:54:37 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-09 00:54:37 +0000
commit7c6e4f8f38346a6cddfdae42a58567e668865238 (patch)
treef68e194b16821d563e5d39a1362d3a5c81fc6c27
parent5c0d17c9a2fbbb60e24cd6bd41ffdf8b63b07318 (diff)
* ext/psych/lib/psych/visitors/to_ruby.rb: anonymous structs
should be able to roundtrip. Thanks @splattael! * test/psych/test_object_references.rb: test for change git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb4
-rw-r--r--test/psych/test_object_references.rb4
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f52c6070f2..9c949977ecb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jan 9 09:51:00 2014 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/visitors/to_ruby.rb: anonymous structs
+ should be able to roundtrip. Thanks @splattael!
+
+ * test/psych/test_object_references.rb: test for change
+
Wed Jan 8 22:53:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_search_super_method): when super called in a
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 1bfffb952f1..42b328a4bf8 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -181,9 +181,11 @@ module Psych
klass = class_loader.struct
members = o.children.map { |c| accept c }
h = Hash[*members]
- klass.new(*h.map { |k,v|
+ s = klass.new(*h.map { |k,v|
class_loader.symbolize k
}).new(*h.map { |k,v| v })
+ register(o, s)
+ s
end
when /^!ruby\/object:?(.*)?$/
diff --git a/test/psych/test_object_references.rb b/test/psych/test_object_references.rb
index 9e2cf08ad0e..273b466b0cd 100644
--- a/test/psych/test_object_references.rb
+++ b/test/psych/test_object_references.rb
@@ -26,6 +26,10 @@ module Psych
assert_reference_trip DateTime.now
end
+ def test_struct_has_references
+ assert_reference_trip Struct.new(:foo).new(1)
+ end
+
def assert_reference_trip obj
yml = Psych.dump([obj, obj])
assert_match(/\*-?\d+/, yml)