aboutsummaryrefslogtreecommitdiffstats
path: root/spec/rubyspec/core
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-27 12:10:41 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-27 12:10:41 +0000
commit0cb5fa5877f7b00d1396e0dda4156e8213d37215 (patch)
tree98225086822c74e28a61a308f8999a627bf182ae /spec/rubyspec/core
parent819977e4106c64efbcee608300dfe419903c104c (diff)
downloadruby-0cb5fa5877f7b00d1396e0dda4156e8213d37215.tar.gz
Update to ruby/spec@c3e6b90
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/core')
-rw-r--r--spec/rubyspec/core/array/pack/j_spec.rb4
-rw-r--r--spec/rubyspec/core/array/pack/l_spec.rb216
-rw-r--r--spec/rubyspec/core/io/close_on_exec_spec.rb137
-rw-r--r--spec/rubyspec/core/numeric/step_spec.rb14
-rw-r--r--spec/rubyspec/core/process/setrlimit_spec.rb20
-rw-r--r--spec/rubyspec/core/string/shared/slice.rb24
-rw-r--r--spec/rubyspec/core/string/unpack/l_spec.rb305
-rw-r--r--spec/rubyspec/core/thread/fixtures/classes.rb16
-rw-r--r--spec/rubyspec/core/thread/inspect_spec.rb8
-rw-r--r--spec/rubyspec/core/thread/status_spec.rb6
-rw-r--r--spec/rubyspec/core/thread/stop_spec.rb6
11 files changed, 292 insertions, 464 deletions
diff --git a/spec/rubyspec/core/array/pack/j_spec.rb b/spec/rubyspec/core/array/pack/j_spec.rb
index 6c68a6e8df..88f074724c 100644
--- a/spec/rubyspec/core/array/pack/j_spec.rb
+++ b/spec/rubyspec/core/array/pack/j_spec.rb
@@ -8,7 +8,7 @@ ruby_version_is '2.3' do
# To handle the special case of x64-mingw32
pointer_size = RUBY_PLATFORM =~ /\bx64\b/ ? 64 : 1.size * 8
- if pointer_size == 64 then
+ guard -> { pointer_size == 64 } do
describe "Array#pack with format 'J'" do
it_behaves_like :array_pack_basic, 'J'
it_behaves_like :array_pack_basic_non_float, 'J'
@@ -114,7 +114,7 @@ ruby_version_is '2.3' do
end
end
- if pointer_size == 32 then
+ guard -> { pointer_size == 32 } do
describe "Array#pack with format 'J'" do
it_behaves_like :array_pack_basic, 'J'
it_behaves_like :array_pack_basic_non_float, 'J'
diff --git a/spec/rubyspec/core/array/pack/l_spec.rb b/spec/rubyspec/core/array/pack/l_spec.rb
index 8066b23e90..5c1ad21d12 100644
--- a/spec/rubyspec/core/array/pack/l_spec.rb
+++ b/spec/rubyspec/core/array/pack/l_spec.rb
@@ -29,7 +29,7 @@ describe "Array#pack with format 'L'" do
it_behaves_like :array_pack_32bit_be, 'L>'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_32bit_le, 'L<_'
it_behaves_like :array_pack_32bit_le, 'L_<'
@@ -51,49 +51,25 @@ describe "Array#pack with format 'L'" do
end
end
- platform_is wordsize: 64 do
- platform_is_not :mingw32 do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_64bit_le, 'L<_'
- it_behaves_like :array_pack_64bit_le, 'L_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_64bit_le, 'L<!'
- it_behaves_like :array_pack_64bit_le, 'L!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_64bit_be, 'L>_'
- it_behaves_like :array_pack_64bit_be, 'L_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_64bit_be, 'L>!'
- it_behaves_like :array_pack_64bit_be, 'L!>'
- end
- end
-
- platform_is :mingw32 do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_32bit_le, 'L<_'
- it_behaves_like :array_pack_32bit_le, 'L_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_32bit_le, 'L<!'
- it_behaves_like :array_pack_32bit_le, 'L!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_32bit_be, 'L>_'
- it_behaves_like :array_pack_32bit_be, 'L_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_32bit_be, 'L>!'
- it_behaves_like :array_pack_32bit_be, 'L!>'
- end
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_64bit_le, 'L<_'
+ it_behaves_like :array_pack_64bit_le, 'L_<'
+ end
+
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_64bit_le, 'L<!'
+ it_behaves_like :array_pack_64bit_le, 'L!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_64bit_be, 'L>_'
+ it_behaves_like :array_pack_64bit_be, 'L_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_64bit_be, 'L>!'
+ it_behaves_like :array_pack_64bit_be, 'L!>'
end
end
end
@@ -107,7 +83,7 @@ describe "Array#pack with format 'l'" do
it_behaves_like :array_pack_32bit_be, 'l>'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_32bit_le, 'l<_'
it_behaves_like :array_pack_32bit_le, 'l_<'
@@ -129,49 +105,25 @@ describe "Array#pack with format 'l'" do
end
end
- platform_is wordsize: 64 do
- platform_is_not :mingw32 do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_64bit_le, 'l<_'
- it_behaves_like :array_pack_64bit_le, 'l_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_64bit_le, 'l<!'
- it_behaves_like :array_pack_64bit_le, 'l!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_64bit_be, 'l>_'
- it_behaves_like :array_pack_64bit_be, 'l_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_64bit_be, 'l>!'
- it_behaves_like :array_pack_64bit_be, 'l!>'
- end
- end
-
- platform_is :mingw32 do
- describe "with modifier '<' and '_'" do
- it_behaves_like :array_pack_32bit_le, 'l<_'
- it_behaves_like :array_pack_32bit_le, 'l_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :array_pack_32bit_le, 'l<!'
- it_behaves_like :array_pack_32bit_le, 'l!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :array_pack_32bit_be, 'l>_'
- it_behaves_like :array_pack_32bit_be, 'l_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :array_pack_32bit_be, 'l>!'
- it_behaves_like :array_pack_32bit_be, 'l!>'
- end
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :array_pack_64bit_le, 'l<_'
+ it_behaves_like :array_pack_64bit_le, 'l_<'
+ end
+
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :array_pack_64bit_le, 'l<!'
+ it_behaves_like :array_pack_64bit_le, 'l!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :array_pack_64bit_be, 'l>_'
+ it_behaves_like :array_pack_64bit_be, 'l_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :array_pack_64bit_be, 'l>!'
+ it_behaves_like :array_pack_64bit_be, 'l!>'
end
end
end
@@ -185,7 +137,7 @@ little_endian do
it_behaves_like :array_pack_32bit_le, 'l'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_32bit_le, 'L_'
end
@@ -203,41 +155,21 @@ little_endian do
end
end
- platform_is wordsize: 64 do
- platform_is_not :mingw32 do
- describe "Array#pack with format 'L' with modifier '_'" do
- it_behaves_like :array_pack_64bit_le, 'L_'
- end
-
- describe "Array#pack with format 'L' with modifier '!'" do
- it_behaves_like :array_pack_64bit_le, 'L!'
- end
-
- describe "Array#pack with format 'l' with modifier '_'" do
- it_behaves_like :array_pack_64bit_le, 'l_'
- end
-
- describe "Array#pack with format 'l' with modifier '!'" do
- it_behaves_like :array_pack_64bit_le, 'l!'
- end
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
+ describe "Array#pack with format 'L' with modifier '_'" do
+ it_behaves_like :array_pack_64bit_le, 'L_'
end
- platform_is :mingw32 do
- describe "Array#pack with format 'L' with modifier '_'" do
- it_behaves_like :array_pack_32bit_le, 'L_'
- end
-
- describe "Array#pack with format 'L' with modifier '!'" do
- it_behaves_like :array_pack_32bit_le, 'L!'
- end
+ describe "Array#pack with format 'L' with modifier '!'" do
+ it_behaves_like :array_pack_64bit_le, 'L!'
+ end
- describe "Array#pack with format 'l' with modifier '_'" do
- it_behaves_like :array_pack_32bit_le, 'l_'
- end
+ describe "Array#pack with format 'l' with modifier '_'" do
+ it_behaves_like :array_pack_64bit_le, 'l_'
+ end
- describe "Array#pack with format 'l' with modifier '!'" do
- it_behaves_like :array_pack_32bit_le, 'l!'
- end
+ describe "Array#pack with format 'l' with modifier '!'" do
+ it_behaves_like :array_pack_64bit_le, 'l!'
end
end
end
@@ -251,7 +183,7 @@ big_endian do
it_behaves_like :array_pack_32bit_be, 'l'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_32bit_be, 'L_'
end
@@ -269,41 +201,21 @@ big_endian do
end
end
- platform_is wordsize: 64 do
- platform_is_not :mingw32 do
- describe "Array#pack with format 'L' with modifier '_'" do
- it_behaves_like :array_pack_64bit_be, 'L_'
- end
-
- describe "Array#pack with format 'L' with modifier '!'" do
- it_behaves_like :array_pack_64bit_be, 'L!'
- end
-
- describe "Array#pack with format 'l' with modifier '_'" do
- it_behaves_like :array_pack_64bit_be, 'l_'
- end
-
- describe "Array#pack with format 'l' with modifier '!'" do
- it_behaves_like :array_pack_64bit_be, 'l!'
- end
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
+ describe "Array#pack with format 'L' with modifier '_'" do
+ it_behaves_like :array_pack_64bit_be, 'L_'
end
- platform_is :mingw32 do
- describe "Array#pack with format 'L' with modifier '_'" do
- it_behaves_like :array_pack_32bit_be, 'L_'
- end
-
- describe "Array#pack with format 'L' with modifier '!'" do
- it_behaves_like :array_pack_32bit_be, 'L!'
- end
+ describe "Array#pack with format 'L' with modifier '!'" do
+ it_behaves_like :array_pack_64bit_be, 'L!'
+ end
- describe "Array#pack with format 'l' with modifier '_'" do
- it_behaves_like :array_pack_32bit_be, 'l_'
- end
+ describe "Array#pack with format 'l' with modifier '_'" do
+ it_behaves_like :array_pack_64bit_be, 'l_'
+ end
- describe "Array#pack with format 'l' with modifier '!'" do
- it_behaves_like :array_pack_32bit_be, 'l!'
- end
+ describe "Array#pack with format 'l' with modifier '!'" do
+ it_behaves_like :array_pack_64bit_be, 'l!'
end
end
end
diff --git a/spec/rubyspec/core/io/close_on_exec_spec.rb b/spec/rubyspec/core/io/close_on_exec_spec.rb
index 46a58374f9..057a9a1c20 100644
--- a/spec/rubyspec/core/io/close_on_exec_spec.rb
+++ b/spec/rubyspec/core/io/close_on_exec_spec.rb
@@ -1,44 +1,5 @@
require File.expand_path('../../../spec_helper', __FILE__)
-describe :io_close_on_exec, shared: true do
- it "sets the close-on-exec flag if true" do
- @io.close_on_exec = true
- @io.close_on_exec?.should == true
- end
-
- it "sets the close-on-exec flag if non-false" do
- @io.close_on_exec = :true
- @io.close_on_exec?.should == true
- end
-
- it "unsets the close-on-exec flag if false" do
- @io.close_on_exec = true
- @io.close_on_exec = false
- @io.close_on_exec?.should == false
- end
-
- it "unsets the close-on-exec flag if nil" do
- @io.close_on_exec = true
- @io.close_on_exec = nil
- @io.close_on_exec?.should == false
- end
-
- it "ensures the IO's file descriptor is closed in exec'ed processes" do
- require 'fcntl'
- @io.close_on_exec = true
- (@io.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC).should == Fcntl::FD_CLOEXEC
- end
-
- it "raises IOError if called on a closed IO" do
- @io.close
- lambda { @io.close_on_exec = true }.should raise_error(IOError)
- end
-
- it "returns nil" do
- @io.send(:close_on_exec=, true).should be_nil
- end
-end
-
describe "IO#close_on_exec=" do
before :each do
@name = tmp('io_close_on_exec.txt')
@@ -50,47 +11,59 @@ describe "IO#close_on_exec=" do
rm_r @name
end
- platform_is :windows do
- ruby_version_is ""..."2.3" do
- it "returns false from #respond_to?" do
- @io.respond_to?(:close_on_exec=).should be_false
- end
-
- it "raises a NotImplementedError when called" do
- lambda { @io.close_on_exec = true }.should raise_error(NotImplementedError)
- end
+ guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
+ it "returns false from #respond_to?" do
+ @io.respond_to?(:close_on_exec=).should be_false
end
- ruby_version_is "2.3" do
- it_should_behave_like :io_close_on_exec
+ it "raises a NotImplementedError when called" do
+ lambda { @io.close_on_exec = true }.should raise_error(NotImplementedError)
end
end
- platform_is_not :windows do
- it_should_behave_like :io_close_on_exec
- end
-end
+ guard -> { platform_is_not :windows or ruby_version_is "2.3" } do
+ it "sets the close-on-exec flag if true" do
+ @io.close_on_exec = true
+ @io.close_on_exec?.should == true
+ end
+ it "sets the close-on-exec flag if non-false" do
+ @io.close_on_exec = :true
+ @io.close_on_exec?.should == true
+ end
-describe :io_is_close_on_exec, shared: true do
- it "returns true by default" do
- @io.close_on_exec?.should == true
- end
+ it "unsets the close-on-exec flag if false" do
+ @io.close_on_exec = true
+ @io.close_on_exec = false
+ @io.close_on_exec?.should == false
+ end
- it "returns true if set" do
- @io.close_on_exec = true
- @io.close_on_exec?.should == true
- end
+ it "unsets the close-on-exec flag if nil" do
+ @io.close_on_exec = true
+ @io.close_on_exec = nil
+ @io.close_on_exec?.should == false
+ end
+
+ it "ensures the IO's file descriptor is closed in exec'ed processes" do
+ require 'fcntl'
+ @io.close_on_exec = true
+ (@io.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC).should == Fcntl::FD_CLOEXEC
+ end
+
+ it "raises IOError if called on a closed IO" do
+ @io.close
+ lambda { @io.close_on_exec = true }.should raise_error(IOError)
+ end
- it "raises IOError if called on a closed IO" do
- @io.close
- lambda { @io.close_on_exec? }.should raise_error(IOError)
+ it "returns nil" do
+ @io.send(:close_on_exec=, true).should be_nil
+ end
end
end
describe "IO#close_on_exec?" do
before :each do
- @name = tmp('io_close_on_exec.txt')
+ @name = tmp('io_is_close_on_exec.txt')
@io = new_io @name
end
@@ -99,23 +72,29 @@ describe "IO#close_on_exec?" do
rm_r @name
end
- platform_is :windows do
- ruby_version_is ""..."2.3" do
- it "returns false from #respond_to?" do
- @io.respond_to?(:close_on_exec?).should be_false
- end
-
- it "raises a NotImplementedError when called" do
- lambda { @io.close_on_exec? }.should raise_error(NotImplementedError)
- end
+ guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
+ it "returns false from #respond_to?" do
+ @io.respond_to?(:close_on_exec?).should be_false
end
- ruby_version_is "2.3" do
- it_should_behave_like :io_close_on_exec
+ it "raises a NotImplementedError when called" do
+ lambda { @io.close_on_exec? }.should raise_error(NotImplementedError)
end
end
- platform_is_not :windows do
- it_should_behave_like :io_is_close_on_exec
+ guard -> { platform_is_not :windows or ruby_version_is "2.3" } do
+ it "returns true by default" do
+ @io.close_on_exec?.should == true
+ end
+
+ it "returns true if set" do
+ @io.close_on_exec = true
+ @io.close_on_exec?.should == true
+ end
+
+ it "raises IOError if called on a closed IO" do
+ @io.close
+ lambda { @io.close_on_exec? }.should raise_error(IOError)
+ end
end
end
diff --git a/spec/rubyspec/core/numeric/step_spec.rb b/spec/rubyspec/core/numeric/step_spec.rb
index 2c3237e194..256c150d4e 100644
--- a/spec/rubyspec/core/numeric/step_spec.rb
+++ b/spec/rubyspec/core/numeric/step_spec.rb
@@ -65,6 +65,10 @@ describe "Numeric#step" do
describe "when no block is given" do
describe "returned Enumerator" do
describe "size" do
+ it "should return infinity_value when limit is nil" do
+ 1.step(by: 42).size.should == infinity_value
+ end
+
it "should return infinity_value when step is 0" do
1.step(to: 5, by: 0).size.should == infinity_value
end
@@ -73,13 +77,21 @@ describe "Numeric#step" do
1.step(to: 2, by: 0.0).size.should == infinity_value
end
- it "should return infinity_value when the limit is Float::INFINITY" do
+ it "should return infinity_value when ascending towards a limit of Float::INFINITY" do
1.step(to: Float::INFINITY, by: 42).size.should == infinity_value
end
+ it "should return infinity_value when decending towards a limit of -Float::INFINITY" do
+ 1.step(to: -Float::INFINITY, by: -42).size.should == infinity_value
+ end
+
it "should return 1 when the both limit and step are Float::INFINITY" do
1.step(to: Float::INFINITY, by: Float::INFINITY).size.should == 1
end
+
+ it "should return 1 when the both limit and step are -Float::INFINITY" do
+ 1.step(to: -Float::INFINITY, by: -Float::INFINITY).size.should == 1
+ end
end
end
end
diff --git a/spec/rubyspec/core/process/setrlimit_spec.rb b/spec/rubyspec/core/process/setrlimit_spec.rb
index 89cd39746f..5d137ca6c1 100644
--- a/spec/rubyspec/core/process/setrlimit_spec.rb
+++ b/spec/rubyspec/core/process/setrlimit_spec.rb
@@ -73,13 +73,13 @@ platform_is_not :windows do
Process.setrlimit(:STACK, *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil
end
- platform_is_not :solaris do
- platform_is_not :aix do
- it "coerces :MEMLOCK into RLIMIT_MEMLOCK" do
- Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
- end
+ platform_is_not :solaris, :aix do
+ it "coerces :MEMLOCK into RLIMIT_MEMLOCK" do
+ Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
end
+ end
+ platform_is_not :solaris do
it "coerces :NPROC into RLIMIT_NPROC" do
Process.setrlimit(:NPROC, *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil
end
@@ -155,13 +155,13 @@ platform_is_not :windows do
Process.setrlimit("STACK", *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil
end
- platform_is_not :solaris do
- platform_is_not :aix do
- it "coerces 'MEMLOCK' into RLIMIT_MEMLOCK" do
- Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
- end
+ platform_is_not :solaris, :aix do
+ it "coerces 'MEMLOCK' into RLIMIT_MEMLOCK" do
+ Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
end
+ end
+ platform_is_not :solaris do
it "coerces 'NPROC' into RLIMIT_NPROC" do
Process.setrlimit("NPROC", *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil
end
diff --git a/spec/rubyspec/core/string/shared/slice.rb b/spec/rubyspec/core/string/shared/slice.rb
index 231c50d87f..697fa2e530 100644
--- a/spec/rubyspec/core/string/shared/slice.rb
+++ b/spec/rubyspec/core/string/shared/slice.rb
@@ -29,6 +29,10 @@ describe :string_slice, shared: true do
lambda { "hello".send(@method, {}) }.should raise_error(TypeError)
lambda { "hello".send(@method, []) }.should raise_error(TypeError)
end
+
+ it "raises a RangeError if the index is too big" do
+ lambda { "hello".send(@method, bignum_value) }.should raise_error(RangeError)
+ end
end
describe :string_slice_index_length, shared: true do
@@ -85,6 +89,21 @@ describe :string_slice_index_length, shared: true do
str.send(@method, 2,1).tainted?.should == true
end
+ it "returns a string with the same encoding" do
+ s = "hello there"
+ s.send(@method, 1, 9).encoding.should == s.encoding
+
+ a = "hello".force_encoding("binary")
+ b = " there".force_encoding("ISO-8859-1")
+ c = (a + b).force_encoding(Encoding::US_ASCII)
+
+ c.send(@method, 0, 5).encoding.should == Encoding::US_ASCII
+ c.send(@method, 5, 6).encoding.should == Encoding::US_ASCII
+ c.send(@method, 1, 3).encoding.should == Encoding::US_ASCII
+ c.send(@method, 8, 2).encoding.should == Encoding::US_ASCII
+ c.send(@method, 1, 10).encoding.should == Encoding::US_ASCII
+ end
+
it "returns nil if the offset falls outside of self" do
"hello there".send(@method, 20,3).should == nil
"hello there".send(@method, -20,3).should == nil
@@ -135,6 +154,11 @@ describe :string_slice_index_length, shared: true do
lambda { "hello".send(@method, nil, nil) }.should raise_error(TypeError)
end
+ it "raises a RangeError if the index or length is too big" do
+ lambda { "hello".send(@method, bignum_value, 1) }.should raise_error(RangeError)
+ lambda { "hello".send(@method, 0, bignum_value) }.should raise_error(RangeError)
+ end
+
it "returns subclass instances" do
s = StringSpecs::MyString.new("hello")
s.send(@method, 0,0).should be_an_instance_of(StringSpecs::MyString)
diff --git a/spec/rubyspec/core/string/unpack/l_spec.rb b/spec/rubyspec/core/string/unpack/l_spec.rb
index 3a7c55f8da..11f0648fc7 100644
--- a/spec/rubyspec/core/string/unpack/l_spec.rb
+++ b/spec/rubyspec/core/string/unpack/l_spec.rb
@@ -14,7 +14,7 @@ describe "String#unpack with format 'L'" do
it_behaves_like :string_unpack_32bit_be_unsigned, 'L>'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'L<_'
it_behaves_like :string_unpack_32bit_le, 'L_<'
@@ -44,65 +44,33 @@ describe "String#unpack with format 'L'" do
end
end
- platform_is wordsize: 64 do
- platform_is_not :mingw32 do
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_64bit_le, 'L<_'
- it_behaves_like :string_unpack_64bit_le, 'L_<'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'L<_'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'L_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_64bit_le, 'L<!'
- it_behaves_like :string_unpack_64bit_le, 'L!<'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'L<!'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'L!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_64bit_be, 'L>_'
- it_behaves_like :string_unpack_64bit_be, 'L_>'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'L>_'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'L_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_64bit_be, 'L>!'
- it_behaves_like :string_unpack_64bit_be, 'L!>'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'L>!'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'L!>'
- end
- end
-
- platform_is :mingw32 do
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_32bit_le, 'L<_'
- it_behaves_like :string_unpack_32bit_le, 'L_<'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'L<_'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'L_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_32bit_le, 'L<!'
- it_behaves_like :string_unpack_32bit_le, 'L!<'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'L<!'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'L!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_32bit_be, 'L>_'
- it_behaves_like :string_unpack_32bit_be, 'L_>'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'L>_'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'L_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_32bit_be, 'L>!'
- it_behaves_like :string_unpack_32bit_be, 'L!>'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'L>!'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'L!>'
- end
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'L<_'
+ it_behaves_like :string_unpack_64bit_le, 'L_<'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'L<_'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'L_<'
+ end
+
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'L<!'
+ it_behaves_like :string_unpack_64bit_le, 'L!<'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'L<!'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'L!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'L>_'
+ it_behaves_like :string_unpack_64bit_be, 'L_>'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'L>_'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'L_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'L>!'
+ it_behaves_like :string_unpack_64bit_be, 'L!>'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'L>!'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'L!>'
end
end
end
@@ -118,7 +86,7 @@ describe "String#unpack with format 'l'" do
it_behaves_like :string_unpack_32bit_be_signed, 'l>'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'l<_'
it_behaves_like :string_unpack_32bit_le, 'l_<'
@@ -148,65 +116,33 @@ describe "String#unpack with format 'l'" do
end
end
- platform_is wordsize: 64 do
- platform_is_not :mingw32 do
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_64bit_le, 'l<_'
- it_behaves_like :string_unpack_64bit_le, 'l_<'
- it_behaves_like :string_unpack_64bit_le_signed, 'l<_'
- it_behaves_like :string_unpack_64bit_le_signed, 'l_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_64bit_le, 'l<!'
- it_behaves_like :string_unpack_64bit_le, 'l!<'
- it_behaves_like :string_unpack_64bit_le_signed, 'l<!'
- it_behaves_like :string_unpack_64bit_le_signed, 'l!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_64bit_be, 'l>_'
- it_behaves_like :string_unpack_64bit_be, 'l_>'
- it_behaves_like :string_unpack_64bit_be_signed, 'l>_'
- it_behaves_like :string_unpack_64bit_be_signed, 'l_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_64bit_be, 'l>!'
- it_behaves_like :string_unpack_64bit_be, 'l!>'
- it_behaves_like :string_unpack_64bit_be_signed, 'l>!'
- it_behaves_like :string_unpack_64bit_be_signed, 'l!>'
- end
- end
-
- platform_is :mingw32 do
- describe "with modifier '<' and '_'" do
- it_behaves_like :string_unpack_32bit_le, 'l<_'
- it_behaves_like :string_unpack_32bit_le, 'l_<'
- it_behaves_like :string_unpack_32bit_le_signed, 'l<_'
- it_behaves_like :string_unpack_32bit_le_signed, 'l_<'
- end
-
- describe "with modifier '<' and '!'" do
- it_behaves_like :string_unpack_32bit_le, 'l<!'
- it_behaves_like :string_unpack_32bit_le, 'l!<'
- it_behaves_like :string_unpack_32bit_le_signed, 'l<!'
- it_behaves_like :string_unpack_32bit_le_signed, 'l!<'
- end
-
- describe "with modifier '>' and '_'" do
- it_behaves_like :string_unpack_32bit_be, 'l>_'
- it_behaves_like :string_unpack_32bit_be, 'l_>'
- it_behaves_like :string_unpack_32bit_be_signed, 'l>_'
- it_behaves_like :string_unpack_32bit_be_signed, 'l_>'
- end
-
- describe "with modifier '>' and '!'" do
- it_behaves_like :string_unpack_32bit_be, 'l>!'
- it_behaves_like :string_unpack_32bit_be, 'l!>'
- it_behaves_like :string_unpack_32bit_be_signed, 'l>!'
- it_behaves_like :string_unpack_32bit_be_signed, 'l!>'
- end
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
+ describe "with modifier '<' and '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'l<_'
+ it_behaves_like :string_unpack_64bit_le, 'l_<'
+ it_behaves_like :string_unpack_64bit_le_signed, 'l<_'
+ it_behaves_like :string_unpack_64bit_le_signed, 'l_<'
+ end
+
+ describe "with modifier '<' and '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'l<!'
+ it_behaves_like :string_unpack_64bit_le, 'l!<'
+ it_behaves_like :string_unpack_64bit_le_signed, 'l<!'
+ it_behaves_like :string_unpack_64bit_le_signed, 'l!<'
+ end
+
+ describe "with modifier '>' and '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'l>_'
+ it_behaves_like :string_unpack_64bit_be, 'l_>'
+ it_behaves_like :string_unpack_64bit_be_signed, 'l>_'
+ it_behaves_like :string_unpack_64bit_be_signed, 'l_>'
+ end
+
+ describe "with modifier '>' and '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'l>!'
+ it_behaves_like :string_unpack_64bit_be, 'l!>'
+ it_behaves_like :string_unpack_64bit_be_signed, 'l>!'
+ it_behaves_like :string_unpack_64bit_be_signed, 'l!>'
end
end
end
@@ -224,7 +160,7 @@ little_endian do
it_behaves_like :string_unpack_32bit_le_signed, 'l'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_32bit_le, 'L_'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L_'
@@ -246,49 +182,25 @@ little_endian do
end
end
- platform_is wordsize: 64 do
- platform_is_not :mingw32 do
- describe "String#unpack with format 'L' with modifier '_'" do
- it_behaves_like :string_unpack_64bit_le, 'L_'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'L_'
- end
-
- describe "String#unpack with format 'L' with modifier '!'" do
- it_behaves_like :string_unpack_64bit_le, 'L!'
- it_behaves_like :string_unpack_64bit_le_unsigned, 'L!'
- end
-
- describe "String#unpack with format 'l' with modifier '_'" do
- it_behaves_like :string_unpack_64bit_le, 'l_'
- it_behaves_like :string_unpack_64bit_le_signed, 'l_'
- end
-
- describe "String#unpack with format 'l' with modifier '!'" do
- it_behaves_like :string_unpack_64bit_le, 'l!'
- it_behaves_like :string_unpack_64bit_le_signed, 'l!'
- end
- end
-
- platform_is :mingw32 do
- describe "String#unpack with format 'L' with modifier '_'" do
- it_behaves_like :string_unpack_32bit_le, 'L_'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'L_'
- end
-
- describe "String#unpack with format 'L' with modifier '!'" do
- it_behaves_like :string_unpack_32bit_le, 'L!'
- it_behaves_like :string_unpack_32bit_le_unsigned, 'L!'
- end
-
- describe "String#unpack with format 'l' with modifier '_'" do
- it_behaves_like :string_unpack_32bit_le, 'l_'
- it_behaves_like :string_unpack_32bit_le_signed, 'l_'
- end
-
- describe "String#unpack with format 'l' with modifier '!'" do
- it_behaves_like :string_unpack_32bit_le, 'l!'
- it_behaves_like :string_unpack_32bit_le_signed, 'l!'
- end
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
+ describe "String#unpack with format 'L' with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'L_'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'L_'
+ end
+
+ describe "String#unpack with format 'L' with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'L!'
+ it_behaves_like :string_unpack_64bit_le_unsigned, 'L!'
+ end
+
+ describe "String#unpack with format 'l' with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_le, 'l_'
+ it_behaves_like :string_unpack_64bit_le_signed, 'l_'
+ end
+
+ describe "String#unpack with format 'l' with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_le, 'l!'
+ it_behaves_like :string_unpack_64bit_le_signed, 'l!'
end
end
end
@@ -306,7 +218,7 @@ big_endian do
it_behaves_like :string_unpack_32bit_be_signed, 'l'
end
- platform_is wordsize: 32 do
+ guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "String#unpack with format 'L' with modifier '_'" do
it_behaves_like :string_unpack_32bit_be, 'L_'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L_'
@@ -328,49 +240,26 @@ big_endian do
end
end
- platform_is wordsize: 64 do
- platform_is_not :mingw32 do
- describe "String#unpack with format 'L' with modifier '_'" do
- it_behaves_like :string_unpack_64bit_be, 'L_'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'L_'
- end
-
- describe "String#unpack with format 'L' with modifier '!'" do
- it_behaves_like :string_unpack_64bit_be, 'L!'
- it_behaves_like :string_unpack_64bit_be_unsigned, 'L!'
- end
-
- describe "String#unpack with format 'l' with modifier '_'" do
- it_behaves_like :string_unpack_64bit_be, 'l_'
- it_behaves_like :string_unpack_64bit_be_signed, 'l_'
- end
-
- describe "String#unpack with format 'l' with modifier '!'" do
- it_behaves_like :string_unpack_64bit_be, 'l!'
- it_behaves_like :string_unpack_64bit_be_signed, 'l!'
- end
- end
-
- platform_is :mingw32 do
- describe "String#unpack with format 'L' with modifier '_'" do
- it_behaves_like :string_unpack_32bit_be, 'L_'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'L_'
- end
-
- describe "String#unpack with format 'L' with modifier '!'" do
- it_behaves_like :string_unpack_32bit_be, 'L!'
- it_behaves_like :string_unpack_32bit_be_unsigned, 'L!'
- end
-
- describe "String#unpack with format 'l' with modifier '_'" do
- it_behaves_like :string_unpack_32bit_be, 'l_'
- it_behaves_like :string_unpack_32bit_be_signed, 'l_'
- end
-
- describe "String#unpack with format 'l' with modifier '!'" do
- it_behaves_like :string_unpack_32bit_be, 'l!'
- it_behaves_like :string_unpack_32bit_be_signed, 'l!'
- end
+ guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
+ describe "String#unpack with format 'L' with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'L_'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'L_'
+ end
+
+ describe "String#unpack with format 'L' with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'L!'
+ it_behaves_like :string_unpack_64bit_be_unsigned, 'L!'
+ end
+
+ describe "String#unpack with format 'l' with modifier '_'" do
+ it_behaves_like :string_unpack_64bit_be, 'l_'
+ it_behaves_like :string_unpack_64bit_be_signed, 'l_'
+ end
+
+ describe "String#unpack with format 'l' with modifier '!'" do
+ it_behaves_like :string_unpack_64bit_be, 'l!'
+ it_behaves_like :string_unpack_64bit_be_signed, 'l!'
end
end
+
end
diff --git a/spec/rubyspec/core/thread/fixtures/classes.rb b/spec/rubyspec/core/thread/fixtures/classes.rb
index 7f7bb69a61..b572c8dd82 100644
--- a/spec/rubyspec/core/thread/fixtures/classes.rb
+++ b/spec/rubyspec/core/thread/fixtures/classes.rb
@@ -111,9 +111,6 @@ module ThreadSpecs
status
end
- def self.status_of_aborting_thread
- end
-
def self.status_of_killed_thread
t = Thread.new { sleep }
Thread.pass while t.status and t.status != 'sleep'
@@ -147,6 +144,19 @@ module ThreadSpecs
status
end
+ def self.status_of_dying_thread_after_sleep
+ status = nil
+ t = dying_thread_ensures {
+ Thread.stop
+ status = Status.new(Thread.current)
+ }
+ Thread.pass while t.status and t.status != 'sleep'
+ t.wakeup
+ Thread.pass while t.status and t.status == 'sleep'
+ t.join
+ status
+ end
+
def self.dying_thread_ensures(kill_method_name=:kill)
Thread.new do
begin
diff --git a/spec/rubyspec/core/thread/inspect_spec.rb b/spec/rubyspec/core/thread/inspect_spec.rb
index 759f6e756c..95e598eb6a 100644
--- a/spec/rubyspec/core/thread/inspect_spec.rb
+++ b/spec/rubyspec/core/thread/inspect_spec.rb
@@ -31,12 +31,14 @@ describe "Thread#inspect" do
end
it "describes a dying sleeping thread" do
- ThreadSpecs.status_of_dying_sleeping_thread.status.should include('sleep')
+ ThreadSpecs.status_of_dying_sleeping_thread.inspect.should include('sleep')
end
- quarantine! do
it "reports aborting on a killed thread" do
- ThreadSpecs.status_of_aborting_thread.inspect.should include('aborting')
+ ThreadSpecs.status_of_dying_running_thread.inspect.should include('aborting')
end
+
+ it "reports aborting on a killed thread after sleep" do
+ ThreadSpecs.status_of_dying_thread_after_sleep.inspect.should include('aborting')
end
end
diff --git a/spec/rubyspec/core/thread/status_spec.rb b/spec/rubyspec/core/thread/status_spec.rb
index 00d7a03ab8..3fbc4f888a 100644
--- a/spec/rubyspec/core/thread/status_spec.rb
+++ b/spec/rubyspec/core/thread/status_spec.rb
@@ -34,9 +34,11 @@ describe "Thread#status" do
ThreadSpecs.status_of_dying_sleeping_thread.status.should == 'sleep'
end
- quarantine! do
it "reports aborting on a killed thread" do
- ThreadSpecs.status_of_aborting_thread.status.should == 'aborting'
+ ThreadSpecs.status_of_dying_running_thread.status.should == 'aborting'
end
+
+ it "reports aborting on a killed thread after sleep" do
+ ThreadSpecs.status_of_dying_thread_after_sleep.status.should == 'aborting'
end
end
diff --git a/spec/rubyspec/core/thread/stop_spec.rb b/spec/rubyspec/core/thread/stop_spec.rb
index 79be623906..0bc99487fd 100644
--- a/spec/rubyspec/core/thread/stop_spec.rb
+++ b/spec/rubyspec/core/thread/stop_spec.rb
@@ -48,9 +48,7 @@ describe "Thread#stop?" do
ThreadSpecs.status_of_dying_sleeping_thread.stop?.should == true
end
- quarantine! do
- it "reports aborting on a killed thread" do
- ThreadSpecs.status_of_aborting_thread.stop?.should == false
- end
+ it "describes a dying thread after sleep" do
+ ThreadSpecs.status_of_dying_thread_after_sleep.stop?.should == false
end
end