Packages

c

scala.tools.nsc.interactive.tests

InteractiveTest

abstract class InteractiveTest extends AskParse with AskShutdown with AskReload with AskLoadedTyped with PresentationCompilerInstance with CoreTestDefs with InteractiveTestSettings

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 scala and java classes found under src/, going recursively into subfolders. Loaded classes are found in sourceFiles. trait TestResources The presentation compiler is available through compiler.

It is easy to test member completion, type and hyperlinking at a given position. Source files are searched for TextMarkers. By default, the completion marker is /*!*/, the typedAt marker is /*?*/ and the hyperlinking marker is /*#*/. Place these markers in your source files, and the test framework will automatically pick them up and test the corresponding actions. Sources are reloaded by askReload(sourceFiles) (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 timeout is 1 second per operation.

To define a custom operation you have to:

(1) Define a new marker by extending TestMarker (2) Provide an implementation for the operation you want to check by extending PresentationCompilerTestDef (3) Add the class defined in (1) to the set of executed test actions by calling ++ on InteractiveTest.

Then you can simply use the new defined marker in your test sources and the testing framework will automatically pick it up.

Self Type
InteractiveTest
Source
InteractiveTest.scala
See also

Check existing tests under test/files/presentation

Linear Supertypes
InteractiveTestSettings, CoreTestDefs, PresentationCompilerRequestsWorkingMode, TestResources, PresentationCompilerInstance, TestSettings, AskLoadedTyped, AskReload, AskShutdown, AskParse, AskCommand, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. InteractiveTest
  2. InteractiveTestSettings
  3. CoreTestDefs
  4. PresentationCompilerRequestsWorkingMode
  5. TestResources
  6. PresentationCompilerInstance
  7. TestSettings
  8. AskLoadedTyped
  9. AskReload
  10. AskShutdown
  11. AskParse
  12. AskCommand
  13. AnyRef
  14. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new InteractiveTest()

Type Members

  1. class HyperlinkAction extends PresentationCompilerTestDef with AskTypeAt with AskTypeCompletionAt

    Ask the presentation compiler for hyperlink at all locations (in all sources) where the defined marker is found.

    Ask the presentation compiler for hyperlink at all locations (in all sources) where the defined marker is found.

    Definition Classes
    CoreTestDefs
  2. class ScopeCompletionAction extends PresentationCompilerTestDef with AskScopeCompletionAt

    Ask the presentation compiler for completion at all locations (in all sources) where the defined marker is found.

    Ask the presentation compiler for completion at all locations (in all sources) where the defined marker is found.

    Definition Classes
    CoreTestDefs
  3. class TypeAction extends PresentationCompilerTestDef with AskTypeAt

    Ask the presentation compiler for type info at all locations (in all sources) where the defined marker is found.

    Ask the presentation compiler for type info at all locations (in all sources) where the defined marker is found.

    Definition Classes
    CoreTestDefs
  4. class TypeCompletionAction extends PresentationCompilerTestDef with AskTypeCompletionAt

    Ask the presentation compiler for completion at all locations (in all sources) where the defined marker is found.

    Ask the presentation compiler for completion at all locations (in all sources) where the defined marker is found.

    Definition Classes
    CoreTestDefs

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from InteractiveTest to any2stringadd[InteractiveTest] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ++(tests: PresentationCompilerTestDef*): Unit

    Add new presentation compiler actions to test.

    Add new presentation compiler actions to test. Presentation compiler's test need to extends trait PresentationCompilerTestDef.

    Attributes
    protected
  5. def ->[B](y: B): (InteractiveTest, B)
    Implicit
    This member is added by an implicit conversion from InteractiveTest to ArrowAssoc[InteractiveTest] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  7. final val TIMEOUT: Int(30000)
    Attributes
    protected
    Definition Classes
    TestSettings
  8. val argsString: String

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

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

    Attributes
    protected
    Definition Classes
    InteractiveTestSettings
  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def ask[T](op: (Response[T]) ⇒ Unit): Response[T]

    Presentation compiler's askXXX actions work by doing side-effects on a Response instance passed as an argument during the askXXX call.

    Presentation compiler's askXXX actions work by doing side-effects on a Response instance passed as an argument during the askXXX call. The defined method ask is meant to encapsulate this behavior.

    Attributes
    protected
    Definition Classes
    AskCommand
  11. def askAllSources[T]: (TestMarker) ⇒ ((Position) ⇒ Response[T]) ⇒ ((Position, T) ⇒ Unit) ⇒ Unit
    Attributes
    protected
    Definition Classes
    PresentationCompilerRequestsWorkingMode
  12. def askLoadedTyped(source: SourceFile, keepLoaded: Boolean = false)(implicit reporter: Reporter): Response[Global.Tree]
    Attributes
    protected
    Definition Classes
    AskLoadedTyped
  13. def askParse(sources: Seq[SourceFile]): Unit

    sources need to be entirely parsed before running the test (else commands such as AskTypeCompletionAt may fail simply because the source's AST is not yet loaded).

    sources need to be entirely parsed before running the test (else commands such as AskTypeCompletionAt may fail simply because the source's AST is not yet loaded).

    Definition Classes
    AskParse
  14. def askReload(sources: Seq[SourceFile])(implicit reporter: Reporter): Response[Unit]

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

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

    Attributes
    protected
    Definition Classes
    AskReload
  15. def askShutdown(): Unit
    Definition Classes
    AskShutdown
  16. val baseDir: Path

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

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

    Attributes
    protected
    Definition Classes
    TestSettings
  17. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  18. lazy val compiler: Global
    Attributes
    protected
    Definition Classes
    PresentationCompilerInstance
  19. val compilerReporter: Reporter
    Attributes
    protected
    Definition Classes
    PresentationCompilerInstance
  20. def createGlobal: Global
    Attributes
    protected
    Definition Classes
    PresentationCompilerInstance
  21. def ensuring(cond: (InteractiveTest) ⇒ Boolean, msg: ⇒ Any): InteractiveTest
    Implicit
    This member is added by an implicit conversion from InteractiveTest to Ensuring[InteractiveTest] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  22. def ensuring(cond: (InteractiveTest) ⇒ Boolean): InteractiveTest
    Implicit
    This member is added by an implicit conversion from InteractiveTest to Ensuring[InteractiveTest] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  23. def ensuring(cond: Boolean, msg: ⇒ Any): InteractiveTest
    Implicit
    This member is added by an implicit conversion from InteractiveTest to Ensuring[InteractiveTest] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  24. def ensuring(cond: Boolean): InteractiveTest
    Implicit
    This member is added by an implicit conversion from InteractiveTest to Ensuring[InteractiveTest] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  25. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  27. def execute(): Unit
    Attributes
    protected
  28. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  29. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  30. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  31. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  32. def loadSources(): Unit

    Load all sources before executing the test.

    Load all sources before executing the test.

    Attributes
    protected
  33. def main(args: Array[String]): Unit

    Test's entry point

  34. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  35. def normalize(s: String): String
    Attributes
    protected
  36. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  37. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  38. val outDir: Path

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

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

    Attributes
    protected
    Definition Classes
    TestSettings
  39. def prepareSettings(settings: Settings): 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.

    Attributes
    protected
    Definition Classes
    InteractiveTestSettings → PresentationCompilerInstance
    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.

  40. def printClassPath(implicit reporter: Reporter): Unit
    Attributes
    protected
    Definition Classes
    InteractiveTestSettings → PresentationCompilerInstance
  41. implicit val reporter: Reporter
    Attributes
    protected
    Definition Classes
    TestSettings
  42. def runDefaultTests(): Unit

    Run all defined PresentationCompilerTestDef

    Run all defined PresentationCompilerTestDef

    Attributes
    protected
  43. val runRandomTests: Boolean
    Attributes
    protected
  44. val settings: Settings
    Attributes
    protected
    Definition Classes
    PresentationCompilerInstance
  45. val sourceDir: String

    Where source files are placed.

    Where source files are placed.

    Attributes
    protected
    Definition Classes
    TestSettings
  46. lazy val sourceFiles: Array[SourceFile]

    collected source files that are to be used by the test runner

    collected source files that are to be used by the test runner

    Attributes
    protected
    Definition Classes
    TestResources
  47. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  48. val synchronousRequests: Boolean

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

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

    Attributes
    protected
    Definition Classes
    InteractiveTestPresentationCompilerRequestsWorkingMode
  49. lazy val testActions: ListBuffer[PresentationCompilerTestDef]

    The core set of test actions that are executed during each test run are CompletionAction, TypeAction and HyperlinkAction.

    The core set of test actions that are executed during each test run are CompletionAction, TypeAction and HyperlinkAction. Override this member if you need to change the default set of executed test actions.

    Attributes
    protected
  50. def toString(): String
    Definition Classes
    AnyRef → Any
  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( ... ) @native()
  54. def [B](y: B): (InteractiveTest, B)
    Implicit
    This member is added by an implicit conversion from InteractiveTest to ArrowAssoc[InteractiveTest] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Deprecated Value Members

  1. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from InteractiveTest to StringFormat[InteractiveTest] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.12.16) Use formatString.format(value) instead of value.formatted(formatString), or use the f"" string interpolator. In Java 15 and later, formatted resolves to the new method in String which has reversed parameters.

Inherited from InteractiveTestSettings

Inherited from CoreTestDefs

Inherited from TestResources

Inherited from PresentationCompilerInstance

Inherited from TestSettings

Inherited from AskLoadedTyped

Inherited from AskReload

Inherited from AskShutdown

Inherited from AskParse

Inherited from AskCommand

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from InteractiveTest to any2stringadd[InteractiveTest]

Inherited by implicit conversion StringFormat from InteractiveTest to StringFormat[InteractiveTest]

Inherited by implicit conversion Ensuring from InteractiveTest to Ensuring[InteractiveTest]

Inherited by implicit conversion ArrowAssoc from InteractiveTest to ArrowAssoc[InteractiveTest]

Ungrouped