summaryrefslogtreecommitdiff
path: root/spec/rubyspec/core/thread/value_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/core/thread/value_spec.rb')
-rw-r--r--spec/rubyspec/core/thread/value_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/rubyspec/core/thread/value_spec.rb b/spec/rubyspec/core/thread/value_spec.rb
new file mode 100644
index 0000000000..82c0cbf762
--- /dev/null
+++ b/spec/rubyspec/core/thread/value_spec.rb
@@ -0,0 +1,18 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+
+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
+ t = Thread.new { raise "Hello" }
+ 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