diff --git a/spec/core/marshal/dump_spec.rb b/spec/core/marshal/dump_spec.rb index d20103d45..d5e1f5497 100644 --- a/spec/core/marshal/dump_spec.rb +++ b/spec/core/marshal/dump_spec.rb @@ -79,9 +79,7 @@ it "dumps a binary encoded Symbol" do s = "\u2192".dup.force_encoding("binary").to_sym - NATFIXME 'dumps a binary encoded Symbol', exception: SpecFailedException do - Marshal.dump(s).should == "\x04\b:\b\xE2\x86\x92" - end + Marshal.dump(s).should == "\x04\b:\b\xE2\x86\x92" end it "dumps multiple Symbols sharing the same encoding" do @@ -384,9 +382,7 @@ def _dump(level) it "dumps a UTF-8 String" do str = "\x6d\xc3\xb6\x68\x72\x65".dup.force_encoding("utf-8") - NATFIXME 'dumps a UTF-8 String', exception: SpecFailedException do - Marshal.dump(str).should == "\x04\bI\"\vm\xC3\xB6hre\x06:\x06ET" - end + Marshal.dump(str).should == "\x04\bI\"\vm\xC3\xB6hre\x06:\x06ET" end it "dumps a String in another encoding" do @@ -452,15 +448,13 @@ def _dump(level) it "dumps a UTF-8 Regexp" do o = Regexp.new("".dup.force_encoding("utf-8"), Regexp::FIXEDENCODING) - NATFIXME 'dumps a UTF-8 Regexp', exception: SpecFailedException do - Marshal.dump(o).should == "\x04\bI/\x00\x10\x06:\x06ET" + Marshal.dump(o).should == "\x04\bI/\x00\x10\x06:\x06ET" - o = Regexp.new("a".dup.force_encoding("utf-8"), Regexp::FIXEDENCODING) - Marshal.dump(o).should == "\x04\bI/\x06a\x10\x06:\x06ET" + o = Regexp.new("a".dup.force_encoding("utf-8"), Regexp::FIXEDENCODING) + Marshal.dump(o).should == "\x04\bI/\x06a\x10\x06:\x06ET" - o = Regexp.new("\u3042".dup.force_encoding("utf-8"), Regexp::FIXEDENCODING) - Marshal.dump(o).should == "\x04\bI/\b\xE3\x81\x82\x10\x06:\x06ET" - end + o = Regexp.new("\u3042".dup.force_encoding("utf-8"), Regexp::FIXEDENCODING) + Marshal.dump(o).should == "\x04\bI/\b\xE3\x81\x82\x10\x06:\x06ET" end it "dumps a Regexp in another encoding" do diff --git a/src/marshal.rb b/src/marshal.rb index 9130a5d10..8436c2c91 100644 --- a/src/marshal.rb +++ b/src/marshal.rb @@ -97,7 +97,7 @@ def write_bigint_bytes(value) def write_string_bytes(value) string = value.to_s - write_integer_bytes(string.length) + write_integer_bytes(string.bytesize) write_bytes(string) end