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 14:13:50 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-22 14:13:50 +0000
commit588ac3ee1fd23690e2da36986f736aac12bec589 (patch)
treeb8c09e779a54a11a9cc2cf19cb893d74e4782542 /test/coverage/test_coverage.rb
parentef29f8db80bc88cfc1a2a384d81b4b1e3860d421 (diff)
Add test cases for branch coverage
* test/coverage/test_coverage.rb (test_branch_coverage_for_if_statement): Add a test case for ternary operator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r--test/coverage/test_coverage.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index c309a25..d78c8a0 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -197,12 +197,13 @@ 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 , 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},
- [:if , 12, 22, 2] => {[:then, 13, 22, 2]=>2, [:else, 14, 22, 2]=>1},
- [:unless, 15, 23, 2] => {[:else, 16, 23, 2]=>2, [:then, 17, 23, 2]=>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},
+ [:if , 12, 22, 2] => {[:then, 13, 22, 2]=>2, [:else, 14, 22, 2]=>1},
+ [:unless, 15, 23, 2] => {[:else, 16, 23, 2]=>2, [:then, 17, 23, 2]=>1},
+ [:if , 18, 25, 2] => {[:then, 19, 25, 11]=>2, [:else, 20, 25, 15]=>1},
}
}
assert_coverage(<<~"end;", { branches: true }, result)
@@ -229,6 +230,8 @@ class TestCoverage < Test::Unit::TestCase
0 if x == 0
0 unless x == 0
+
+ x == 0 ? 0 : 1
end
foo(0)