1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-07-27 12:40:09 +02:00
parent a06301b103
commit 5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions

View file

@ -1,6 +1,6 @@
describe :array_pack_arguments, shared: true do
it "raises an ArgumentError if there are fewer elements than the format requires" do
lambda { [].pack(pack_format(1)) }.should raise_error(ArgumentError)
-> { [].pack(pack_format(1)) }.should raise_error(ArgumentError)
end
end
@ -10,11 +10,11 @@ describe :array_pack_basic, shared: true do
end
it "raises a TypeError when passed nil" do
lambda { [@obj].pack(nil) }.should raise_error(TypeError)
-> { [@obj].pack(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed an Integer" do
lambda { [@obj].pack(1) }.should raise_error(TypeError)
-> { [@obj].pack(1) }.should raise_error(TypeError)
end
end
@ -56,10 +56,10 @@ end
describe :array_pack_no_platform, shared: true do
it "raises ArgumentError when the format modifier is '_'" do
lambda{ [1].pack(pack_format("_")) }.should raise_error(ArgumentError)
->{ [1].pack(pack_format("_")) }.should raise_error(ArgumentError)
end
it "raises ArgumentError when the format modifier is '!'" do
lambda{ [1].pack(pack_format("!")) }.should raise_error(ArgumentError)
->{ [1].pack(pack_format("!")) }.should raise_error(ArgumentError)
end
end

View file

@ -5,12 +5,12 @@ describe :array_pack_hex, shared: true do
it "raises a TypeError if the object does not respond to #to_str" do
obj = mock("pack hex non-string")
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_str does not return a String" do
obj = mock("pack hex non-string")
obj.should_receive(:to_str).and_return(1)
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
end
end

View file

@ -14,7 +14,7 @@ describe :array_pack_float_le, shared: true do
end
it "raises a TypeError if passed a String representation of a floating point number" do
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
-> { ["13"].pack(pack_format) }.should raise_error(TypeError)
end
it "encodes the number of array elements specified by the count modifier" do
@ -69,7 +69,7 @@ describe :array_pack_float_be, shared: true do
end
it "raises a TypeError if passed a String representation of a floating point number" do
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
-> { ["13"].pack(pack_format) }.should raise_error(TypeError)
end
it "encodes the number of array elements specified by the count modifier" do
@ -124,7 +124,7 @@ describe :array_pack_double_le, shared: true do
end
it "raises a TypeError if passed a String representation of a floating point number" do
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
-> { ["13"].pack(pack_format) }.should raise_error(TypeError)
end
it "encodes the number of array elements specified by the count modifier" do
@ -183,7 +183,7 @@ describe :array_pack_double_be, shared: true do
end
it "raises a TypeError if passed a String representation of a floating point number" do
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
-> { ["13"].pack(pack_format) }.should raise_error(TypeError)
end
it "encodes the number of array elements specified by the count modifier" do

View file

@ -4,15 +4,15 @@ describe :array_pack_numeric_basic, shared: true do
end
it "raises a TypeError when passed nil" do
lambda { [nil].pack(pack_format) }.should raise_error(TypeError)
-> { [nil].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError when passed true" do
lambda { [true].pack(pack_format) }.should raise_error(TypeError)
-> { [true].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError when passed false" do
lambda { [false].pack(pack_format) }.should raise_error(TypeError)
-> { [false].pack(pack_format) }.should raise_error(TypeError)
end
it "returns a binary string" do
@ -24,21 +24,21 @@ end
describe :array_pack_integer, shared: true do
it "raises a TypeError when the object does not respond to #to_int" do
obj = mock('not an integer')
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
lambda { ["5"].pack(pack_format) }.should raise_error(TypeError)
-> { ["5"].pack(pack_format) }.should raise_error(TypeError)
end
end
describe :array_pack_float, shared: true do
it "raises a TypeError if a String does not represent a floating point number" do
lambda { ["a"].pack(pack_format) }.should raise_error(TypeError)
-> { ["a"].pack(pack_format) }.should raise_error(TypeError)
end
it "raises a TypeError when the object does not respond to #to_f" do
obj = mock('not an float')
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
end
end

View file

@ -17,11 +17,11 @@ describe :array_pack_string, shared: true do
end
it "raises an ArgumentError when the Array is empty" do
lambda { [].pack(pack_format) }.should raise_error(ArgumentError)
-> { [].pack(pack_format) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the Array has too few elements" do
lambda { ["a"].pack(pack_format(nil, 2)) }.should raise_error(ArgumentError)
-> { ["a"].pack(pack_format(nil, 2)) }.should raise_error(ArgumentError)
end
it "calls #to_str to convert the element to a String" do
@ -33,7 +33,7 @@ describe :array_pack_string, shared: true do
it "raises a TypeError when the object does not respond to #to_str" do
obj = mock("not a string")
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
end
it "returns a string in encoding of common to the concatenated results" do

View file

@ -64,7 +64,7 @@ describe :array_pack_unicode, shared: true do
it "raises a TypeError if #to_int does not return an Integer" do
obj = mock('to_int')
obj.should_receive(:to_int).and_return("5")
lambda { [obj].pack("U") }.should raise_error(TypeError)
-> { [obj].pack("U") }.should raise_error(TypeError)
end
it "ignores NULL bytes between directives" do
@ -76,11 +76,11 @@ describe :array_pack_unicode, shared: true do
end
it "raises a RangeError if passed a negative number" do
lambda { [-1].pack("U") }.should raise_error(RangeError)
-> { [-1].pack("U") }.should raise_error(RangeError)
end
it "raises a RangeError if passed a number larger than an unsigned 32-bit integer" do
lambda { [2**32].pack("U") }.should raise_error(RangeError)
-> { [2**32].pack("U") }.should raise_error(RangeError)
end
it "sets the output string to UTF-8 encoding" do