Permalink
Browse files

Merge pull request #1357 from obrok/thread

Fixes for Thread #start, #key?, #[], #[]= in 1.9
  • Loading branch information...
2 parents 80e8429 + d45da1d commit d70dd47d8e15ce5b56fde607cb052b3044dea052 @rue rue committed Oct 25, 2011
@@ -34,6 +34,7 @@ static_scope.rbc
string.rbc
symbol.rbc
thread.rbc
+thread18.rbc
thunk.rbc
time.rbc
true.rbc
@@ -36,6 +36,7 @@ static_scope.rbc
string.rbc
symbol.rbc
thread.rbc
+thread19.rbc
thunk.rbc
time.rbc
true.rbc
@@ -35,6 +35,7 @@ static_scope.rbc
string.rbc
symbol.rbc
thread.rbc
+thread19.rbc
thunk.rbc
time.rbc
true.rbc
@@ -114,31 +114,6 @@ def self.new(*args)
return thr
end
- def self.start(*args)
- thr = Rubinius.invoke_primitive :thread_allocate, self
-
- Rubinius.asm(args, thr) do |args, obj|
- run obj
- dup
-
- push_false
- send :setup, 1, true
- pop
-
- run args
- push_block
- send_with_splat :__thread_initialize__, 0, true
- # no pop here, as .asm blocks imply a pop as they're not
- # allowed to leak a stack value
- end
-
- return thr
- end
-
- class << self
- alias_method :fork, :start
- end
-
def initialize(*args, &block)
unless block
Kernel.raise ThreadError, "no block passed to Thread#initialize"
@@ -0,0 +1,26 @@
+class Thread
+ def self.start(*args)
+ thr = Rubinius.invoke_primitive :thread_allocate, self
+
+ Rubinius.asm(args, thr) do |args, obj|
+ run obj
+ dup
+
+ push_false
+ send :setup, 1, true
+ pop
+
+ run args
+ push_block
+ send_with_splat :__thread_initialize__, 0, true
+ # no pop here, as .asm blocks imply a pop as they're not
+ # allowed to leak a stack value
+ end
+
+ return thr
+ end
+
+ class << self
+ alias_method :fork, :start
+ end
+end
@@ -0,0 +1,28 @@
+class Thread
+ def self.start(*args)
+ raise ArgumentError.new("no block passed to Thread.start") unless block_given?
+
+ thr = Rubinius.invoke_primitive :thread_allocate, self
+
+ Rubinius.asm(args, thr) do |args, obj|
+ run obj
+ dup
+
+ push_false
+ send :setup, 1, true
+ pop
+
+ run args
+ push_block
+ send_with_splat :__thread_initialize__, 0, true
+ # no pop here, as .asm blocks imply a pop as they're not
+ # allowed to leak a stack value
+ end
+
+ return thr
+ end
+
+ class << self
+ alias_method :fork, :start
+ end
+end
@@ -0,0 +1,21 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+
+describe "Rubinius::Type.coerce_to_symbol" do
+ ruby_version_is ''...'1.9' do
+ it 'raises TypeError if the coercion fails' do
+ lambda { Rubinius::Type.coerce_to_symbol nil }.should raise_error(TypeError)
+ end
+
+ it 'raises ArgumentError if supplied with a Fixnum' do
+ lambda { Rubinius::Type.coerce_to_symbol 42 }.should raise_error(ArgumentError)
+ end
+ end
+
+ ruby_version_is '1.9' do
+ it 'always raises TypeError if the coercion fails' do
+ lambda { Rubinius::Type.coerce_to_symbol nil }.should raise_error(TypeError)
+ lambda { Rubinius::Type.coerce_to_symbol 42 }.should raise_error(TypeError)
+ end
+ end
+end
@@ -1 +0,0 @@
-fails:Thread#[] raises exceptions on the wrong type of keys
@@ -1 +0,0 @@
-fails:Thread#[]= raises exceptions on the wrong type of keys
@@ -1 +0,0 @@
-fails:Thread.fork Thread.start raises a ArgumentError if not passed a block
@@ -1 +0,0 @@
-fails:Thread#key? raises exceptions on the wrong type of keys
@@ -1 +0,0 @@
-fails:Thread.start Thread.start raises a ArgumentError if not passed a block

0 comments on commit d70dd47

Please sign in to comment.