Created
May 21, 2013 07:55
-
-
Save badosu/5618190 to your computer and use it in GitHub Desktop.
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
@@ -161,9 +165,18 @@ describe "A block" do | |
lambda { @y.s(obj) { |a, b| } }.should raise_error(TypeError) | |
end | |
+ | |
+ it "raises an exception if #to_ary raises an exception" do | |
+ obj = mock("block yield to_ary raising an exception") | |
+ obj.should_receive(:to_ary).and_raise(ZeroDivisionError) | |
+ | |
+ lambda { @y.s(obj) { |a, b| } }.should raise_error(ZeroDivisionError) | |
+ end | |
+ | |
end | |
describe "taking |a, *b| arguments" do | |
+ | |
it "assigns 'nil' and '[]' to the arguments when no values are yielded" do | |
@y.z { |a, *b| [a, b] }.should == [nil, []] | |
end | |
diff --git a/vm/instructions.def b/vm/instructions.def | |
index e199f40..221e5aa 100644 | |
--- a/vm/instructions.def | |
+++ b/vm/instructions.def | |
@@ -1320,6 +1320,9 @@ instruction cast_for_splat_block_arg() [ -- arguments ] | |
if(CBOOL(obj->respond_to(state, G(sym_to_ary), cFalse))) { | |
OnStack<1> os(state, obj); | |
Object* ignored = obj->send(state, call_frame, G(sym_to_ary)); | |
+ if(!ignored) { | |
+ RUN_EXCEPTION(); | |
+ } | |
if(!ignored->nil_p() && !kind_of<Array>(ignored)) { | |
Exception::type_error(state, "to_ary must return an Array", call_frame); | |
RUN_EXCEPTION(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment