mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
compile.c: support branch coverage for a&.foo = 1
[Bug #15475] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7e035dcda7
commit
d58bada6cc
2 changed files with 26 additions and 9 deletions
|
@ -348,15 +348,22 @@ class TestCoverage < Test::Unit::TestCase
|
|||
def test_branch_coverage_for_safe_method_invocation
|
||||
result = {
|
||||
:branches=>{
|
||||
[:"&.", 0, 3, 0, 3, 6] => {[:then, 1, 3, 0, 3, 6]=>1, [:else, 2, 3, 0, 3, 6]=>0},
|
||||
[:"&.", 3, 4, 0, 4, 6] => {[:then, 4, 4, 0, 4, 6]=>0, [:else, 5, 4, 0, 4, 6]=>1},
|
||||
[:"&.", 0, 6, 0, 6, 6] => {[:then, 1, 6, 0, 6, 6]=>1, [:else, 2, 6, 0, 6, 6]=>0},
|
||||
[:"&.", 3, 7, 0, 7, 6] => {[:then, 4, 7, 0, 7, 6]=>0, [:else, 5, 7, 0, 7, 6]=>1},
|
||||
[:"&.", 6, 8, 0, 8, 10] => {[:then, 7, 8, 0, 8, 10]=>1, [:else, 8, 8, 0, 8, 10]=>0},
|
||||
[:"&.", 9, 9, 0, 9, 10] => {[:then, 10, 9, 0, 9, 10]=>0, [:else, 11, 9, 0, 9, 10]=>1},
|
||||
}
|
||||
}
|
||||
assert_coverage(<<~"end;", { branches: true }, result)
|
||||
a = 10
|
||||
class Dummy; def foo; end; def foo=(x); end; end
|
||||
a = Dummy.new
|
||||
b = nil
|
||||
a&.abs
|
||||
b&.hoo
|
||||
c = Dummy.new
|
||||
d = nil
|
||||
a&.foo
|
||||
b&.foo
|
||||
c&.foo = 1
|
||||
d&.foo = 1
|
||||
end;
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue