1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* parse.y (top_compstmt, top_stmts, top_stmt): prohibit BEGIN {} in

non-toplevel scope.  [ruby-core:21657]

* test/ruby/test_beginendblock.rb (test_begininclass): add a test for
  above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2010-01-18 16:43:29 +00:00
parent f00951bb25
commit 6b438bee04
3 changed files with 83 additions and 20 deletions

View file

@ -41,6 +41,12 @@ class TestBeginEndBlock < Test::Unit::TestCase
end
end
def test_begininclass
assert_raise(SyntaxError) do
eval("class TestBeginEndBlock; BEGIN {}; end")
end
end
def test_endblockwarn
ruby = EnvUtil.rubybin
# Use Tempfile to create temporary file path.