Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7f7d57b482a3
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 291c7c7d0711
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Jun 26, 2015

  1. added edge-case Marshal#load spec for extended Hashes containing user…

    …-marshaled objects
    sshao authored and brixen committed Jun 26, 2015
    Copy the full SHA
    1e86ae2 View commit details
  2. Fixed Marshal#construct_hash to handle edge case of extended Hash

    Fixed Marshal#construct_hash to handle edge case of extended Hash
    containing user-marshaled objects. See previous commit for associated
    spec.
    sshao authored and brixen committed Jun 26, 2015
    Copy the full SHA
    abb8e05 View commit details
  3. Copy the full SHA
    291c7c7 View commit details
Showing with 24 additions and 0 deletions.
  1. +3 −0 kernel/common/marshal.rb
  2. +21 −0 spec/ruby/core/marshal/shared/load.rb
3 changes: 3 additions & 0 deletions kernel/common/marshal.rb
Original file line number Diff line number Diff line change
@@ -675,8 +675,11 @@ def construct_hash
store_unique_object obj

construct_integer.times do
original_modules = @modules
@modules = nil
key = construct
val = construct
@modules = original_modules

# Use __store__ (an alias for []=) to get around subclass overrides
obj.__store__ key, val
21 changes: 21 additions & 0 deletions spec/ruby/core/marshal/shared/load.rb
Original file line number Diff line number Diff line change
@@ -294,6 +294,16 @@
new_obj.instance_variable_get(:@mix).should equal new_obj[1]
new_obj[1].instance_variable_get(:@foo).should == 10
end

it "loads an extended Array object containing a user-marshaled object" do
obj = [UserMarshal.new, UserMarshal.new].extend(Meths)
new_obj = Marshal.send(@method, "\x04\be:\nMeths[\ao:\x10UserMarshal\x06:\n@dataI\"\nstuff\x06:\x06ETo;\x06\x06;\aI\"\nstuff\x06;\bT")

new_obj.should == obj
obj_ancestors = class << obj; ancestors[1..-1]; end
new_obj_ancestors = class << new_obj; ancestors[1..-1]; end
obj_ancestors.should == new_obj_ancestors
end
end

describe "for a Hash" do
@@ -308,6 +318,17 @@
new_obj_metaclass_ancestors[@num_self_class+1].should == UserHashInitParams
end

it "loads an extended hash object containing a user-marshaled object" do
obj = {:a => UserMarshal.new}.extend(Meths)

new_obj = Marshal.send(@method, "\004\be:\nMeths{\006:\006aU:\020UserMarshal\"\nstuff")

new_obj.should == obj
new_obj_metaclass_ancestors = class << new_obj; ancestors; end
new_obj_metaclass_ancestors[@num_self_class].should == Meths
new_obj_metaclass_ancestors[@num_self_class+1].should == Hash
end

it "preserves hash ivars when hash contains a string having ivar" do
s = 'string'
s.instance_variable_set :@string_ivar, 'string ivar'