mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 21:49:06 +02:00
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
This commit is contained in:
parent
fb6db414a1
commit
2e24a66b88
3 changed files with 52 additions and 11 deletions
|
@ -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 => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue