File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 78
78
s = "\u2192 " . force_encoding ( "binary" ) . to_sym
79
79
Marshal . dump ( s ) . should == "\x04 \b :\b \xE2 \x86 \x92 "
80
80
end
81
+
82
+ it "dumps multiple Symbols sharing the same encoding" do
83
+ # Note that the encoding is a link for the second Symbol
84
+ symbol1 = "I:\t \xE2 \x82 \xAC a\x06 :\x06 ET"
85
+ symbol2 = "I:\t \xE2 \x82 \xAC b\x06 ;\x06 T"
86
+ value = [
87
+ "€a" . force_encoding ( Encoding ::UTF_8 ) . to_sym ,
88
+ "€b" . force_encoding ( Encoding ::UTF_8 ) . to_sym
89
+ ]
90
+ Marshal . dump ( value ) . should == "\x04 \b [\a #{ symbol1 } #{ symbol2 } "
91
+
92
+ value = [ *value , value [ 0 ] ]
93
+ Marshal . dump ( value ) . should == "\x04 \b [\b #{ symbol1 } #{ symbol2 } ;\x00 "
94
+ end
81
95
end
82
96
83
97
describe "with an object responding to #marshal_dump" do
Original file line number Diff line number Diff line change 399
399
sym . should == s
400
400
sym . encoding . should == Encoding ::BINARY
401
401
end
402
+
403
+ it "loads multiple Symbols sharing the same encoding" do
404
+ # Note that the encoding is a link for the second Symbol
405
+ symbol1 = "I:\t \xE2 \x82 \xAC a\x06 :\x06 ET"
406
+ symbol2 = "I:\t \xE2 \x82 \xAC b\x06 ;\x06 T"
407
+ dump = "\x04 \b [\a #{ symbol1 } #{ symbol2 } "
408
+ value = Marshal . send ( @method , dump )
409
+ value . map ( &:encoding ) . should == [ Encoding ::UTF_8 , Encoding ::UTF_8 ]
410
+ expected = [
411
+ "€a" . force_encoding ( Encoding ::UTF_8 ) . to_sym ,
412
+ "€b" . force_encoding ( Encoding ::UTF_8 ) . to_sym
413
+ ]
414
+ value . should == expected
415
+
416
+ value = Marshal . send ( @method , "\x04 \b [\b #{ symbol1 } #{ symbol2 } ;\x00 " )
417
+ value . map ( &:encoding ) . should == [ Encoding ::UTF_8 , Encoding ::UTF_8 , Encoding ::UTF_8 ]
418
+ value . should == [ *expected , expected [ 0 ] ]
419
+ end
402
420
end
403
421
404
422
describe "for a String" do
You can’t perform that action at this time.
0 commit comments