2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
|
|
|
require_relative 'fixtures/classes'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "Thread#value" do
|
|
|
|
it "returns the result of the block" do
|
|
|
|
Thread.new { 3 }.value.should == 3
|
|
|
|
end
|
|
|
|
|
|
|
|
it "re-raises an error for an uncaught exception" do
|
2017-10-28 11:15:48 -04:00
|
|
|
t = Thread.new {
|
|
|
|
Thread.current.report_on_exception = false
|
|
|
|
raise "Hello"
|
|
|
|
}
|
2017-05-07 08:04:49 -04:00
|
|
|
lambda { t.value }.should raise_error(RuntimeError, "Hello")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is nil for a killed thread" do
|
|
|
|
t = Thread.new { Thread.current.exit }
|
|
|
|
t.value.should == nil
|
|
|
|
end
|
|
|
|
end
|