summaryrefslogtreecommitdiff
path: root/spec/ruby/language/return_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/return_spec.rb')
-rw-r--r--spec/ruby/language/return_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/language/return_spec.rb b/spec/ruby/language/return_spec.rb
index 94c15b697e..a62ed1242d 100644
--- a/spec/ruby/language/return_spec.rb
+++ b/spec/ruby/language/return_spec.rb
@@ -435,6 +435,21 @@ describe "The return keyword" do
end
end
+ describe "within BEGIN" do
+ it "is allowed" do
+ File.write(@filename, <<-END_OF_CODE)
+ BEGIN {
+ ScratchPad << "before call"
+ return
+ ScratchPad << "after call"
+ }
+ END_OF_CODE
+
+ load @filename
+ ScratchPad.recorded.should == ["before call"]
+ end
+ end
+
describe "file loading" do
it "stops file loading and execution" do
File.write(@filename, <<-END_OF_CODE)