1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-07-27 12:10:41 +00:00
parent 819977e410
commit 0cb5fa5877
21 changed files with 329 additions and 461 deletions

View file

@ -1,3 +1,3 @@
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'mspec', :github => 'ruby/mspec' gem 'mspec', :git => 'https://github.com/ruby/mspec'

View file

@ -8,7 +8,7 @@ ruby_version_is '2.3' do
# To handle the special case of x64-mingw32 # To handle the special case of x64-mingw32
pointer_size = RUBY_PLATFORM =~ /\bx64\b/ ? 64 : 1.size * 8 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 describe "Array#pack with format 'J'" do
it_behaves_like :array_pack_basic, 'J' it_behaves_like :array_pack_basic, 'J'
it_behaves_like :array_pack_basic_non_float, 'J' it_behaves_like :array_pack_basic_non_float, 'J'
@ -114,7 +114,7 @@ ruby_version_is '2.3' do
end end
end end
if pointer_size == 32 then guard -> { pointer_size == 32 } do
describe "Array#pack with format 'J'" do describe "Array#pack with format 'J'" do
it_behaves_like :array_pack_basic, 'J' it_behaves_like :array_pack_basic, 'J'
it_behaves_like :array_pack_basic_non_float, 'J' it_behaves_like :array_pack_basic_non_float, 'J'

View file

@ -29,7 +29,7 @@ describe "Array#pack with format 'L'" do
it_behaves_like :array_pack_32bit_be, 'L>' it_behaves_like :array_pack_32bit_be, 'L>'
end end
platform_is wordsize: 32 do guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_32bit_le, 'L<_' it_behaves_like :array_pack_32bit_le, 'L<_'
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
end end
platform_is wordsize: 64 do guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
platform_is_not :mingw32 do describe "with modifier '<' and '_'" do
describe "with modifier '<' and '_'" do it_behaves_like :array_pack_64bit_le, 'L<_'
it_behaves_like :array_pack_64bit_le, 'L<_' 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
platform_is :mingw32 do describe "with modifier '<' and '!'" do
describe "with modifier '<' and '_'" do it_behaves_like :array_pack_64bit_le, 'L<!'
it_behaves_like :array_pack_32bit_le, 'L<_' it_behaves_like :array_pack_64bit_le, 'L!<'
it_behaves_like :array_pack_32bit_le, 'L_<' end
end
describe "with modifier '<' and '!'" do describe "with modifier '>' and '_'" do
it_behaves_like :array_pack_32bit_le, 'L<!' it_behaves_like :array_pack_64bit_be, 'L>_'
it_behaves_like :array_pack_32bit_le, 'L!<' it_behaves_like :array_pack_64bit_be, 'L_>'
end end
describe "with modifier '>' and '_'" do describe "with modifier '>' and '!'" do
it_behaves_like :array_pack_32bit_be, 'L>_' it_behaves_like :array_pack_64bit_be, 'L>!'
it_behaves_like :array_pack_32bit_be, 'L_>' it_behaves_like :array_pack_64bit_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
end end
end end
end end
@ -107,7 +83,7 @@ describe "Array#pack with format 'l'" do
it_behaves_like :array_pack_32bit_be, 'l>' it_behaves_like :array_pack_32bit_be, 'l>'
end end
platform_is wordsize: 32 do guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" do describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_32bit_le, 'l<_' it_behaves_like :array_pack_32bit_le, 'l<_'
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
end end
platform_is wordsize: 64 do guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
platform_is_not :mingw32 do describe "with modifier '<' and '_'" do
describe "with modifier '<' and '_'" do it_behaves_like :array_pack_64bit_le, 'l<_'
it_behaves_like :array_pack_64bit_le, 'l<_' 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
platform_is :mingw32 do describe "with modifier '<' and '!'" do
describe "with modifier '<' and '_'" do it_behaves_like :array_pack_64bit_le, 'l<!'
it_behaves_like :array_pack_32bit_le, 'l<_' it_behaves_like :array_pack_64bit_le, 'l!<'
it_behaves_like :array_pack_32bit_le, 'l_<' end
end
describe "with modifier '<' and '!'" do describe "with modifier '>' and '_'" do
it_behaves_like :array_pack_32bit_le, 'l<!' it_behaves_like :array_pack_64bit_be, 'l>_'
it_behaves_like :array_pack_32bit_le, 'l!<' it_behaves_like :array_pack_64bit_be, 'l_>'
end end
describe "with modifier '>' and '_'" do describe "with modifier '>' and '!'" do
it_behaves_like :array_pack_32bit_be, 'l>_' it_behaves_like :array_pack_64bit_be, 'l>!'
it_behaves_like :array_pack_32bit_be, 'l_>' it_behaves_like :array_pack_64bit_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
end end
end end
end end
@ -185,7 +137,7 @@ little_endian do
it_behaves_like :array_pack_32bit_le, 'l' it_behaves_like :array_pack_32bit_le, 'l'
end 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 describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_32bit_le, 'L_' it_behaves_like :array_pack_32bit_le, 'L_'
end end
@ -203,41 +155,21 @@ little_endian do
end end
end end
platform_is wordsize: 64 do guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
platform_is_not :mingw32 do describe "Array#pack with format 'L' with modifier '_'" do
describe "Array#pack with format 'L' with modifier '_'" do it_behaves_like :array_pack_64bit_le, 'L_'
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
end end
platform_is :mingw32 do describe "Array#pack with format 'L' with modifier '!'" do
describe "Array#pack with format 'L' with modifier '_'" do it_behaves_like :array_pack_64bit_le, 'L!'
it_behaves_like :array_pack_32bit_le, 'L_' end
end
describe "Array#pack with format 'L' with modifier '!'" do describe "Array#pack with format 'l' with modifier '_'" do
it_behaves_like :array_pack_32bit_le, 'L!' it_behaves_like :array_pack_64bit_le, 'l_'
end end
describe "Array#pack with format 'l' with modifier '_'" do describe "Array#pack with format 'l' with modifier '!'" do
it_behaves_like :array_pack_32bit_le, 'l_' 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
end end
end end
end end
@ -251,7 +183,7 @@ big_endian do
it_behaves_like :array_pack_32bit_be, 'l' it_behaves_like :array_pack_32bit_be, 'l'
end 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 describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_32bit_be, 'L_' it_behaves_like :array_pack_32bit_be, 'L_'
end end
@ -269,41 +201,21 @@ big_endian do
end end
end end
platform_is wordsize: 64 do guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
platform_is_not :mingw32 do describe "Array#pack with format 'L' with modifier '_'" do
describe "Array#pack with format 'L' with modifier '_'" do it_behaves_like :array_pack_64bit_be, 'L_'
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
end end
platform_is :mingw32 do describe "Array#pack with format 'L' with modifier '!'" do
describe "Array#pack with format 'L' with modifier '_'" do it_behaves_like :array_pack_64bit_be, 'L!'
it_behaves_like :array_pack_32bit_be, 'L_' end
end
describe "Array#pack with format 'L' with modifier '!'" do describe "Array#pack with format 'l' with modifier '_'" do
it_behaves_like :array_pack_32bit_be, 'L!' it_behaves_like :array_pack_64bit_be, 'l_'
end end
describe "Array#pack with format 'l' with modifier '_'" do describe "Array#pack with format 'l' with modifier '!'" do
it_behaves_like :array_pack_32bit_be, 'l_' 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
end end
end end
end end

View file

@ -1,44 +1,5 @@
require File.expand_path('../../../spec_helper', __FILE__) 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 describe "IO#close_on_exec=" do
before :each do before :each do
@name = tmp('io_close_on_exec.txt') @name = tmp('io_close_on_exec.txt')
@ -50,47 +11,59 @@ describe "IO#close_on_exec=" do
rm_r @name rm_r @name
end end
platform_is :windows do guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
ruby_version_is ""..."2.3" do it "returns false from #respond_to?" do
it "returns false from #respond_to?" do @io.respond_to?(:close_on_exec=).should be_false
@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
end end
ruby_version_is "2.3" do it "raises a NotImplementedError when called" do
it_should_behave_like :io_close_on_exec lambda { @io.close_on_exec = true }.should raise_error(NotImplementedError)
end end
end end
platform_is_not :windows do guard -> { platform_is_not :windows or ruby_version_is "2.3" } do
it_should_behave_like :io_close_on_exec it "sets the close-on-exec flag if true" do
end @io.close_on_exec = true
end @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 "unsets the close-on-exec flag if false" do
it "returns true by default" do @io.close_on_exec = true
@io.close_on_exec?.should == true @io.close_on_exec = false
end @io.close_on_exec?.should == false
end
it "returns true if set" do it "unsets the close-on-exec flag if nil" do
@io.close_on_exec = true @io.close_on_exec = true
@io.close_on_exec?.should == true @io.close_on_exec = nil
end @io.close_on_exec?.should == false
end
it "raises IOError if called on a closed IO" do it "ensures the IO's file descriptor is closed in exec'ed processes" do
@io.close require 'fcntl'
lambda { @io.close_on_exec? }.should raise_error(IOError) @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 end
end end
describe "IO#close_on_exec?" do describe "IO#close_on_exec?" do
before :each do before :each do
@name = tmp('io_close_on_exec.txt') @name = tmp('io_is_close_on_exec.txt')
@io = new_io @name @io = new_io @name
end end
@ -99,23 +72,29 @@ describe "IO#close_on_exec?" do
rm_r @name rm_r @name
end end
platform_is :windows do guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
ruby_version_is ""..."2.3" do it "returns false from #respond_to?" do
it "returns false from #respond_to?" do @io.respond_to?(:close_on_exec?).should be_false
@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
end end
ruby_version_is "2.3" do it "raises a NotImplementedError when called" do
it_should_behave_like :io_close_on_exec lambda { @io.close_on_exec? }.should raise_error(NotImplementedError)
end end
end end
platform_is_not :windows do guard -> { platform_is_not :windows or ruby_version_is "2.3" } do
it_should_behave_like :io_is_close_on_exec 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
end end

View file

@ -65,6 +65,10 @@ describe "Numeric#step" do
describe "when no block is given" do describe "when no block is given" do
describe "returned Enumerator" do describe "returned Enumerator" do
describe "size" 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 it "should return infinity_value when step is 0" do
1.step(to: 5, by: 0).size.should == infinity_value 1.step(to: 5, by: 0).size.should == infinity_value
end end
@ -73,13 +77,21 @@ describe "Numeric#step" do
1.step(to: 2, by: 0.0).size.should == infinity_value 1.step(to: 2, by: 0.0).size.should == infinity_value
end 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 1.step(to: Float::INFINITY, by: 42).size.should == infinity_value
end 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 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 1.step(to: Float::INFINITY, by: Float::INFINITY).size.should == 1
end 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 end
end end

View file

@ -73,13 +73,13 @@ platform_is_not :windows do
Process.setrlimit(:STACK, *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil Process.setrlimit(:STACK, *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil
end end
platform_is_not :solaris do platform_is_not :solaris, :aix do
platform_is_not :aix do it "coerces :MEMLOCK into RLIMIT_MEMLOCK" do
it "coerces :MEMLOCK into RLIMIT_MEMLOCK" do Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
end
end end
end
platform_is_not :solaris do
it "coerces :NPROC into RLIMIT_NPROC" do it "coerces :NPROC into RLIMIT_NPROC" do
Process.setrlimit(:NPROC, *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil Process.setrlimit(:NPROC, *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil
end end
@ -155,13 +155,13 @@ platform_is_not :windows do
Process.setrlimit("STACK", *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil Process.setrlimit("STACK", *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil
end end
platform_is_not :solaris do platform_is_not :solaris, :aix do
platform_is_not :aix do it "coerces 'MEMLOCK' into RLIMIT_MEMLOCK" do
it "coerces 'MEMLOCK' into RLIMIT_MEMLOCK" do Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
end
end end
end
platform_is_not :solaris do
it "coerces 'NPROC' into RLIMIT_NPROC" do it "coerces 'NPROC' into RLIMIT_NPROC" do
Process.setrlimit("NPROC", *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil Process.setrlimit("NPROC", *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil
end end

View file

@ -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)
lambda { "hello".send(@method, []) }.should raise_error(TypeError) lambda { "hello".send(@method, []) }.should raise_error(TypeError)
end end
it "raises a RangeError if the index is too big" do
lambda { "hello".send(@method, bignum_value) }.should raise_error(RangeError)
end
end end
describe :string_slice_index_length, shared: true do 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 str.send(@method, 2,1).tainted?.should == true
end 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 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
"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) lambda { "hello".send(@method, nil, nil) }.should raise_error(TypeError)
end 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 it "returns subclass instances" do
s = StringSpecs::MyString.new("hello") s = StringSpecs::MyString.new("hello")
s.send(@method, 0,0).should be_an_instance_of(StringSpecs::MyString) s.send(@method, 0,0).should be_an_instance_of(StringSpecs::MyString)

View file

@ -14,7 +14,7 @@ describe "String#unpack with format 'L'" do
it_behaves_like :string_unpack_32bit_be_unsigned, 'L>' it_behaves_like :string_unpack_32bit_be_unsigned, 'L>'
end end
platform_is wordsize: 32 do guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" 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, 'L_<' it_behaves_like :string_unpack_32bit_le, 'L_<'
@ -44,65 +44,33 @@ describe "String#unpack with format 'L'" do
end end
end end
platform_is wordsize: 64 do guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
platform_is_not :mingw32 do describe "with modifier '<' and '_'" 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, '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<_' 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
platform_is :mingw32 do describe "with modifier '<' and '!'" do
describe "with modifier '<' and '_'" do it_behaves_like :string_unpack_64bit_le, 'L<!'
it_behaves_like :string_unpack_32bit_le, 'L<_' it_behaves_like :string_unpack_64bit_le, 'L!<'
it_behaves_like :string_unpack_32bit_le, 'L_<' it_behaves_like :string_unpack_64bit_le_unsigned, 'L<!'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L<_' it_behaves_like :string_unpack_64bit_le_unsigned, 'L!<'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L_<' end
end
describe "with modifier '<' and '!'" do describe "with modifier '>' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'L<!' it_behaves_like :string_unpack_64bit_be, 'L>_'
it_behaves_like :string_unpack_32bit_le, 'L!<' it_behaves_like :string_unpack_64bit_be, 'L_>'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L<!' it_behaves_like :string_unpack_64bit_be_unsigned, 'L>_'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L!<' it_behaves_like :string_unpack_64bit_be_unsigned, 'L_>'
end end
describe "with modifier '>' and '_'" do describe "with modifier '>' and '!'" do
it_behaves_like :string_unpack_32bit_be, 'L>_' it_behaves_like :string_unpack_64bit_be, 'L>!'
it_behaves_like :string_unpack_32bit_be, 'L_>' it_behaves_like :string_unpack_64bit_be, 'L!>'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L>_' it_behaves_like :string_unpack_64bit_be_unsigned, 'L>!'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L_>' it_behaves_like :string_unpack_64bit_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
end end
end end
end end
@ -118,7 +86,7 @@ describe "String#unpack with format 'l'" do
it_behaves_like :string_unpack_32bit_be_signed, 'l>' it_behaves_like :string_unpack_32bit_be_signed, 'l>'
end end
platform_is wordsize: 32 do guard -> { platform_is wordsize: 32 or platform_is :mingw32 } do
describe "with modifier '<' and '_'" 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, 'l_<' it_behaves_like :string_unpack_32bit_le, 'l_<'
@ -148,65 +116,33 @@ describe "String#unpack with format 'l'" do
end end
end end
platform_is wordsize: 64 do guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
platform_is_not :mingw32 do describe "with modifier '<' and '_'" 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, '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<_' 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
platform_is :mingw32 do describe "with modifier '<' and '!'" do
describe "with modifier '<' and '_'" do it_behaves_like :string_unpack_64bit_le, 'l<!'
it_behaves_like :string_unpack_32bit_le, 'l<_' it_behaves_like :string_unpack_64bit_le, 'l!<'
it_behaves_like :string_unpack_32bit_le, 'l_<' it_behaves_like :string_unpack_64bit_le_signed, 'l<!'
it_behaves_like :string_unpack_32bit_le_signed, 'l<_' it_behaves_like :string_unpack_64bit_le_signed, 'l!<'
it_behaves_like :string_unpack_32bit_le_signed, 'l_<' end
end
describe "with modifier '<' and '!'" do describe "with modifier '>' and '_'" do
it_behaves_like :string_unpack_32bit_le, 'l<!' it_behaves_like :string_unpack_64bit_be, 'l>_'
it_behaves_like :string_unpack_32bit_le, 'l!<' it_behaves_like :string_unpack_64bit_be, 'l_>'
it_behaves_like :string_unpack_32bit_le_signed, 'l<!' it_behaves_like :string_unpack_64bit_be_signed, 'l>_'
it_behaves_like :string_unpack_32bit_le_signed, 'l!<' it_behaves_like :string_unpack_64bit_be_signed, 'l_>'
end end
describe "with modifier '>' and '_'" do describe "with modifier '>' and '!'" do
it_behaves_like :string_unpack_32bit_be, 'l>_' it_behaves_like :string_unpack_64bit_be, 'l>!'
it_behaves_like :string_unpack_32bit_be, 'l_>' it_behaves_like :string_unpack_64bit_be, 'l!>'
it_behaves_like :string_unpack_32bit_be_signed, 'l>_' it_behaves_like :string_unpack_64bit_be_signed, 'l>!'
it_behaves_like :string_unpack_32bit_be_signed, 'l_>' it_behaves_like :string_unpack_64bit_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
end end
end end
end end
@ -224,7 +160,7 @@ little_endian do
it_behaves_like :string_unpack_32bit_le_signed, 'l' it_behaves_like :string_unpack_32bit_le_signed, 'l'
end 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 describe "String#unpack with format 'L' with modifier '_'" 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_'
@ -246,49 +182,25 @@ little_endian do
end end
end end
platform_is wordsize: 64 do guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
platform_is_not :mingw32 do describe "String#unpack with format 'L' with modifier '_'" 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, 'L_' it_behaves_like :string_unpack_64bit_le_unsigned, '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
platform_is :mingw32 do describe "String#unpack with format 'L' with modifier '!'" do
describe "String#unpack with format 'L' with modifier '_'" do it_behaves_like :string_unpack_64bit_le, 'L!'
it_behaves_like :string_unpack_32bit_le, 'L_' it_behaves_like :string_unpack_64bit_le_unsigned, 'L!'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L_' end
end
describe "String#unpack with format 'L' with modifier '!'" do describe "String#unpack with format 'l' with modifier '_'" do
it_behaves_like :string_unpack_32bit_le, 'L!' it_behaves_like :string_unpack_64bit_le, 'l_'
it_behaves_like :string_unpack_32bit_le_unsigned, 'L!' it_behaves_like :string_unpack_64bit_le_signed, 'l_'
end end
describe "String#unpack with format 'l' with modifier '_'" do describe "String#unpack with format 'l' with modifier '!'" do
it_behaves_like :string_unpack_32bit_le, 'l_' it_behaves_like :string_unpack_64bit_le, 'l!'
it_behaves_like :string_unpack_32bit_le_signed, '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_32bit_le, 'l!'
it_behaves_like :string_unpack_32bit_le_signed, 'l!'
end
end end
end end
end end
@ -306,7 +218,7 @@ big_endian do
it_behaves_like :string_unpack_32bit_be_signed, 'l' it_behaves_like :string_unpack_32bit_be_signed, 'l'
end 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 describe "String#unpack with format 'L' with modifier '_'" 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_'
@ -328,49 +240,26 @@ big_endian do
end end
end end
platform_is wordsize: 64 do guard -> { platform_is wordsize: 64 and platform_is_not :mingw32 } do
platform_is_not :mingw32 do describe "String#unpack with format 'L' with modifier '_'" 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, 'L_' it_behaves_like :string_unpack_64bit_be_unsigned, '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
platform_is :mingw32 do describe "String#unpack with format 'L' with modifier '!'" do
describe "String#unpack with format 'L' with modifier '_'" do it_behaves_like :string_unpack_64bit_be, 'L!'
it_behaves_like :string_unpack_32bit_be, 'L_' it_behaves_like :string_unpack_64bit_be_unsigned, 'L!'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L_' end
end
describe "String#unpack with format 'L' with modifier '!'" do describe "String#unpack with format 'l' with modifier '_'" do
it_behaves_like :string_unpack_32bit_be, 'L!' it_behaves_like :string_unpack_64bit_be, 'l_'
it_behaves_like :string_unpack_32bit_be_unsigned, 'L!' it_behaves_like :string_unpack_64bit_be_signed, 'l_'
end end
describe "String#unpack with format 'l' with modifier '_'" do describe "String#unpack with format 'l' with modifier '!'" do
it_behaves_like :string_unpack_32bit_be, 'l_' it_behaves_like :string_unpack_64bit_be, 'l!'
it_behaves_like :string_unpack_32bit_be_signed, '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_32bit_be, 'l!'
it_behaves_like :string_unpack_32bit_be_signed, 'l!'
end
end end
end end
end end

View file

@ -111,9 +111,6 @@ module ThreadSpecs
status status
end end
def self.status_of_aborting_thread
end
def self.status_of_killed_thread def self.status_of_killed_thread
t = Thread.new { sleep } t = Thread.new { sleep }
Thread.pass while t.status and t.status != 'sleep' Thread.pass while t.status and t.status != 'sleep'
@ -147,6 +144,19 @@ module ThreadSpecs
status status
end 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) def self.dying_thread_ensures(kill_method_name=:kill)
Thread.new do Thread.new do
begin begin

View file

@ -31,12 +31,14 @@ describe "Thread#inspect" do
end end
it "describes a dying sleeping thread" do 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 end
quarantine! do
it "reports aborting on a killed thread" 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 end
it "reports aborting on a killed thread after sleep" do
ThreadSpecs.status_of_dying_thread_after_sleep.inspect.should include('aborting')
end end
end end

View file

@ -34,9 +34,11 @@ describe "Thread#status" do
ThreadSpecs.status_of_dying_sleeping_thread.status.should == 'sleep' ThreadSpecs.status_of_dying_sleeping_thread.status.should == 'sleep'
end end
quarantine! do
it "reports aborting on a killed thread" 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 end
it "reports aborting on a killed thread after sleep" do
ThreadSpecs.status_of_dying_thread_after_sleep.status.should == 'aborting'
end end
end end

View file

@ -48,9 +48,7 @@ describe "Thread#stop?" do
ThreadSpecs.status_of_dying_sleeping_thread.stop?.should == true ThreadSpecs.status_of_dying_sleeping_thread.stop?.should == true
end end
quarantine! do it "describes a dying thread after sleep" do
it "reports aborting on a killed thread" do ThreadSpecs.status_of_dying_thread_after_sleep.stop?.should == false
ThreadSpecs.status_of_aborting_thread.stop?.should == false
end
end end
end end

View file

@ -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 it "raises a LocalJumpError when invoking the block from a method" do
lambda { @program.break_in_nested_method }.should raise_error(LocalJumpError) 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 end
it "raises a LocalJumpError when yielding to the block" do it "raises a LocalJumpError when yielding to the block" do
lambda { @program.break_in_yielding_method }.should raise_error(LocalJumpError) 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
end end
@ -60,6 +60,20 @@ describe "The break statement in a captured block" do
ScratchPad.recorded.should == [:a, :za, :xa, :zd, :aa, :zb] ScratchPad.recorded.should == [:a, :za, :xa, :zd, :aa, :zb]
end end
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 end
describe "The break statement in a lambda" do describe "The break statement in a lambda" do

View file

@ -89,7 +89,7 @@ module BreakSpecs
break :break break :break
note :c note :c
} }
note :c note :cc
note call_method(b) note call_method(b)
note :d note :d
end end
@ -101,7 +101,7 @@ module BreakSpecs
break :break break :break
note :c note :c
} }
note :c note :cc
note yielding(&b) note yielding(&b)
note :d note :d
end end

View file

@ -83,7 +83,9 @@ module DefinedSpecs
end end
def global_variable_read 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 defined? $defined_specs_global_variable_read
end end

View file

@ -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

View file

@ -3,12 +3,15 @@ describe :strscan_peek, shared: true do
@s = StringScanner.new('This is a test') @s = StringScanner.new('This is a test')
end 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.send(@method, 4).should == "This"
@s.pos.should == 0 @s.pos.should == 0
@s.pos = 5 @s.pos = 5
@s.send(@method, 2).should == "is" @s.send(@method, 2).should == "is"
@s.send(@method, 1000).should == "is a test" @s.send(@method, 1000).should == "is a test"
s = StringScanner.new("été")
s.send(@method, 2).should == "é"
end end
it "returns an empty string when the passed argument is zero" do it "returns an empty string when the passed argument is zero" do

View file

@ -1,6 +1,7 @@
#include "ruby.h" #include "ruby.h"
#include "rubyspec.h" #include "rubyspec.h"
#include "ruby/io.h" #include "ruby/io.h"
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
@ -133,46 +134,46 @@ VALUE io_spec_rb_io_taint_check(VALUE self, VALUE io) {
} }
#endif #endif
typedef int wait_bool;
#define wait_bool_to_ruby_bool(x) (x ? Qtrue : Qfalse)
#ifdef HAVE_RB_IO_WAIT_READABLE #ifdef HAVE_RB_IO_WAIT_READABLE
#define RB_IO_WAIT_READABLE_BUF 13 #define RB_IO_WAIT_READABLE_BUF 13
VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) { VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io, VALUE read_p) {
int fd = io_spec_get_fd(io); int fd = io_spec_get_fd(io);
char buf[RB_IO_WAIT_READABLE_BUF]; char buf[RB_IO_WAIT_READABLE_BUF];
wait_bool ret; int ret, r, saved_errno;
if (set_non_blocking(fd) == -1) if (set_non_blocking(fd) == -1)
rb_sys_fail("set_non_blocking failed"); rb_sys_fail("set_non_blocking failed");
if(RTEST(read_p)) { 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; return Qnil;
} }
saved_errno = errno;
rb_ivar_set(self, rb_intern("@write_data"), Qtrue); rb_ivar_set(self, rb_intern("@write_data"), Qtrue);
errno = saved_errno;
} }
ret = rb_io_wait_readable(fd); ret = rb_io_wait_readable(fd);
if(RTEST(read_p)) { if(RTEST(read_p)) {
if(read(fd, buf, RB_IO_WAIT_READABLE_BUF) != 13) { r = read(fd, buf, RB_IO_WAIT_READABLE_BUF);
return Qnil; if (r != RB_IO_WAIT_READABLE_BUF) {
perror("read");
return INT2FIX(r);
} }
rb_ivar_set(self, rb_intern("@read_data"), rb_ivar_set(self, rb_intern("@read_data"),
rb_str_new(buf, RB_IO_WAIT_READABLE_BUF)); rb_str_new(buf, RB_IO_WAIT_READABLE_BUF));
} }
return wait_bool_to_ruby_bool(ret); return ret ? Qtrue : Qfalse;
} }
#endif #endif
#ifdef HAVE_RB_IO_WAIT_WRITABLE #ifdef HAVE_RB_IO_WAIT_WRITABLE
VALUE io_spec_rb_io_wait_writable(VALUE self, VALUE io) { VALUE io_spec_rb_io_wait_writable(VALUE self, VALUE io) {
wait_bool ret; int ret = rb_io_wait_writable(io_spec_get_fd(io));
ret = rb_io_wait_writable(io_spec_get_fd(io)); return ret ? Qtrue : Qfalse;
return wait_bool_to_ruby_bool(ret);
} }
#endif #endif

View file

@ -188,7 +188,7 @@ describe "CApiGlobalSpecs" do
running = true running = true
end end
Thread.pass until running Thread.pass while thr.status and !running
$_.should be_nil $_.should be_nil
thr.join thr.join
@ -215,7 +215,7 @@ describe "CApiGlobalSpecs" do
running = true running = true
end end
Thread.pass until running Thread.pass while thr.status and !running
$_.should be_nil $_.should be_nil
thr.join thr.join

View file

@ -175,6 +175,7 @@ describe "CApiObject" do
describe "rb_require" do describe "rb_require" do
before :each do before :each do
@saved_loaded_features = $LOADED_FEATURES.dup @saved_loaded_features = $LOADED_FEATURES.dup
$foo = nil
end end
after :each do after :each do
@ -183,7 +184,6 @@ describe "CApiObject" do
end end
it "requires a ruby file" do it "requires a ruby file" do
$foo.should == nil
$:.unshift File.dirname(__FILE__) $:.unshift File.dirname(__FILE__)
@o.rb_require() @o.rb_require()
$foo.should == 7 $foo.should == 7

View file

@ -107,6 +107,10 @@ describe "C-API Thread function" do
# Wait until it's blocking... # Wait until it's blocking...
Thread.pass while thr.status and thr.status != "sleep" 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. # Wake it up, causing the unblock function to be run.
thr.wakeup thr.wakeup