summaryrefslogtreecommitdiff
path: root/spec/ruby/core/array/pack/z_spec.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2022-01-10 16:29:54 +0100
committerBenoit Daloze <eregontp@gmail.com>2022-01-10 16:29:54 +0100
commit4053e8ba0d39b688440fedee2ab3fffabcd64312 (patch)
tree8a29366a09cd159798fada68fb1007a2fece5ec6 /spec/ruby/core/array/pack/z_spec.rb
parent8abfc106058d09840d13f64e7e87cb7e40c3d6fa (diff)
Update to ruby/spec@226cfdc
Diffstat (limited to 'spec/ruby/core/array/pack/z_spec.rb')
-rw-r--r--spec/ruby/core/array/pack/z_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/ruby/core/array/pack/z_spec.rb b/spec/ruby/core/array/pack/z_spec.rb
index 82ce7b4a1c..5ad3afd69e 100644
--- a/spec/ruby/core/array/pack/z_spec.rb
+++ b/spec/ruby/core/array/pack/z_spec.rb
@@ -12,6 +12,16 @@ describe "Array#pack with format 'Z'" do
it_behaves_like :array_pack_string, 'Z'
it_behaves_like :array_pack_taint, 'Z'
+ it "calls #to_str to convert an Object to a String" do
+ obj = mock("pack Z string")
+ obj.should_receive(:to_str).and_return("``abcdef")
+ [obj].pack("Z*").should == "``abcdef\x00"
+ end
+
+ it "will not implicitly convert a number to a string" do
+ -> { [0].pack('Z') }.should raise_error(TypeError)
+ end
+
it "adds all the bytes and appends a NULL byte when passed the '*' modifier" do
["abc"].pack("Z*").should == "abc\x00"
end