summaryrefslogtreecommitdiff
path: root/test/coverage/test_coverage.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-18 02:44:36 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-18 02:44:36 +0000
commit2e24a66b883b7f14d9dd0aeffa749d68dd5d6939 (patch)
treeacc092cd4b620f77c355b13f06f6f510604e79b9 /test/coverage/test_coverage.rb
parentfb6db414a199a6d2e43952413823198b69b6d1e3 (diff)
iseq.c (finish_iseq_build): fix coverage leakage [Bug #14191]
Before this change, coverage.so had failed to measure some multiple-line code fragments. This is because removing trace instructions (#14104) changed TracePoint's lineno (new lineno), and coverage counter array was based on old lineno. This change initializes coverage counter array based on new lineno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r--test/coverage/test_coverage.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index 3fbd815..281d525 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -201,6 +201,39 @@ class TestCoverage < Test::Unit::TestCase
}
end
+ def test_line_coverage_for_multiple_lines
+ result = {
+ :lines => [nil, 1, nil, nil, nil, 1, nil, nil, nil, 1, nil, 1, nil, nil, nil, nil, 1, 1, nil, 1, nil, nil, nil, nil, 1]
+ }
+ assert_coverage(<<~"end;", { lines: true }, result) # Bug #14191
+ FOO = [
+ { foo: 'bar' },
+ { bar: 'baz' }
+ ]
+
+ 'some string'.split
+ .map(&:length)
+
+ some =
+ 'value'
+
+ Struct.new(
+ :foo,
+ :bar
+ ).new
+
+ class Test
+ def foo(bar)
+ {
+ foo: bar
+ }
+ end
+ end
+
+ Test.new.foo(Object.new)
+ end;
+ end
+
def test_branch_coverage_for_if_statement
result = {
:branches => {