scala.tools.nsc.interactive.tests

InteractiveTest

abstract class InteractiveTest extends AnyRef

A base class for writing interactive compiler tests.

This class tries to cover common functionality needed when testing the presentation compiler: instantiation source files, reloading, creating positions, instantiating the presentation compiler, random stress testing.

By default, this class loads all classes found under src/. They are found in sourceFiles. Positions can be created using pos(file, line, col). The presentation compiler is available through compiler.

It is easy to test member completion and type at a given position. Source files are searched for /markers/. By default, the completion marker is /*!*/ and the typedAt marker is /*?*/. Place these markers in your source files, and call completionTests and typedAtTests to print the results at all these positions. Sources are reloaded by reloadSources (blocking call). All ask operations are placed on the work queue without waiting for each one to complete before asking the next. After all asks, it waits for each response in turn and prints the result. The default timout is 5 seconds per operation.

The same mechanism can be used for custom operations. Use askAllSources(marker)(f)(g). Give your custom marker, and provide the two functions: one for creating the request, and the second for processing the response, if it didn't time out and there was no error.

Source
InteractiveTest.scala
See also

Check existing tests under test/files/presentation

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. InteractiveTest
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new InteractiveTest()

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. val TIMEOUT: Int

  7. def allPositionsOf(sources: Seq[SourceFile] = sourceFiles, str: String): Map[SourceFile, Seq[Position]]

    All positions of the given string in all source files.

  8. val argsString: String

    If there's a file ending in .

    If there's a file ending in .opts, read it and parse it for cmd line arguments.

  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def askAllSources[T]: (String) ⇒ ((Position) ⇒ Response[T]) ⇒ ((Position, T) ⇒ Unit) ⇒ Unit

  11. def askAllSourcesAsync[T](marker: String)(askAt: (Position) ⇒ Response[T])(f: (Position, T) ⇒ Unit): Unit

    Perform an operation on all sources at all positions that match the given marker string.

    Perform an operation on all sources at all positions that match the given marker string. For instance, askAllSources("/*!*/)(askTypeAt)(println) would ask the tyep at all positions marked with /*!*/and println the result.

  12. def askAllSourcesSync[T](marker: String)(askAt: (Position) ⇒ Response[T])(f: (Position, T) ⇒ Unit): Unit

    Synchronous version of askAllSources.

    Synchronous version of askAllSources. Each position is treated in turn, waiting for the response before going to the next one.

  13. val baseDir: Path

    The base directory for this test, usually a subdirectory of "test/files/presentation/"

  14. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  15. lazy val compiler: Global

  16. val completionMarker: String

  17. def completionTests(): Unit

    Ask completion for all marked positions in all sources.

    Ask completion for all marked positions in all sources. A completion position is marked with /*!*/

  18. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  20. def filesInDir(dir: Path): Iterator[Path]

  21. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  22. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  24. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  25. def main(args: Array[String]): Unit

  26. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  29. val outDir: Path

    The root directory for this test suite, usually the test kind ("test/files/presentation").

  30. def pos(file: SourceFile, line: Int, col: Int): Position

  31. def positionsOf(source: SourceFile, str: String): Seq[Position]

    Return all positions of the given str in the given source file.

  32. def prepareSettings(): Unit

    Prepare the settings object.

    Prepare the settings object. Load the .opts file and adjust all paths from the Unix-like syntax to the platform specific syntax. This is necessary so that a single .opts file can be used on all platforms.

    Note

    Bootclasspath is treated specially. If there is a -bootclasspath option in the file, the 'usejavacp' setting is set to false. This ensures that the bootclasspath takes precedence over the scala-library used to run the current test.

  33. def printClassPath(): Unit

    Attributes
    protected
  34. def randomTests(n: Int, files: Array[SourceFile]): Unit

    Perform n random tests with random changes.

  35. def reloadSources(sources: Seq[SourceFile] = sourceFiles): Unit

    Reload the given source files and wait for them to be reloaded.

  36. val reporter: StoreReporter

  37. val runRandomTests: Boolean

  38. def runTest(): Unit

  39. val settings: Settings

  40. def showPos(pos: Position): String

    Return the filename:line:col version of this position.

  41. def source(filename: String): SourceFile

  42. def source(file: Path): BatchSourceFile

  43. val sourceDir: String

    Where source files are placed.

  44. lazy val sourceFiles: Array[SourceFile]

    All .

    All .scala files below "src" directory.

  45. def sources(filename: String*): Seq[SourceFile]

  46. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  47. val synchronousRequests: Boolean

    Should askAllSources wait for each ask to finish before issueing the next?

  48. def toString(): String

    Definition Classes
    AnyRef → Any
  49. def typeAtTests(): Unit

    Ask for typedAt for all marker positions in all sources.

  50. val typedAtMarker: String

  51. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  52. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  53. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  54. def withResponse[T](pos: Position, response: Response[T])(f: (Position, T) ⇒ Unit): Unit

    Attributes
    protected

Inherited from AnyRef

Inherited from Any