File: Test.scala

package info (click to toggle)
scala 2.11.12-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 62,924 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,135; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (28 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import scala.tools.nsc.interactive.tests.InteractiveTest
import scala.reflect.internal.util.SourceFile
import scala.tools.nsc.interactive.Response

object Test extends InteractiveTest {
  override def execute(): Unit = {
    val sourceA = loadSourceAndWaitUntilTypechecked("A.scala")
    checkPresent(sourceA)
  }

  private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = {
    val sourceFile = sourceFiles.find(_.file.name == sourceName).head
    askLoadedTyped(sourceFile).get
    /* The response to `askLoadedType` may return before `interactive.Global.waitLoadedType`
     * fully executes. Because this test expects `waitLoadedType` is fully executed before
     * calling `checkPresent`, with the below no-op presentation compiler request we make
     * sure this requirement is fulfilled.
     */
    compiler.askForResponse(() => ()).get
    sourceFile
  }

  private def checkPresent(source: SourceFile): Unit = compiler.getUnitOf(source) match {
    case Some(unit) => reporter.println("Compilation Unit for " + source.file.name + " still loaded after askLoadedTyped")

    case None => reporter.println("Test OK")
  }
}