Skip to content

Commit 52369d8

Browse files
committed
Added test for explicit cases
1 parent 621f237 commit 52369d8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/test/scala/scoverage/PluginCoverageTest.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,24 @@ class PluginCoverageTest
3636

3737

3838
// https://github.com/scoverage/sbt-scoverage/issues/16
39-
test("scoverage should instrument for-loops") {
39+
test("scoverage should instrument for-loops but not the generated default case") {
4040
compileCodeSnippet( """ trait A {
4141
| def print1(list: List[String]) = for (string: String <- list) println(string)
4242
|} """.stripMargin)
43-
// we should have 3 statements
43+
// should have one statement for the withFilter invoke, one of the match selector,
44+
// one of the case block, one for the case string RHS value, one for the foreach block.
4445
assertNMeasuredStatements(5)
4546
}
47+
48+
test("scoverage should instrument all case statements in an explicit match") {
49+
compileCodeSnippet( """ trait A {
50+
| def foo(name: Any) = name match {
51+
| case i : Int => 1
52+
| case b : Boolean => 2
53+
| case _ => 3
54+
| }
55+
|} """.stripMargin)
56+
// should have one statement for each literal, one for each case block, and one for the selector.
57+
assertNMeasuredStatements(7)
58+
}
4659
}

0 commit comments

Comments
 (0)