Skip to content

Commit 9e3db04

Browse files
committed
Added tests for yields
1 parent b1c8ca5 commit 9e3db04

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/test/scala/scoverage/PluginASTSupportTest.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,16 @@ class PluginASTSupportTest
9393
assert(!reporter.hasErrors)
9494
assert(!reporter.hasWarnings)
9595
}
96+
97+
test("type param with default arg supported") {
98+
compileCodeSnippet( """ class TypeTreeObjects {
99+
| class Container {
100+
| def typeParamAndDefaultArg[C](name: String = "sammy"): String = name
101+
| }
102+
| new Container().typeParamAndDefaultArg[Any]()
103+
| } """.stripMargin)
104+
assert(!reporter.hasErrors)
105+
assert(!reporter.hasWarnings)
106+
}
96107
}
97108

src/test/scala/scoverage/PluginCoverageTest.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ class PluginCoverageTest
8080
assertNMeasuredStatements(7)
8181
}
8282

83+
84+
85+
test("scoverage should support yields") {
86+
compileCodeSnippet( """
87+
| object Yielder {
88+
| val holidays = for ( name <- Seq("sammy", "clint", "lee");
89+
| place <- Seq("london", "philly", "iowa") ) yield {
90+
| name + " has been to " + place
91+
| }
92+
| }""".stripMargin)
93+
assert(!reporter.hasErrors)
94+
// 2 statements for the two applies in Seq, one for each literal which is 6, one for the flat map,
95+
// one for the map, one for the yield op.
96+
assertNMeasuredStatements(11)
97+
}
98+
8399
test("scoverage should not instrument local macro implementation") {
84100
compileCodeSnippet( """
85101
| object MyMacro {

src/test/scala/scoverage/PluginRunner.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import java.io.{FileNotFoundException, File}
44
import scala.tools.nsc.transform.{TypingTransformers, Transform}
55
import java.net.URL
66
import scala.tools.nsc.plugins.PluginComponent
7-
import scala.tools.nsc.Global
7+
import scala.tools.nsc.{Phase, Global}
88
import scala.collection.mutable.ListBuffer
99

1010
/** @author Stephen Samuel */
@@ -19,6 +19,7 @@ trait PluginSupport {
1919
val s = new scala.tools.nsc.Settings
2020
s.Xprint.value = List("all")
2121
s.Yrangepos.value = true
22+
s.Yposdebug.value = true
2223
s.classpath.value = classPath.mkString(":")
2324
s
2425
}
@@ -94,8 +95,6 @@ class ScoverageAwareCompiler(settings: scala.tools.nsc.Settings, reporter: scala
9495

9596
class PositionValidator(val global: Global) extends PluginComponent with TypingTransformers with Transform {
9697

97-
val sources = new ListBuffer[String]
98-
9998
override val phaseName: String = "scoverage-validator"
10099
override val runsAfter: List[String] = List("typer")
101100
override val runsBefore = List[String]("scoverage-instrumentation")

0 commit comments

Comments
 (0)