File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 357
357
end
358
358
359
359
it "dumps an extended Struct" do
360
- st = Struct . new ( "Extended" , :a , :b ) . new
361
- Marshal . dump ( st . extend ( Meths ) ) . should == "\004 \b e:\n MethsS:\025 Struct::Extended\a :\006 a0:\006 b0"
360
+ obj = Struct . new ( "Extended" , :a , :b ) . new . extend ( Meths )
361
+ Marshal . dump ( obj ) . should == "\004 \b e:\n MethsS:\025 Struct::Extended\a :\006 a0:\006 b0"
362
+
363
+ s = 'hi'
364
+ obj . a = [ :a , s ]
365
+ obj . b = [ :Meths , s ]
366
+ Marshal . dump ( obj ) . should == "\004 \b e:\n MethsS:\025 Struct::Extended\a :\006 a[\a ;\a \" \a hi:\006 b[\a ;\000 @\a "
362
367
Struct . send ( :remove_const , :Extended )
363
368
end
364
369
end
Original file line number Diff line number Diff line change 478
478
describe "for a Struct" do
479
479
it "loads a extended_struct having fields with same objects" do
480
480
s = 'hi'
481
- obj = Struct . new ( "Ure2" , :a , :b ) . new . extend ( Meths )
481
+ obj = Struct . new ( "Extended" , :a , :b ) . new . extend ( Meths )
482
+ dump = "\004 \b e:\n MethsS:\025 Struct::Extended\a :\006 a0:\006 b0"
483
+ Marshal . send ( @method , dump ) . should == obj
484
+
482
485
obj . a = [ :a , s ]
483
486
obj . b = [ :Meths , s ]
484
-
485
- Marshal . send ( @method ,
486
- "\004 \b e:\n MethsS:\021 Struct::Ure2\a :\006 a[\a ;\a \" \a hi:\006 b[\a ;\000 @\a "
487
- ) . should == obj
488
- Struct . send ( :remove_const , :Ure2 )
487
+ dump = "\004 \b e:\n MethsS:\025 Struct::Extended\a :\006 a[\a ;\a \" \a hi:\006 b[\a ;\000 @\a "
488
+ Marshal . send ( @method , dump ) . should == obj
489
+ Struct . send ( :remove_const , :Extended )
489
490
end
490
491
491
492
it "loads a struct having ivar" do
492
493
obj = Struct . new ( "Thick" ) . new
493
494
obj . instance_variable_set ( :@foo , 5 )
494
- Marshal . send ( @method , "\004 \b IS:\022 Struct::Thick\000 \006 :\t @fooi\n " ) . should == obj
495
+ reloaded = Marshal . send ( @method , "\004 \b IS:\022 Struct::Thick\000 \006 :\t @fooi\n " )
496
+ reloaded . should == obj
497
+ reloaded . instance_variable_get ( :@foo ) . should == 5
495
498
Struct . send ( :remove_const , :Thick )
496
499
end
497
500
You can’t perform that action at this time.
0 commit comments