diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-16 05:36:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-16 05:36:42 +0000 |
commit | 8c15f40acfd4171419d15b2516674a067d7d999f (patch) | |
tree | cb5a01be40ffc9f21e2eeae47d2967552d326b15 /test/ruby/test_class.rb | |
parent | 7a666c67664053df9e749cc81d17a2312881d436 (diff) | |
download | ruby-8c15f40acfd4171419d15b2516674a067d7d999f.tar.gz |
parse.y: no return in class
* parse.y (k_return): prohibit return in class/module body except
for singleton class.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_class.rb')
-rw-r--r-- | test/ruby/test_class.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 0986e64fbb..bb8a3c574d 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -241,15 +241,23 @@ class TestClass < Test::Unit::TestCase assert_equal("TestClass::C\u{df}", c.name, '[ruby-core:24600]') end - def test_invalid_jump_from_class_definition + def test_invalid_next_from_class_definition assert_raise(SyntaxError) { eval("class C; next; end") } + end + + def test_invalid_break_from_class_definition assert_raise(SyntaxError) { eval("class C; break; end") } + end + + def test_invalid_redo_from_class_definition assert_raise(SyntaxError) { eval("class C; redo; end") } + end + + def test_invalid_retry_from_class_definition assert_raise(SyntaxError) { eval("class C; retry; end") } end def test_invalid_return_from_class_definition - skip "Wrongly return from this method" assert_raise(SyntaxError) { eval("class C; return; end") } end |