Created
March 1, 2012 22:48
-
-
Save jfirebaugh/1953784 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "with a String" do | |
| it "dumps a blank String" do | |
| Marshal.dump(encode("", "binary")).should == "\004\b\"\000" | |
| end | |
| it "dumps a short String" do | |
| Marshal.dump(encode("short", "binary")).should == "\004\b\"\012short" | |
| end | |
| it "dumps a long String" do | |
| Marshal.dump(encode("big" * 100, "binary")).should == "\004\b\"\002,\001#{"big" * 100}" | |
| end | |
| it "dumps a String extended with a Module" do | |
| Marshal.dump(encode("".extend(Meths), "binary")).should == "\004\be:\nMeths\"\000" | |
| end | |
| it "dumps a String subclass" do | |
| Marshal.dump(encode(UserString.new, "binary")).should == "\004\bC:\017UserString\"\000" | |
| end | |
| it "dumps a String subclass extended with a Module" do | |
| Marshal.dump(encode(UserString.new.extend(Meths), "binary")).should == "\004\be:\nMethsC:\017UserString\"\000" | |
| end | |
| ruby_version_is "1.9" do | |
| it "dumps a US-ASCII String" do | |
| Marshal.dump("".encode("us-ascii")).should == "\x04\bI\"\x00\x06:\x06EF" | |
| end | |
| it "dumps a UTF-8 String" do | |
| Marshal.dump("".encode("utf-8")).should == "\x04\bI\"\x00\x06:\x06ET" | |
| end | |
| it "dumps a String in another encoding" do | |
| Marshal.dump("".encode("utf-16le")).should == "\x04\bI\"\x00\x06:\rencoding\"\rUTF-16LE" | |
| end | |
| end | |
| end | |
| describe "with a Regexp" do | |
| it "dumps a Regexp" do | |
| Marshal.dump(encode(/\A.\Z/, "binary")).should == "\004\b/\n\\A.\\Z\000" | |
| end | |
| it "dumps a Regexp with flags" do | |
| Marshal.dump(encode(//im, "binary")).should == "\x04\b/\000\005" | |
| end | |
| it "dumps a Regexp with instance variables" do | |
| o = encode(//, "binary") | |
| o.instance_variable_set(:@ivar, :ivar) | |
| Marshal.dump(o).should == "\004\bI/\000\000\006:\n@ivar:\tivar" | |
| end | |
| it "dumps an extended Regexp" do | |
| Marshal.dump(encode(//, "binary").extend(Meths)).should == "\004\be:\nMeths/\000\000" | |
| end | |
| ruby_version_is "".."1.9" do | |
| it "dumps a Regexp subclass" do | |
| Marshal.dump(UserRegexp.new("")).should == "\004\bC:\017UserRegexp/\000\000" | |
| end | |
| end | |
| ruby_version_is "1.9" do | |
| it "dumps a Regexp subclass" do | |
| Marshal.dump(UserRegexp.new("")).should == "\x04\bIC:\x0FUserRegexp/\x00\x00\x06:\x06EF" | |
| end | |
| it "dumps a US-ASCII Regexp" do | |
| Marshal.dump(encode(//, "us-ascii")).should == "\x04\bI/\x00\x10\x06:\x06EF" | |
| end | |
| it "dumps a UTF-8 Regexp" do | |
| Marshal.dump(encode(//, "utf-8")).should == "\x04\bI/\x00\x10\x06:\x06ET" | |
| end | |
| it "dumps a Regexp in another encoding" do | |
| Marshal.dump(encode(//, "utf-16le")).should == "\x04\bI/\x00\x10\x06:\rencoding\"\rUTF-16LE" | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0] | |
| .................................................................................................FFFF.......................... | |
| 1) | |
| Marshal.dump with a Regexp dumps a Regexp FAILED | |
| Expected "\x04\b/\n\\A.\\Z\x10" | |
| to equal "\x04\b/\n\\A.\\Z\x00" | |
| /Users/john/Development/rubinius/spec/ruby/core/marshal/dump_spec.rb:208:in `block (3 levels) in <top (required)>' | |
| /Users/john/Development/rubinius/spec/ruby/core/marshal/dump_spec.rb:4:in `<top (required)>' | |
| 2) | |
| Marshal.dump with a Regexp dumps a Regexp with flags FAILED | |
| Expected "\x04\b/\x00\x15" | |
| to equal "\x04\b/\x00\x05" | |
| /Users/john/Development/rubinius/spec/ruby/core/marshal/dump_spec.rb:212:in `block (3 levels) in <top (required)>' | |
| /Users/john/Development/rubinius/spec/ruby/core/marshal/dump_spec.rb:4:in `<top (required)>' | |
| 3) | |
| Marshal.dump with a Regexp dumps a Regexp with instance variables FAILED | |
| Expected "\x04\bI/\x00\x10\x06:\n@ivar:\tivar" | |
| to equal "\x04\bI/\x00\x00\x06:\n@ivar:\tivar" | |
| /Users/john/Development/rubinius/spec/ruby/core/marshal/dump_spec.rb:218:in `block (3 levels) in <top (required)>' | |
| /Users/john/Development/rubinius/spec/ruby/core/marshal/dump_spec.rb:4:in `<top (required)>' | |
| 4) | |
| Marshal.dump with a Regexp dumps an extended Regexp FAILED | |
| Expected "\x04\be:\nMeths/\x00\x10" | |
| to equal "\x04\be:\nMeths/\x00\x00" | |
| /Users/john/Development/rubinius/spec/ruby/core/marshal/dump_spec.rb:222:in `block (3 levels) in <top (required)>' | |
| /Users/john/Development/rubinius/spec/ruby/core/marshal/dump_spec.rb:4:in `<top (required)>' | |
| Finished in 0.033451 seconds | |
| 1 file, 127 examples, 136 expectations, 4 failures, 0 errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment