summaryrefslogtreecommitdiff
path: root/test/coverage
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-01 03:03:17 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-01 03:03:17 +0000
commit9613af6f34e46bc70528593b345824ccada18102 (patch)
treebc215601ddd58ec0c0471f42f0fd2211b1420200 /test/coverage
parent99d363184765ef6b11e739299a805c366171fd26 (diff)
compile.c (iseq_set_sequence): fix branch coverage table
Not only TRACE_ELEMENT but also INSN_ELEMENT may have events. The old pc2branchindex was created using only events of TRACE_ELEMENTs. This change uses events of INSN_ELEMENTs too for pc2branchindex table. [Bug #15476] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage')
-rw-r--r--test/coverage/test_coverage.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index 1797c898af..6a58706440 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -167,6 +167,20 @@ class TestCoverage < Test::Unit::TestCase
end;
end
+ def test_coverage_optimized_branch
+ result = {
+ :branches => {
+ [:"&.", 0, 1, 0, 1, 8] => {
+ [:then, 1, 1, 0, 1, 8] => 1,
+ [:else, 2, 1, 0, 1, 8] => 0,
+ },
+ },
+ }
+ assert_coverage(<<~"end;", { branches: true }, result) # Bug #15476
+ nil&.foo
+ end;
+ end
+
def assert_coverage(code, opt, stdout)
stdout = [stdout] unless stdout.is_a?(Array)
stdout = stdout.map {|s| s.to_s }