diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-09 13:29:42 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-09 13:29:42 +0000 |
commit | e55b415c2fa001bd91d8706c5492d2cb28393f88 (patch) | |
tree | 3c6ff13a260dcf54803fa67936a52baa445206fe /test | |
parent | 12474f034730c2832e5785a2b2e3eeaaa181d743 (diff) |
merge revision(s) 59202: [Backport #13690]
compile.c: disallow next in once
* compile.c (iseq_compile_each0): turned dregx context in "once"
into "guarded" type from "block" type, to disallow `next`,
`break`, `redo` as well as outside "once".
[ruby-core:81805] [Bug #13690]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_exception.rb | 11 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 8 |
2 files changed, 8 insertions, 11 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 90ed39de2a..165f679e76 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -905,15 +905,4 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| } end; end - - def test_break_in_once - assert_separately([], "#{<<-"begin;"}\n#{<<~'end;'}") - begin; - obj = Object.new - def obj.try - /#{break}/o - end - assert_raise(LocalJumpError, /proc-closure/) {obj.try} - end; - end end diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index eba5f6d851..56ea659191 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -453,8 +453,16 @@ WARN } end + def test_invalid_break + assert_syntax_error("def m; break; end", /Invalid break/) + assert_in_out_err([], '/#{break}/', [], /Invalid break \(SyntaxError\)$/) + assert_in_out_err([], '/#{break}/o', [], /Invalid break \(SyntaxError\)$/) + end + def test_invalid_next assert_syntax_error("def m; next; end", /Invalid next/) + assert_in_out_err([], '/#{next}/', [], /Invalid next \(SyntaxError\)$/) + assert_in_out_err([], '/#{next}/o', [], /Invalid next \(SyntaxError\)$/) end def test_lambda_with_space |