diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-28 19:50:06 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-28 19:50:06 +0000 |
commit | 4fbb9aa3cb6c31ec128bfb31f59efa66d66adba4 (patch) | |
tree | 84a654b260261fe172f2584f60b3ba93e59f841d /spec/ruby/core/string | |
parent | b864bd05bff2a61d55b08deb92e969f9fa55e07c (diff) |
Update to ruby/spec@6f38a82
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/string')
-rw-r--r-- | spec/ruby/core/string/crypt_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/core/string/new_spec.rb | 10 | ||||
-rw-r--r-- | spec/ruby/core/string/shared/each_line.rb | 23 | ||||
-rw-r--r-- | spec/ruby/core/string/uminus_spec.rb | 64 | ||||
-rw-r--r-- | spec/ruby/core/string/unpack/j_spec.rb | 414 | ||||
-rw-r--r-- | spec/ruby/core/string/uplus_spec.rb | 30 |
6 files changed, 276 insertions, 271 deletions
diff --git a/spec/ruby/core/string/crypt_spec.rb b/spec/ruby/core/string/crypt_spec.rb index 697dfd5190..01d3830892 100644 --- a/spec/ruby/core/string/crypt_spec.rb +++ b/spec/ruby/core/string/crypt_spec.rb @@ -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 diff --git a/spec/ruby/core/string/new_spec.rb b/spec/ruby/core/string/new_spec.rb index 7d1c361bf8..a65c6da2d1 100644 --- a/spec/ruby/core/string/new_spec.rb +++ b/spec/ruby/core/string/new_spec.rb @@ -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 diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb index dee741e270..19cf5e6d78 100644 --- a/spec/ruby/core/string/shared/each_line.rb +++ b/spec/ruby/core/string/shared/each_line.rb @@ -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 diff --git a/spec/ruby/core/string/uminus_spec.rb b/spec/ruby/core/string/uminus_spec.rb index a2b6fad098..f79683cb74 100644 --- a/spec/ruby/core/string/uminus_spec.rb +++ b/spec/ruby/core/string/uminus_spec.rb @@ -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 - - output.equal?(input).should == true - output.frozen?.should == true - end +describe 'String#-@' do + it 'returns self if the String is frozen' do + input = 'foo'.freeze + output = -input - it 'returns a frozen copy if the String is not frozen' do - input = 'foo' - output = -input + output.equal?(input).should == true + output.frozen?.should == true + end - output.frozen?.should == true - output.should == 'foo' - end + it 'returns a frozen copy if the String is not frozen' do + input = 'foo' + output = -input - 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(' ') + output.frozen?.should == true + output.should == 'foo' + end - origin.should_not equal(dynamic) - (-origin).should equal(-dynamic) - 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 "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 + origin.should_not equal(dynamic) + (-origin).should equal(-dynamic) + end + + 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 + 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 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 diff --git a/spec/ruby/core/string/unpack/j_spec.rb b/spec/ruby/core/string/unpack/j_spec.rb index 8f4213bd97..3c2baad642 100644 --- a/spec/ruby/core/string/unpack/j_spec.rb +++ b/spec/ruby/core/string/unpack/j_spec.rb @@ -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 +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 "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 + describe "with modifier '!'" do + it_behaves_like :string_unpack_64bit_le, 'J!' + it_behaves_like :string_unpack_64bit_le_unsigned, 'J!' 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 + 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 "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 + 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_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>' + 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!<' + describe "with modifier '!'" do + it_behaves_like :string_unpack_64bit_be, 'J!' + it_behaves_like :string_unpack_64bit_be_unsigned, 'J!' end + 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 "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 '>' 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_be, 'j!' + it_behaves_like :string_unpack_64bit_be_signed, 'j!' end 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 "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_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_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_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_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_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_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_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_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_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_unsigned, 'J>!' + it_behaves_like :string_unpack_64bit_be_unsigned, 'J!>' 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 "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_32bit_le, 'j!' - it_behaves_like :string_unpack_32bit_le_signed, 'j!' - end - end + describe "with modifier '>'" do + it_behaves_like :string_unpack_64bit_be, 'j>' + it_behaves_like :string_unpack_64bit_be_signed, 'j>' 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 '<' 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 '!'" do - it_behaves_like :string_unpack_32bit_be, 'J!' - it_behaves_like :string_unpack_32bit_be_unsigned, 'J!' - end - 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 "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 '>' 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 '!'" do - it_behaves_like :string_unpack_32bit_be, 'j!' - it_behaves_like :string_unpack_32bit_be_signed, 'j!' - end - 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<' + 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>' + describe "with modifier '!'" do + it_behaves_like :string_unpack_32bit_le, 'J!' + it_behaves_like :string_unpack_32bit_le_unsigned, 'J!' 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_unsigned, 'J<_' - it_behaves_like :string_unpack_32bit_le_unsigned, 'J_<' + 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 '<' 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!<' + describe "with modifier '!'" do + it_behaves_like :string_unpack_32bit_le, 'j!' + it_behaves_like :string_unpack_32bit_le_signed, 'j!' end + end + 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_>' + 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 '>' 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_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_le, 'j<' - it_behaves_like :string_unpack_32bit_le_signed, 'j<' + 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>' + 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 "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_32bit_le, '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_signed, '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_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_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_signed, '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_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 diff --git a/spec/ruby/core/string/uplus_spec.rb b/spec/ruby/core/string/uplus_spec.rb index 6c6792590e..a7402b4549 100644 --- a/spec/ruby/core/string/uplus_spec.rb +++ b/spec/ruby/core/string/uplus_spec.rb @@ -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 |