mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@6f38a82
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b864bd05bf
commit
4fbb9aa3cb
145 changed files with 2847 additions and 2596 deletions
|
@ -36,10 +36,8 @@ describe "String#crypt" do
|
|||
lambda { "hello".crypt("a\x00") }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
ruby_version_is "2.3" do
|
||||
it "raises an ArgumentError when the string contains NUL character" do
|
||||
lambda { "poison\0null".crypt("aa") }.should raise_error(ArgumentError)
|
||||
end
|
||||
it "raises an ArgumentError when the string contains NUL character" do
|
||||
lambda { "poison\0null".crypt("aa") }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "calls #to_str to converts the salt arg to a String" do
|
||||
|
|
|
@ -7,12 +7,10 @@ describe "String.new" do
|
|||
str.should be_an_instance_of(String)
|
||||
end
|
||||
|
||||
ruby_version_is "2.3" do
|
||||
it "accepts an encoding argument" do
|
||||
xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding 'utf-8'
|
||||
str = String.new(xA4xA2, encoding: 'euc-jp')
|
||||
str.encoding.should == Encoding::EUC_JP
|
||||
end
|
||||
it "accepts an encoding argument" do
|
||||
xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding 'utf-8'
|
||||
str = String.new(xA4xA2, encoding: 'euc-jp')
|
||||
str.encoding.should == Encoding::EUC_JP
|
||||
end
|
||||
|
||||
ruby_version_is "2.4" do
|
||||
|
|
|
@ -51,9 +51,8 @@ describe :string_each_line, shared: true do
|
|||
end
|
||||
end
|
||||
|
||||
quarantine! do # Currently fails on Travis
|
||||
ruby_version_is '2.5' do
|
||||
it "yields paragraphs (broken by 2 or more successive newlines) when passed ''" do
|
||||
it "yields paragraphs (broken by 2 or more successive newlines) when passed '' and replaces multiple newlines with only two ones" do
|
||||
a = []
|
||||
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
|
||||
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n"]
|
||||
|
@ -63,7 +62,6 @@ quarantine! do # Currently fails on Travis
|
|||
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n", "dog"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "uses $/" do
|
||||
before :each do
|
||||
|
@ -136,7 +134,7 @@ end
|
|||
|
||||
ruby_version_is '2.4' do
|
||||
context "when `chomp` keyword argument is passed" do
|
||||
it "removes new line characters" do
|
||||
it "removes new line characters when separator is not specified" do
|
||||
a = []
|
||||
"hello \nworld\n".send(@method, chomp: true) { |s| a << s }
|
||||
a.should == ["hello ", "world"]
|
||||
|
@ -145,6 +143,23 @@ end
|
|||
"hello \r\nworld\r\n".send(@method, chomp: true) { |s| a << s }
|
||||
a.should == ["hello ", "world"]
|
||||
end
|
||||
|
||||
it "removes only specified separator" do
|
||||
a = []
|
||||
"hello world".send(@method, ' ', chomp: true) { |s| a << s }
|
||||
a.should == ["hello", "world"]
|
||||
end
|
||||
|
||||
# https://bugs.ruby-lang.org/issues/14257
|
||||
it "ignores new line characters when separator is specified" do
|
||||
a = []
|
||||
"hello\n world\n".send(@method, ' ', chomp: true) { |s| a << s }
|
||||
a.should == ["hello\n", "world\n"]
|
||||
|
||||
a = []
|
||||
"hello\r\n world\r\n".send(@method, ' ', chomp: true) { |s| a << s }
|
||||
a.should == ["hello\r\n", "world\r\n"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,46 +1,44 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.3" do
|
||||
describe 'String#-@' do
|
||||
it 'returns self if the String is frozen' do
|
||||
input = 'foo'.freeze
|
||||
output = -input
|
||||
describe 'String#-@' do
|
||||
it 'returns self if the String is frozen' do
|
||||
input = 'foo'.freeze
|
||||
output = -input
|
||||
|
||||
output.equal?(input).should == true
|
||||
output.frozen?.should == true
|
||||
output.equal?(input).should == true
|
||||
output.frozen?.should == true
|
||||
end
|
||||
|
||||
it 'returns a frozen copy if the String is not frozen' do
|
||||
input = 'foo'
|
||||
output = -input
|
||||
|
||||
output.frozen?.should == true
|
||||
output.should == 'foo'
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns the same object for equal unfrozen strings" do
|
||||
origin = "this is a string"
|
||||
dynamic = %w(this is a string).join(' ')
|
||||
|
||||
origin.should_not equal(dynamic)
|
||||
(-origin).should equal(-dynamic)
|
||||
end
|
||||
|
||||
it 'returns a frozen copy if the String is not frozen' do
|
||||
input = 'foo'
|
||||
output = -input
|
||||
|
||||
output.frozen?.should == true
|
||||
output.should == 'foo'
|
||||
it "returns the same object when it's called on the same String literal" do
|
||||
(-"unfrozen string").should equal(-"unfrozen string")
|
||||
(-"unfrozen string").should_not equal(-"another unfrozen string")
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns the same object for equal unfrozen strings" do
|
||||
origin = "this is a string"
|
||||
dynamic = %w(this is a string).join(' ')
|
||||
it "is an identity function if the string is frozen" do
|
||||
dynamic = %w(this string is frozen).join(' ').freeze
|
||||
|
||||
origin.should_not equal(dynamic)
|
||||
(-origin).should equal(-dynamic)
|
||||
end
|
||||
(-dynamic).should equal(dynamic)
|
||||
|
||||
it "returns the same object when it's called on the same String literal" do
|
||||
(-"unfrozen string").should equal(-"unfrozen string")
|
||||
(-"unfrozen string").should_not equal(-"another unfrozen string")
|
||||
end
|
||||
|
||||
it "is an identity function if the string is frozen" do
|
||||
dynamic = %w(this string is frozen).join(' ').freeze
|
||||
|
||||
(-dynamic).should equal(dynamic)
|
||||
|
||||
dynamic.should_not equal("this string is frozen".freeze)
|
||||
(-dynamic).should_not equal("this string is frozen".freeze)
|
||||
(-dynamic).should_not equal(-"this string is frozen".freeze)
|
||||
end
|
||||
dynamic.should_not equal("this string is frozen".freeze)
|
||||
(-dynamic).should_not equal("this string is frozen".freeze)
|
||||
(-dynamic).should_not equal(-"this string is frozen".freeze)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,272 +3,270 @@ require_relative '../fixtures/classes'
|
|||
require_relative 'shared/basic'
|
||||
require_relative 'shared/integer'
|
||||
|
||||
ruby_version_is '2.3' do
|
||||
platform_is pointer_size: 64 do
|
||||
little_endian do
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J_'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J!'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J!'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j_'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j!'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
big_endian do
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J_'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J!'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J!'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j_'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j!'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
platform_is pointer_size: 64 do
|
||||
little_endian do
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '<'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J<'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J<'
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J_'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J_'
|
||||
end
|
||||
|
||||
describe "with modifier '>'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J>'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J>'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '_'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J<_'
|
||||
it_behaves_like :string_unpack_64bit_le, 'J_<'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J<_'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J_<'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '!'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J<!'
|
||||
it_behaves_like :string_unpack_64bit_le, 'J!<'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J<!'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J!<'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '_'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J>_'
|
||||
it_behaves_like :string_unpack_64bit_be, 'J_>'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J>_'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J_>'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '!'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J>!'
|
||||
it_behaves_like :string_unpack_64bit_be, 'J!>'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J>!'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J!>'
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J!'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J!'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '<'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j<'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j<'
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j_'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j_'
|
||||
end
|
||||
|
||||
describe "with modifier '>'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j>'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j>'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '_'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j<_'
|
||||
it_behaves_like :string_unpack_64bit_le, 'j_<'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j<_'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j_<'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '!'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j<!'
|
||||
it_behaves_like :string_unpack_64bit_le, 'j!<'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j<!'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j!<'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '_'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j>_'
|
||||
it_behaves_like :string_unpack_64bit_be, 'j_>'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j>_'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j_>'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '!'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j>!'
|
||||
it_behaves_like :string_unpack_64bit_be, 'j!>'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j>!'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j!>'
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j!'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
platform_is pointer_size: 32 do
|
||||
little_endian do
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J_'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J!'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J!'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j_'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j!'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
big_endian do
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J_'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J!'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J!'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j_'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j!'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
big_endian do
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '<'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J<'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J<'
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J_'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J_'
|
||||
end
|
||||
|
||||
describe "with modifier '>'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J>'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J>'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '_'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J<_'
|
||||
it_behaves_like :string_unpack_32bit_le, 'J_<'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J<_'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J_<'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '!'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J<!'
|
||||
it_behaves_like :string_unpack_32bit_le, 'J!<'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J<!'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J!<'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '_'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J>_'
|
||||
it_behaves_like :string_unpack_32bit_be, 'J_>'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J>_'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J_>'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '!'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J>!'
|
||||
it_behaves_like :string_unpack_32bit_be, 'J!>'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J>!'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J!>'
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J!'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J!'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '<'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j<'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j<'
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j_'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j_'
|
||||
end
|
||||
|
||||
describe "with modifier '>'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j>'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j>'
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j!'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '_'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j<_'
|
||||
it_behaves_like :string_unpack_32bit_le, 'j_<'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j<_'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j_<'
|
||||
end
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '<'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J<'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J<'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '!'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j<!'
|
||||
it_behaves_like :string_unpack_32bit_le, 'j!<'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j<!'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j!<'
|
||||
end
|
||||
describe "with modifier '>'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J>'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J>'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '_'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j>_'
|
||||
it_behaves_like :string_unpack_32bit_be, 'j_>'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j>_'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j_>'
|
||||
end
|
||||
describe "with modifier '<' and '_'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J<_'
|
||||
it_behaves_like :string_unpack_64bit_le, 'J_<'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J<_'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J_<'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '!'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j>!'
|
||||
it_behaves_like :string_unpack_32bit_be, 'j!>'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j>!'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j!>'
|
||||
end
|
||||
describe "with modifier '<' and '!'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'J<!'
|
||||
it_behaves_like :string_unpack_64bit_le, 'J!<'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J<!'
|
||||
it_behaves_like :string_unpack_64bit_le_unsigned, 'J!<'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '_'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J>_'
|
||||
it_behaves_like :string_unpack_64bit_be, 'J_>'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J>_'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J_>'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '!'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'J>!'
|
||||
it_behaves_like :string_unpack_64bit_be, 'J!>'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J>!'
|
||||
it_behaves_like :string_unpack_64bit_be_unsigned, 'J!>'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '<'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j<'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j<'
|
||||
end
|
||||
|
||||
describe "with modifier '>'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j>'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j>'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '_'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j<_'
|
||||
it_behaves_like :string_unpack_64bit_le, 'j_<'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j<_'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j_<'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '!'" do
|
||||
it_behaves_like :string_unpack_64bit_le, 'j<!'
|
||||
it_behaves_like :string_unpack_64bit_le, 'j!<'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j<!'
|
||||
it_behaves_like :string_unpack_64bit_le_signed, 'j!<'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '_'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j>_'
|
||||
it_behaves_like :string_unpack_64bit_be, 'j_>'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j>_'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j_>'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '!'" do
|
||||
it_behaves_like :string_unpack_64bit_be, 'j>!'
|
||||
it_behaves_like :string_unpack_64bit_be, 'j!>'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j>!'
|
||||
it_behaves_like :string_unpack_64bit_be_signed, 'j!>'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
platform_is pointer_size: 32 do
|
||||
little_endian do
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J_'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J!'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J!'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j_'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j!'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
big_endian do
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J_'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J!'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J!'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '_'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j_'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j_'
|
||||
end
|
||||
|
||||
describe "with modifier '!'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j!'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'J'" do
|
||||
describe "with modifier '<'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J<'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J<'
|
||||
end
|
||||
|
||||
describe "with modifier '>'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J>'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J>'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '_'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J<_'
|
||||
it_behaves_like :string_unpack_32bit_le, 'J_<'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J<_'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J_<'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '!'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'J<!'
|
||||
it_behaves_like :string_unpack_32bit_le, 'J!<'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J<!'
|
||||
it_behaves_like :string_unpack_32bit_le_unsigned, 'J!<'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '_'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J>_'
|
||||
it_behaves_like :string_unpack_32bit_be, 'J_>'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J>_'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J_>'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '!'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'J>!'
|
||||
it_behaves_like :string_unpack_32bit_be, 'J!>'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J>!'
|
||||
it_behaves_like :string_unpack_32bit_be_unsigned, 'J!>'
|
||||
end
|
||||
end
|
||||
|
||||
describe "String#unpack with format 'j'" do
|
||||
describe "with modifier '<'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j<'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j<'
|
||||
end
|
||||
|
||||
describe "with modifier '>'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j>'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j>'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '_'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j<_'
|
||||
it_behaves_like :string_unpack_32bit_le, 'j_<'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j<_'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j_<'
|
||||
end
|
||||
|
||||
describe "with modifier '<' and '!'" do
|
||||
it_behaves_like :string_unpack_32bit_le, 'j<!'
|
||||
it_behaves_like :string_unpack_32bit_le, 'j!<'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j<!'
|
||||
it_behaves_like :string_unpack_32bit_le_signed, 'j!<'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '_'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j>_'
|
||||
it_behaves_like :string_unpack_32bit_be, 'j_>'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j>_'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j_>'
|
||||
end
|
||||
|
||||
describe "with modifier '>' and '!'" do
|
||||
it_behaves_like :string_unpack_32bit_be, 'j>!'
|
||||
it_behaves_like :string_unpack_32bit_be, 'j!>'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j>!'
|
||||
it_behaves_like :string_unpack_32bit_be_signed, 'j!>'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.3" do
|
||||
describe 'String#+@' do
|
||||
it 'returns an unfrozen copy of a frozen String' do
|
||||
input = 'foo'.freeze
|
||||
output = +input
|
||||
describe 'String#+@' do
|
||||
it 'returns an unfrozen copy of a frozen String' do
|
||||
input = 'foo'.freeze
|
||||
output = +input
|
||||
|
||||
output.frozen?.should == false
|
||||
output.should == 'foo'
|
||||
end
|
||||
output.frozen?.should == false
|
||||
output.should == 'foo'
|
||||
end
|
||||
|
||||
it 'returns self if the String is not frozen' do
|
||||
input = 'foo'
|
||||
output = +input
|
||||
it 'returns self if the String is not frozen' do
|
||||
input = 'foo'
|
||||
output = +input
|
||||
|
||||
output.equal?(input).should == true
|
||||
end
|
||||
output.equal?(input).should == true
|
||||
end
|
||||
|
||||
it 'returns mutable copy despite freeze-magic-comment in file' do
|
||||
ruby_exe(fixture(__FILE__, "freeze_magic_comment.rb")).should == 'mutable'
|
||||
end
|
||||
it 'returns mutable copy despite freeze-magic-comment in file' do
|
||||
ruby_exe(fixture(__FILE__, "freeze_magic_comment.rb")).should == 'mutable'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue