-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
6 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
require_relative '../../spec_helper' | ||
|
||
ruby_version_is ''...'3.1' do | ||
describe "Thread#native_thread_id" do | ||
it "raises NoMethodError" do | ||
th = Thread.new {} | ||
-> { th.native_thread_id }.should raise_error(NoMethodError) | ||
th.join | ||
end | ||
end | ||
end | ||
|
||
ruby_version_is "3.1" do | ||
describe "Thread#native_thread_id" do | ||
platform_is_not :linux do | ||
it "returns an integer" do | ||
th = Thread.new {} | ||
th.native_thread_id.should be_kind_of(Integer) | ||
th.join | ||
end | ||
it "returns an integer when the thread is alive" do | ||
Thread.current.native_thread_id.should be_kind_of(Integer) | ||
end | ||
|
||
platform_is :linux do | ||
it "returns nil" do | ||
th = Thread.new {} | ||
th.native_thread_id.should be_nil | ||
th.join | ||
end | ||
it "returns nil when the thread is not running" do | ||
t = Thread.new {} | ||
t.join | ||
t.native_thread_id.should == nil | ||
end | ||
end | ||
end |