summaryrefslogtreecommitdiff
path: root/test/coverage/test_coverage.rb
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-22 13:49:41 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-22 13:49:41 +0000
commitecdac92e50cf679ad2d9c2a235f136f18d5f212c (patch)
treecbd096c4125ea10bce8d0bd898e7253d2b591982 /test/coverage/test_coverage.rb
parentde482ab1436ea124237ee5c4cde492fe2ee311fb (diff)
Add test cases for branch coverage
* test/coverage/test_coverage.rb (test_branch_coverage_for_if_statement): Add test cases for if/unless without else clauses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r--test/coverage/test_coverage.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index 3a12ad1..9d4f734 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -197,8 +197,10 @@ class TestCoverage < Test::Unit::TestCase
def test_branch_coverage_for_if_statement
result = {
:branches => {
- [: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},
+ [: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},
+ [:if , 6, 14, 2] => {[:then, 7, 15, 4]=>2, [:else, 8, 14, 2]=>1},
+ [:unless, 9, 18, 2] => {[:else, 10, 18, 2]=>2, [:then, 11, 19, 4]=>1},
}
}
assert_coverage(<<~"end;", { branches: true }, result)
@@ -214,6 +216,14 @@ class TestCoverage < Test::Unit::TestCase
else
1
end
+
+ if x == 0
+ 0
+ end
+
+ unless x == 0
+ 0
+ end
end
foo(0)