Skip to content

Commit e2130f8

Browse files
committed
Add spec for Marshal.load of #marshal_load object + symbol
1 parent 2b0adb0 commit e2130f8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

spec/ruby/core/marshal/fixtures/marshal_data.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class UserPreviouslyDefinedWithInitializedIvar
8383
end
8484

8585
class UserMarshal
86-
attr_reader :data
86+
attr_accessor :data
8787

8888
def initialize
8989
@data = 'stuff'

spec/ruby/core/marshal/shared/load.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@
309309

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

314315
new_obj.should == obj
315316
obj_ancestors = class << obj; ancestors[1..-1]; end
@@ -609,6 +610,18 @@
609610
end
610611
end
611612

613+
describe "for an object responding to #marshal_dump and #marshal_load" do
614+
it "loads a user-marshaled object" do
615+
obj = UserMarshal.new
616+
obj.data = :data
617+
value = [obj, :data]
618+
dump = Marshal.dump(value)
619+
dump.should == "\x04\b[\aU:\x10UserMarshal:\tdata;\x06"
620+
reloaded = Marshal.load(dump)
621+
reloaded.should == value
622+
end
623+
end
624+
612625
describe "for a user object" do
613626
it "loads a user-marshaled extended object" do
614627
obj = UserMarshal.new.extend(Meths)

0 commit comments

Comments
 (0)