summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-16 11:42:03 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-16 11:42:03 +0000
commit36a0a1a3f3d6ede4c8d42c3beb2e5c24ea649f3c (patch)
treede1c5a4fa3147dba0cf70117320b639ab3feae20 /test
parent90b86c51ab8161f49b5d88f35a3ce6cf78fe7274 (diff)
* eval_jump.c (rb_exec_end_proc): changed at_exit and END proc
evaluation order. [Bug #4400] [ruby-core:35237] * eval_jump.c (rb_mark_end_proc): ditto. * test/ruby/test_beginendblock.rb (TestBeginEndBlock#test_nested_at_exit): added a test for nested at_exit. * test/ruby/test_beginendblock.rb (TestBeginEndBlock#test_beginendblock): changed the test to adopt new spec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_beginendblock.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb
index 0540f5df1c..7e460b989d 100644
--- a/test/ruby/test_beginendblock.rb
+++ b/test/ruby/test_beginendblock.rb
@@ -14,7 +14,7 @@ class TestBeginEndBlock < Test::Unit::TestCase
ruby = EnvUtil.rubybin
target = File.join(DIR, 'beginmainend.rb')
result = IO.popen([ruby, target]){|io|io.read}
- assert_equal(%w(b1 b2-1 b2 main b3-1 b3 b4 e1 e4 e3 e2 e4-2 e4-1 e1-1 e4-1-1), result.split)
+ assert_equal(%w(b1 b2-1 b2 main b3-1 b3 b4 e1 e1-1 e4 e4-2 e4-1 e4-1-1 e3 e2), result.split)
input = Tempfile.new(self.class.name)
inputpath = input.path
@@ -124,4 +124,25 @@ EOW
assert_match(/e1/, out)
assert_match(/e6/, out)
end
+
+ def test_nested_at_exit
+ t = Tempfile.new(["test_nested_at_exit_", ".rb"])
+ t.puts "at_exit { puts :outer0 }"
+ t.puts "at_exit { puts :outer1_begin; at_exit { puts :inner1 }; puts :outer1_end }"
+ t.puts "at_exit { puts :outer2_begin; at_exit { puts :inner2 }; puts :outer2_end }"
+ t.puts "at_exit { puts :outer3 }"
+ t.flush
+
+ expected = [ "outer3",
+ "outer2_begin",
+ "outer2_end",
+ "inner2",
+ "outer1_begin",
+ "outer1_end",
+ "inner1",
+ "outer0" ]
+
+ assert_in_out_err(t.path, "", expected, [], "[ruby-core:35237]")
+ t.close
+ end
end