From 0cb5fa5877f7b00d1396e0dda4156e8213d37215 Mon Sep 17 00:00:00 2001 From: eregon Date: Thu, 27 Jul 2017 12:10:41 +0000 Subject: Update to ruby/spec@c3e6b90 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/rubyspec/Gemfile | 2 +- spec/rubyspec/core/array/pack/j_spec.rb | 4 +- spec/rubyspec/core/array/pack/l_spec.rb | 216 +++++---------- spec/rubyspec/core/io/close_on_exec_spec.rb | 137 ++++----- spec/rubyspec/core/numeric/step_spec.rb | 14 +- spec/rubyspec/core/process/setrlimit_spec.rb | 20 +- spec/rubyspec/core/string/shared/slice.rb | 24 ++ spec/rubyspec/core/string/unpack/l_spec.rb | 305 +++++++-------------- spec/rubyspec/core/thread/fixtures/classes.rb | 16 +- spec/rubyspec/core/thread/inspect_spec.rb | 8 +- spec/rubyspec/core/thread/status_spec.rb | 6 +- spec/rubyspec/core/thread/stop_spec.rb | 6 +- spec/rubyspec/language/break_spec.rb | 18 +- spec/rubyspec/language/fixtures/break.rb | 4 +- spec/rubyspec/language/fixtures/defined.rb | 4 +- spec/rubyspec/library/bigdecimal/to_r_spec.rb | 16 ++ spec/rubyspec/library/stringscanner/shared/peek.rb | 5 +- spec/rubyspec/optional/capi/ext/io_spec.c | 23 +- spec/rubyspec/optional/capi/globals_spec.rb | 4 +- spec/rubyspec/optional/capi/object_spec.rb | 2 +- spec/rubyspec/optional/capi/thread_spec.rb | 4 + 21 files changed, 353 insertions(+), 485 deletions(-) create mode 100644 spec/rubyspec/library/bigdecimal/to_r_spec.rb (limited to 'spec') diff --git a/spec/rubyspec/Gemfile b/spec/rubyspec/Gemfile index c9e44987cd..28793d427f 100644 --- a/spec/rubyspec/Gemfile +++ b/spec/rubyspec/Gemfile @@ -1,3 +1,3 @@ source 'https://rubygems.org' -gem 'mspec', :github => 'ruby/mspec' +gem 'mspec', :git => 'https://github.com/ruby/mspec' 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' 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' 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' 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' 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' 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' 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' 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' 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' 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' 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' 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' 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 diff --git a/spec/rubyspec/language/break_spec.rb b/spec/rubyspec/language/break_spec.rb index 4758e6ce50..794eed2dd9 100644 --- a/spec/rubyspec/language/break_spec.rb +++ b/spec/rubyspec/language/break_spec.rb @@ -40,12 +40,12 @@ describe "The break statement in a captured block" do it "raises a LocalJumpError when invoking the block from a method" do lambda { @program.break_in_nested_method }.should raise_error(LocalJumpError) - ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b] + ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b] end it "raises a LocalJumpError when yielding to the block" do lambda { @program.break_in_yielding_method }.should raise_error(LocalJumpError) - ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b] + ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b] end end @@ -60,6 +60,20 @@ describe "The break statement in a captured block" do ScratchPad.recorded.should == [:a, :za, :xa, :zd, :aa, :zb] end end + + describe "from another thread" do + it "raises a LocalJumpError when getting the value from another thread" do + ScratchPad << :a + thread_with_break = Thread.new do + ScratchPad << :b + break :break + ScratchPad << :c + end + + lambda { thread_with_break.value }.should raise_error(LocalJumpError) + ScratchPad.recorded.should == [:a, :b] + end + end end describe "The break statement in a lambda" do diff --git a/spec/rubyspec/language/fixtures/break.rb b/spec/rubyspec/language/fixtures/break.rb index 165d3395c3..50e7fcf5d9 100644 --- a/spec/rubyspec/language/fixtures/break.rb +++ b/spec/rubyspec/language/fixtures/break.rb @@ -89,7 +89,7 @@ module BreakSpecs break :break note :c } - note :c + note :cc note call_method(b) note :d end @@ -101,7 +101,7 @@ module BreakSpecs break :break note :c } - note :c + note :cc note yielding(&b) note :d end diff --git a/spec/rubyspec/language/fixtures/defined.rb b/spec/rubyspec/language/fixtures/defined.rb index ce330b486e..d26e553c4b 100644 --- a/spec/rubyspec/language/fixtures/defined.rb +++ b/spec/rubyspec/language/fixtures/defined.rb @@ -83,7 +83,9 @@ module DefinedSpecs end def global_variable_read - value = $defined_specs_global_variable_read + suppress_warning do + value = $defined_specs_global_variable_read + end defined? $defined_specs_global_variable_read end diff --git a/spec/rubyspec/library/bigdecimal/to_r_spec.rb b/spec/rubyspec/library/bigdecimal/to_r_spec.rb new file mode 100644 index 0000000000..6f6e5a1bea --- /dev/null +++ b/spec/rubyspec/library/bigdecimal/to_r_spec.rb @@ -0,0 +1,16 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'bigdecimal' + +describe "BigDecimal#to_r" do + + it "returns a Rational" do + BigDecimal("3.14159").to_r.should be_kind_of(Rational) + end + + it "returns a Rational with bignum values" do + r = BigDecimal.new("3.141592653589793238462643").to_r + r.numerator.should eql(3141592653589793238462643) + r.denominator.should eql(1000000000000000000000000) + end + +end diff --git a/spec/rubyspec/library/stringscanner/shared/peek.rb b/spec/rubyspec/library/stringscanner/shared/peek.rb index f414cc3b40..418ebb6536 100644 --- a/spec/rubyspec/library/stringscanner/shared/peek.rb +++ b/spec/rubyspec/library/stringscanner/shared/peek.rb @@ -3,12 +3,15 @@ describe :strscan_peek, shared: true do @s = StringScanner.new('This is a test') end - it "returns at most the specified number of characters from the current position" do + it "returns at most the specified number of bytes from the current position" do @s.send(@method, 4).should == "This" @s.pos.should == 0 @s.pos = 5 @s.send(@method, 2).should == "is" @s.send(@method, 1000).should == "is a test" + + s = StringScanner.new("été") + s.send(@method, 2).should == "é" end it "returns an empty string when the passed argument is zero" do diff --git a/spec/rubyspec/optional/capi/ext/io_spec.c b/spec/rubyspec/optional/capi/ext/io_spec.c index 751cb33fd8..9eb733b1e0 100644 --- a/spec/rubyspec/optional/capi/ext/io_spec.c +++ b/spec/rubyspec/optional/capi/ext/io_spec.c @@ -1,6 +1,7 @@ #include "ruby.h" #include "rubyspec.h" #include "ruby/io.h" +#include #include #ifdef HAVE_UNISTD_H #include @@ -133,46 +134,46 @@ VALUE io_spec_rb_io_taint_check(VALUE self, VALUE io) { } #endif -typedef int wait_bool; -#define wait_bool_to_ruby_bool(x) (x ? Qtrue : Qfalse) - #ifdef HAVE_RB_IO_WAIT_READABLE #define RB_IO_WAIT_READABLE_BUF 13 VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) { int fd = io_spec_get_fd(io); char buf[RB_IO_WAIT_READABLE_BUF]; - wait_bool ret; + int ret, r, saved_errno; if (set_non_blocking(fd) == -1) rb_sys_fail("set_non_blocking failed"); if(RTEST(read_p)) { - if(read(fd, buf, RB_IO_WAIT_READABLE_BUF) != -1) { + if (read(fd, buf, RB_IO_WAIT_READABLE_BUF) != -1) { return Qnil; } + saved_errno = errno; rb_ivar_set(self, rb_intern("@write_data"), Qtrue); + errno = saved_errno; } ret = rb_io_wait_readable(fd); if(RTEST(read_p)) { - if(read(fd, buf, RB_IO_WAIT_READABLE_BUF) != 13) { - return Qnil; + r = read(fd, buf, RB_IO_WAIT_READABLE_BUF); + if (r != RB_IO_WAIT_READABLE_BUF) { + perror("read"); + return INT2FIX(r); } rb_ivar_set(self, rb_intern("@read_data"), rb_str_new(buf, RB_IO_WAIT_READABLE_BUF)); } - return wait_bool_to_ruby_bool(ret); + return ret ? Qtrue : Qfalse; } #endif #ifdef HAVE_RB_IO_WAIT_WRITABLE VALUE io_spec_rb_io_wait_writable(VALUE self, VALUE io) { - wait_bool ret; - ret = rb_io_wait_writable(io_spec_get_fd(io)); - return wait_bool_to_ruby_bool(ret); + int ret = rb_io_wait_writable(io_spec_get_fd(io)); + return ret ? Qtrue : Qfalse; } #endif diff --git a/spec/rubyspec/optional/capi/globals_spec.rb b/spec/rubyspec/optional/capi/globals_spec.rb index 2e748e78ac..c6e2ed912b 100644 --- a/spec/rubyspec/optional/capi/globals_spec.rb +++ b/spec/rubyspec/optional/capi/globals_spec.rb @@ -188,7 +188,7 @@ describe "CApiGlobalSpecs" do running = true end - Thread.pass until running + Thread.pass while thr.status and !running $_.should be_nil thr.join @@ -215,7 +215,7 @@ describe "CApiGlobalSpecs" do running = true end - Thread.pass until running + Thread.pass while thr.status and !running $_.should be_nil thr.join diff --git a/spec/rubyspec/optional/capi/object_spec.rb b/spec/rubyspec/optional/capi/object_spec.rb index 41224d0de3..b16d26ce47 100644 --- a/spec/rubyspec/optional/capi/object_spec.rb +++ b/spec/rubyspec/optional/capi/object_spec.rb @@ -175,6 +175,7 @@ describe "CApiObject" do describe "rb_require" do before :each do @saved_loaded_features = $LOADED_FEATURES.dup + $foo = nil end after :each do @@ -183,7 +184,6 @@ describe "CApiObject" do end it "requires a ruby file" do - $foo.should == nil $:.unshift File.dirname(__FILE__) @o.rb_require() $foo.should == 7 diff --git a/spec/rubyspec/optional/capi/thread_spec.rb b/spec/rubyspec/optional/capi/thread_spec.rb index fbce8016a2..0ca701e35d 100644 --- a/spec/rubyspec/optional/capi/thread_spec.rb +++ b/spec/rubyspec/optional/capi/thread_spec.rb @@ -107,6 +107,10 @@ describe "C-API Thread function" do # Wait until it's blocking... Thread.pass while thr.status and thr.status != "sleep" + # The thread status is set to sleep by rb_thread_call_without_gvl(), + # but the thread might not be in the blocking read(2) yet, so wait a bit. + sleep 0.1 + # Wake it up, causing the unblock function to be run. thr.wakeup -- cgit v1.2.3