diff options
Diffstat (limited to 'spec/ruby/core/array/pack/m_spec.rb')
| -rw-r--r-- | spec/ruby/core/array/pack/m_spec.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/spec/ruby/core/array/pack/m_spec.rb b/spec/ruby/core/array/pack/m_spec.rb index 40c2e3f1fa..a80f91275c 100644 --- a/spec/ruby/core/array/pack/m_spec.rb +++ b/spec/ruby/core/array/pack/m_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' @@ -80,8 +80,16 @@ describe "Array#pack with format 'M'" do ].should be_computed_by(:pack, "M") end - it "encodes a tab followed by a newline with an encoded newline" do + it "encodes a tab at the end of a line with an encoded newline" do + ["\t"].pack("M").should == "\t=\n" ["\t\n"].pack("M").should == "\t=\n\n" + ["abc\t\nxyz"].pack("M").should == "abc\t=\n\nxyz=\n" + end + + it "encodes a space at the end of a line with an encoded newline" do + [" "].pack("M").should == " =\n" + [" \n"].pack("M").should == " =\n\n" + ["abc \nxyz"].pack("M").should == "abc =\n\nxyz=\n" end it "encodes 127..255 in hex format" do @@ -285,16 +293,16 @@ describe "Array#pack with format 'm'" do it "raises a TypeError if #to_str does not return a String" do obj = mock("pack m non-string") - lambda { [obj].pack("m") }.should raise_error(TypeError) + -> { [obj].pack("m") }.should raise_error(TypeError) end it "raises a TypeError if passed nil" do - lambda { [nil].pack("m") }.should raise_error(TypeError) + -> { [nil].pack("m") }.should raise_error(TypeError) end it "raises a TypeError if passed an Integer" do - lambda { [0].pack("m") }.should raise_error(TypeError) - lambda { [bignum_value].pack("m") }.should raise_error(TypeError) + -> { [0].pack("m") }.should raise_error(TypeError) + -> { [bignum_value].pack("m") }.should raise_error(TypeError) end it "does not emit a newline if passed zero as the count modifier" do |
