diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2022-11-08 11:52:22 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2022-11-08 14:37:08 +0900 |
commit | 4a7d6c2852aa734506be83c932168e8f974687b5 (patch) | |
tree | 0e25f1f2b2036fcf461b3df00ac48cbedd2043c2 /test/coverage | |
parent | f7db1affd10767d729866e95c02ffb26266829ab (diff) | |
download | ruby-4a7d6c2852aa734506be83c932168e8f974687b5.tar.gz |
Fix false LocalJumpError when branch coverage is enabled
`throw TAG_BREAK` instruction makes a jump only if the continuation of
catch of TAG_BREAK exactly matches the instruction immediately following
the "send" instruction that is currently being executed. Otherwise, it
seems to determine break from proc-closure.
Branch coverage may insert some recording instructions after "send"
instruction, which broke the conditions for TAG_BREAK to work properly.
This change forces to set the continuation of catch of TAG_BREAK
immediately after "send" (or "invokesuper") instruction.
[Bug #18991]
Diffstat (limited to 'test/coverage')
-rw-r--r-- | test/coverage/test_coverage.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb index 1a21235d0a..a2a7718a30 100644 --- a/test/coverage/test_coverage.rb +++ b/test/coverage/test_coverage.rb @@ -964,4 +964,18 @@ class TestCoverage < Test::Unit::TestCase p :NG end; end + + def test_tag_break_with_branch_coverage + result = { + :branches => { + [:"&.", 0, 1, 0, 1, 6] => { + [:then, 1, 1, 0, 1, 6] => 1, + [:else, 2, 1, 0, 1, 6] => 0, + }, + }, + } + assert_coverage(<<~"end;", { branches: true }, result) + 1&.tap do break end + end; + end end |