[前][次][番号順一覧][スレッド一覧]

ruby-changes:32450

From: tenderlove <ko1@a...>
Date: Thu, 9 Jan 2014 09:54:43 +0900 (JST)
Subject: [ruby-changes:32450] tenderlove:r44529 (trunk): * ext/psych/lib/psych/visitors/to_ruby.rb: anonymous structs

tenderlove	2014-01-09 09:54:37 +0900 (Thu, 09 Jan 2014)

  New Revision: 44529

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44529

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/to_ruby.rb
    trunk/test/psych/test_object_references.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44528)
+++ ChangeLog	(revision 44529)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jan  9 09:51:00 2014  Aaron Patterson <aaron@t...>
+
+	* 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@r...>
 
 	* vm_insnhelper.c (vm_search_super_method): when super called in a
Index: ext/psych/lib/psych/visitors/to_ruby.rb
===================================================================
--- ext/psych/lib/psych/visitors/to_ruby.rb	(revision 44528)
+++ ext/psych/lib/psych/visitors/to_ruby.rb	(revision 44529)
@@ -181,9 +181,11 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L181
             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:?(.*)?$/
Index: test/psych/test_object_references.rb
===================================================================
--- test/psych/test_object_references.rb	(revision 44528)
+++ test/psych/test_object_references.rb	(revision 44529)
@@ -26,6 +26,10 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_object_references.rb#L26
       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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]