Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions spec/ruby/core/kernel/eval_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@ class Object
-> { eval("return :eval") }.call.should == :eval
end

it "returns from the method calling #eval when evaluating 'return'" do
def eval_return(n)
eval("return n*2")
end
-> { eval_return(3) }.call.should == 6
end

it "returns from the method calling #eval when evaluating 'return' in BEGIN" do
def eval_return(n)
eval("BEGIN {return n*3}")
end
-> { eval_return(4) }.call.should == 12
end

it "unwinds through a Proc-style closure and returns from a lambda-style closure in the closure chain" do
code = fixture __FILE__, "eval_return_with_lambda.rb"
ruby_exe(code).chomp.should == "a,b,c,eval,f"
Expand Down