Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test infrastructure for scope completion

Adds a new marker /*_*/ to trigger scope completion test.
Original type completion test oracles update for the tweaked output
  • Loading branch information...
commit 9c7c66ff7907e3ab814f0f4375eeaf6cdd230d5e 1 parent ab77f2a
Jason Zaugg retronym authored skyluc committed
2  src/interactive/scala/tools/nsc/interactive/tests/InteractiveTest.scala
View
@@ -61,7 +61,7 @@ abstract class InteractiveTest
* Override this member if you need to change the default set of executed test actions.
*/
protected lazy val testActions: ListBuffer[PresentationCompilerTestDef] = {
- ListBuffer(new CompletionAction(compiler), new TypeAction(compiler), new HyperlinkAction(compiler))
+ ListBuffer(new TypeCompletionAction(compiler), new ScopeCompletionAction(compiler), new TypeAction(compiler), new HyperlinkAction(compiler))
}
/** Add new presentation compiler actions to test. Presentation compiler's test
19 src/interactive/scala/tools/nsc/interactive/tests/core/AskCommand.scala
View
@@ -42,7 +42,7 @@ trait AskParse extends AskCommand {
import compiler.Tree
/** `sources` need to be entirely parsed before running the test
- * (else commands such as `AskCompletionAt` may fail simply because
+ * (else commands such as `AskTypeCompletionAt` may fail simply because
* the source's AST is not yet loaded).
*/
def askParse(sources: Seq[SourceFile]) {
@@ -72,10 +72,10 @@ trait AskReload extends AskCommand {
}
/** Ask the presentation compiler for completion at a given position. */
-trait AskCompletionAt extends AskCommand {
+trait AskTypeCompletionAt extends AskCommand {
import compiler.Member
- private[tests] def askCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
+ private[tests] def askTypeCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
reporter.println("\naskTypeCompletion at " + pos.source.file.name + ((pos.line, pos.column)))
ask {
@@ -84,6 +84,19 @@ trait AskCompletionAt extends AskCommand {
}
}
+/** Ask the presentation compiler for scope completion at a given position. */
+trait AskScopeCompletionAt extends AskCommand {
+ import compiler.Member
+
+ private[tests] def askScopeCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
+ reporter.println("\naskScopeCompletion at " + pos.source.file.name + ((pos.line, pos.column)))
+
+ ask {
+ compiler.askScopeCompletion(pos, _)
+ }
+ }
+}
+
/** Ask the presentation compiler for type info at a given position. */
trait AskTypeAt extends AskCommand {
import compiler.Tree
46 src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
View
@@ -12,16 +12,16 @@ private[tests] trait CoreTestDefs
/** Ask the presentation compiler for completion at all locations
* (in all sources) where the defined `marker` is found. */
- class CompletionAction(override val compiler: Global)
+ class TypeCompletionAction(override val compiler: Global)
extends PresentationCompilerTestDef
- with AskCompletionAt {
+ with AskTypeCompletionAt {
override def runTest() {
- askAllSources(CompletionMarker) { pos =>
- askCompletionAt(pos)
+ askAllSources(TypeCompletionMarker) { pos =>
+ askTypeCompletionAt(pos)
} { (pos, members) =>
withResponseDelimiter {
- reporter.println("[response] askCompletionAt " + format(pos))
+ reporter.println("[response] askTypeCompletion at " + format(pos))
// we skip getClass because it changed signature between 1.5 and 1.6, so there is no
// universal check file that we can provide for this to work
reporter.println("retrieved %d members".format(members.size))
@@ -34,6 +34,40 @@ private[tests] trait CoreTestDefs
}
}
+ /** Ask the presentation compiler for completion at all locations
+ * (in all sources) where the defined `marker` is found. */
+ class ScopeCompletionAction(override val compiler: Global)
+ extends PresentationCompilerTestDef
+ with AskScopeCompletionAt {
+
+ def memberPrinter(member: compiler.Member): String =
+ "[accessible: %5s] ".format(member.accessible) + "`" + (member.sym.toString() + member.tpe.toString()).trim() + "`"
+
+ override def runTest() {
+ askAllSources(ScopeCompletionMarker) { pos =>
+ askScopeCompletionAt(pos)
+ } { (pos, members) =>
+ withResponseDelimiter {
+ reporter.println("[response] askScopeCompletion at " + format(pos))
+ try {
+ // exclude members not from source (don't have position), for more focused and self contained tests.
+ def eligible(sym: compiler.Symbol) = sym.pos != compiler.NoPosition
+ val filtered = members.filter(member => eligible(member.sym))
+
+ reporter.println("retrieved %d members".format(filtered.size))
+ compiler ask { () =>
+ reporter.println(filtered.map(_.forceInfoString).sorted mkString "\n")
+ }
+ } catch {
+ case t: Throwable =>
+ t.printStackTrace()
+ }
+
+ }
+ }
+ }
+ }
+
/** Ask the presentation compiler for type info at all locations
* (in all sources) where the defined `marker` is found. */
class TypeAction(override val compiler: Global)
@@ -57,7 +91,7 @@ private[tests] trait CoreTestDefs
class HyperlinkAction(override val compiler: Global)
extends PresentationCompilerTestDef
with AskTypeAt
- with AskCompletionAt {
+ with AskTypeCompletionAt {
override def runTest() {
askAllSources(HyperlinkMarker) { pos =>
4 src/interactive/scala/tools/nsc/interactive/tests/core/TestMarker.scala
View
@@ -20,7 +20,9 @@ abstract case class TestMarker(marker: String) {
TestMarker.checkForDuplicate(this)
}
-object CompletionMarker extends TestMarker("/*!*/")
+object TypeCompletionMarker extends TestMarker("/*!*/")
+
+object ScopeCompletionMarker extends TestMarker("/*_*/")
object TypeMarker extends TestMarker("/*?*/")
2  test/files/presentation/callcc-interpreter.check
View
@@ -2,7 +2,7 @@ reload: CallccInterpreter.scala
askTypeCompletion at CallccInterpreter.scala(51,38)
================================================================================
-[response] askCompletionAt (51,38)
+[response] askTypeCompletion at (51,38)
retrieved 59 members
abstract trait Term extends AnyRef
abstract trait Value extends AnyRef
2  test/files/presentation/completion-implicit-chained.check
View
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(11,16)
================================================================================
-[response] askCompletionAt (11,16)
+[response] askTypeCompletion at (11,16)
retrieved 24 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
2  test/files/presentation/ide-bug-1000349.check
View
@@ -2,7 +2,7 @@ reload: CompletionOnEmptyArgMethod.scala
askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17)
================================================================================
-[response] askCompletionAt (2,17)
+[response] askTypeCompletion at (2,17)
retrieved 32 members
def +(other: String): String
def ->[B](y: B): (Foo, B)
6 test/files/presentation/ide-bug-1000475.check
View
@@ -2,7 +2,7 @@ reload: Foo.scala
askTypeCompletion at Foo.scala(3,7)
================================================================================
-[response] askCompletionAt (3,7)
+[response] askTypeCompletion at (3,7)
retrieved 31 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
@@ -36,7 +36,7 @@ final def wait(x$1: Long,x$2: Int): Unit
askTypeCompletion at Foo.scala(6,10)
================================================================================
-[response] askCompletionAt (6,10)
+[response] askTypeCompletion at (6,10)
retrieved 31 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
@@ -70,7 +70,7 @@ final def wait(x$1: Long,x$2: Int): Unit
askTypeCompletion at Foo.scala(7,7)
================================================================================
-[response] askCompletionAt (7,7)
+[response] askTypeCompletion at (7,7)
retrieved 31 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
2  test/files/presentation/ide-bug-1000531.check
View
@@ -2,7 +2,7 @@ reload: CrashOnLoad.scala
askTypeCompletion at CrashOnLoad.scala(6,12)
================================================================================
-[response] askCompletionAt (6,12)
+[response] askTypeCompletion at (6,12)
retrieved 120 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
2  test/files/presentation/implicit-member.check
View
@@ -2,7 +2,7 @@ reload: ImplicitMember.scala
askTypeCompletion at ImplicitMember.scala(7,7)
================================================================================
-[response] askCompletionAt (7,7)
+[response] askTypeCompletion at (7,7)
retrieved 34 members
def +(other: String): String
def ->[B](y: B): (Implicit.type, B)
4 test/files/presentation/ping-pong.check
View
@@ -2,7 +2,7 @@ reload: PingPong.scala
askTypeCompletion at PingPong.scala(10,23)
================================================================================
-[response] askCompletionAt (10,23)
+[response] askTypeCompletion at (10,23)
retrieved 35 members
[inaccessible] private[this] val ping: Ping
[inaccessible] protected[package lang] def clone(): Object
@@ -39,7 +39,7 @@ private[this] val name: String
askTypeCompletion at PingPong.scala(19,20)
================================================================================
-[response] askCompletionAt (19,20)
+[response] askTypeCompletion at (19,20)
retrieved 35 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
12 test/files/presentation/t1207.check
View
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(10,15)
================================================================================
-[response] askCompletionAt (10,15)
+[response] askTypeCompletion at (10,15)
retrieved 3 members
final package bongo
final package lang
@@ -11,7 +11,7 @@ final package util
askTypeCompletion at Completions.scala(11,16)
================================================================================
-[response] askCompletionAt (11,16)
+[response] askTypeCompletion at (11,16)
retrieved 3 members
final package bongo
final package lang
@@ -20,7 +20,7 @@ final package util
askTypeCompletion at Completions.scala(12,19)
================================================================================
-[response] askCompletionAt (12,19)
+[response] askTypeCompletion at (12,19)
retrieved 3 members
final package bongo
final package lang
@@ -29,7 +29,7 @@ final package util
askTypeCompletion at Completions.scala(13,19)
================================================================================
-[response] askCompletionAt (13,19)
+[response] askTypeCompletion at (13,19)
retrieved 3 members
final package bongo
final package lang
@@ -38,7 +38,7 @@ final package util
askTypeCompletion at Completions.scala(14,23)
================================================================================
-[response] askCompletionAt (14,23)
+[response] askTypeCompletion at (14,23)
retrieved 3 members
final package bongo
final package lang
@@ -47,7 +47,7 @@ final package util
askTypeCompletion at Completions.scala(15,10)
================================================================================
-[response] askCompletionAt (15,10)
+[response] askTypeCompletion at (15,10)
retrieved 0 members
================================================================================
2  test/files/presentation/t5708.check
View
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(17,9)
================================================================================
-[response] askCompletionAt (17,9)
+[response] askTypeCompletion at (17,9)
retrieved 39 members
[inaccessible] private def privateM: String
[inaccessible] private[this] val privateV: String
10 test/files/presentation/visibility.check
View
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(14,12)
================================================================================
-[response] askCompletionAt (14,12)
+[response] askTypeCompletion at (14,12)
retrieved 37 members
[inaccessible] private[this] def secretPrivateThis(): Unit
def +(other: String): String
@@ -42,7 +42,7 @@ protected[package lang] def finalize(): Unit
askTypeCompletion at Completions.scala(16,11)
================================================================================
-[response] askCompletionAt (16,11)
+[response] askTypeCompletion at (16,11)
retrieved 37 members
def +(other: String): String
def ->[B](y: B): (accessibility.Foo, B)
@@ -82,7 +82,7 @@ protected[package lang] def finalize(): Unit
askTypeCompletion at Completions.scala(22,11)
================================================================================
-[response] askCompletionAt (22,11)
+[response] askTypeCompletion at (22,11)
retrieved 37 members
[inaccessible] private def secretPrivate(): Unit
def +(other: String): String
@@ -122,7 +122,7 @@ protected[package lang] def finalize(): Unit
askTypeCompletion at Completions.scala(28,10)
================================================================================
-[response] askCompletionAt (28,10)
+[response] askTypeCompletion at (28,10)
retrieved 37 members
[inaccessible] private def secretPrivate(): Unit
[inaccessible] private[this] def secretPrivateThis(): Unit
@@ -162,7 +162,7 @@ protected[package accessibility] def secretProtectedInPackage(): Unit
askTypeCompletion at Completions.scala(37,8)
================================================================================
-[response] askCompletionAt (37,8)
+[response] askTypeCompletion at (37,8)
retrieved 37 members
[inaccessible] private def secretPrivate(): Unit
[inaccessible] private[this] def secretPrivateThis(): Unit
Please sign in to comment.
Something went wrong with that request. Please try again.