mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/coverage/test_coverage.rb: Use <<~
to ease to calculate column of target codes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
755dd9f461
commit
de482ab143
1 changed files with 14 additions and 14 deletions
|
@ -197,11 +197,11 @@ class TestCoverage < Test::Unit::TestCase
|
|||
def test_branch_coverage_for_if_statement
|
||||
result = {
|
||||
:branches => {
|
||||
[:if , 0, 2, 8] => {[:then, 1, 3, 10]=>2, [:else, 2, 5, 10]=>1},
|
||||
[:unless, 3, 8, 8] => {[:else, 4, 11, 10]=>2, [:then, 5, 9, 10]=>1},
|
||||
[:if , 0, 2, 2] => {[:then, 1, 3, 4]=>2, [:else, 2, 5, 4]=>1},
|
||||
[:unless, 3, 8, 2] => {[:else, 4, 11, 4]=>2, [:then, 5, 9, 4]=>1},
|
||||
}
|
||||
}
|
||||
assert_coverage(<<-"end;", { branches: true }, result)
|
||||
assert_coverage(<<~"end;", { branches: true }, result)
|
||||
def foo(x)
|
||||
if x == 0
|
||||
0
|
||||
|
@ -225,11 +225,11 @@ class TestCoverage < Test::Unit::TestCase
|
|||
def test_branch_coverage_for_while_statement
|
||||
result = {
|
||||
:branches => {
|
||||
[:while, 0, 2, 6] => {[:body, 1, 3, 8]=> 3},
|
||||
[:until, 2, 5, 6] => {[:body, 3, 6, 8]=>10},
|
||||
[:while, 0, 2, 0] => {[:body, 1, 3, 2]=> 3},
|
||||
[:until, 2, 5, 0] => {[:body, 3, 6, 2]=>10},
|
||||
}
|
||||
}
|
||||
assert_coverage(<<-"end;", { branches: true }, result)
|
||||
assert_coverage(<<~"end;", { branches: true }, result)
|
||||
x = 3
|
||||
while x > 0
|
||||
x -= 1
|
||||
|
@ -243,13 +243,13 @@ class TestCoverage < Test::Unit::TestCase
|
|||
def test_branch_coverage_for_case_statement
|
||||
result = {
|
||||
:branches => {
|
||||
[:case, 0, 2, 8] => {[:when, 1, 4, 10]=>2, [:when, 2, 6, 10]=>0, [:else, 3, 2, 8]=>1},
|
||||
[:case, 4, 9, 8] => {[:when, 5, 11, 10]=>2, [:when, 6, 13, 10]=>0, [:else, 7, 9, 8]=>1},
|
||||
[:case, 8, 16, 8] => {[:when, 9, 18, 10]=>2, [:when, 10, 20, 10]=>0, [:else, 11, 22, 10]=>1},
|
||||
[:case, 12, 25, 8] => {[:when, 13, 27, 10]=>2, [:when, 14, 29, 10]=>0, [:else, 15, 31, 10]=>1},
|
||||
[:case, 0, 2, 2] => {[:when, 1, 4, 4]=>2, [:when, 2, 6, 4]=>0, [:else, 3, 2, 2]=>1},
|
||||
[:case, 4, 9, 2] => {[:when, 5, 11, 4]=>2, [:when, 6, 13, 4]=>0, [:else, 7, 9, 2]=>1},
|
||||
[:case, 8, 16, 2] => {[:when, 9, 18, 4]=>2, [:when, 10, 20, 4]=>0, [:else, 11, 22, 4]=>1},
|
||||
[:case, 12, 25, 2] => {[:when, 13, 27, 4]=>2, [:when, 14, 29, 4]=>0, [:else, 15, 31, 4]=>1},
|
||||
}
|
||||
}
|
||||
assert_coverage(<<-"end;", { branches: true }, result)
|
||||
assert_coverage(<<~"end;", { branches: true }, result)
|
||||
def foo(x)
|
||||
case x
|
||||
when 0
|
||||
|
@ -293,11 +293,11 @@ class TestCoverage < Test::Unit::TestCase
|
|||
def test_branch_coverage_for_safe_method_invocation
|
||||
result = {
|
||||
:branches=>{
|
||||
[:"&.", 0, 3, 6] => {[:then, 1, 3, 6]=>1, [:else, 2, 3, 6]=>0},
|
||||
[:"&.", 3, 4, 6] => {[:then, 4, 4, 6]=>0, [:else, 5, 4, 6]=>1},
|
||||
[:"&.", 0, 3, 0] => {[:then, 1, 3, 0]=>1, [:else, 2, 3, 0]=>0},
|
||||
[:"&.", 3, 4, 0] => {[:then, 4, 4, 0]=>0, [:else, 5, 4, 0]=>1},
|
||||
}
|
||||
}
|
||||
assert_coverage(<<-"end;", { branches: true }, result)
|
||||
assert_coverage(<<~"end;", { branches: true }, result)
|
||||
a = 10
|
||||
b = nil
|
||||
a&.abs
|
||||
|
|
Loading…
Add table
Reference in a new issue