Permalink
Browse files

[nomaster] Test infrastructure for scope completion

Adds a new marker /*_*/ to trigger scope completion test.
Original type completion test oracles update for the tweaked output
(cherry picked from commit 9c7c66f)
  • Loading branch information...
1 parent b9f6860 commit 3a8796da1a321b5b7bb547c3c0cd9f62b5d0279d @retronym retronym committed with skyluc Nov 6, 2013
@@ -69,7 +69,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
@@ -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
@@ -13,19 +13,19 @@ 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 {
def memberPrinter(member: compiler.Member): String =
"[accessible: %5s] ".format(member.accessible) + "`" + (member.sym.toString() + member.tpe.toString()).trim() + "`"
override def runTest() {
- askAllSources(CompletionMarker) { pos =>
- askCompletionAt(pos)
+ askAllSources(TypeCompletionMarker) { pos =>
+ askTypeCompletionAt(pos)
} { (pos, members) =>
withResponseDelimiter {
- reporter.println("[response] aksTypeCompletion at " + 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))
@@ -38,6 +38,39 @@ 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 focussed 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(memberPrinter).sortBy(_.toString()).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)
@@ -61,7 +94,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 =>
@@ -97,4 +130,4 @@ private[tests] trait CoreTestDefs
}
}
}
-}
+}
@@ -20,7 +20,9 @@ abstract case class TestMarker(val marker: String) {
TestMarker.checkForDuplicate(this)
}
-object CompletionMarker extends TestMarker("/*!*/")
+object TypeCompletionMarker extends TestMarker("/*!*/")
+
+object ScopeCompletionMarker extends TestMarker("/*_*/")
object TypeMarker extends TestMarker("/*?*/")
@@ -2,7 +2,7 @@ reload: CallccInterpreter.scala
askTypeCompletion at CallccInterpreter.scala(51,38)
================================================================================
-[response] aksTypeCompletion at (51,38)
+[response] askTypeCompletion at (51,38)
retrieved 64 members
[accessible: true] `class AddcallccInterpreter.Add`
[accessible: true] `class AppcallccInterpreter.App`
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(11,16)
================================================================================
-[response] aksTypeCompletion at (11,16)
+[response] askTypeCompletion at (11,16)
retrieved 24 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -2,7 +2,7 @@ reload: CompletionOnEmptyArgMethod.scala
askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17)
================================================================================
-[response] aksTypeCompletion at (2,17)
+[response] askTypeCompletion at (2,17)
retrieved 37 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -2,7 +2,7 @@ reload: Foo.scala
askTypeCompletion at Foo.scala(3,7)
================================================================================
-[response] aksTypeCompletion at (3,7)
+[response] askTypeCompletion at (3,7)
retrieved 36 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -40,7 +40,7 @@ retrieved 36 members
askTypeCompletion at Foo.scala(6,10)
================================================================================
-[response] aksTypeCompletion at (6,10)
+[response] askTypeCompletion at (6,10)
retrieved 36 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -78,7 +78,7 @@ retrieved 36 members
askTypeCompletion at Foo.scala(7,7)
================================================================================
-[response] aksTypeCompletion at (7,7)
+[response] askTypeCompletion at (7,7)
retrieved 36 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -2,7 +2,7 @@ reload: CrashOnLoad.scala
askTypeCompletion at CrashOnLoad.scala(6,12)
================================================================================
-[response] aksTypeCompletion at (6,12)
+[response] askTypeCompletion at (6,12)
retrieved 126 members
[accessible: true] `class GroupedIteratorIterator[B]#GroupedIterator`
[accessible: true] `method !=(x$1: Any)Boolean`
@@ -2,7 +2,7 @@ reload: ImplicitMember.scala
askTypeCompletion at ImplicitMember.scala(7,7)
================================================================================
-[response] aksTypeCompletion at (7,7)
+[response] askTypeCompletion at (7,7)
retrieved 39 members
[accessible: true] `class AppliedImplicitImplicit.AppliedImplicit`
[accessible: true] `method !=(x$1: Any)Boolean`
@@ -2,7 +2,7 @@ reload: PingPong.scala
askTypeCompletion at PingPong.scala(10,23)
================================================================================
-[response] aksTypeCompletion at (10,23)
+[response] askTypeCompletion at (10,23)
retrieved 40 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -43,7 +43,7 @@ retrieved 40 members
askTypeCompletion at PingPong.scala(19,20)
================================================================================
-[response] aksTypeCompletion at (19,20)
+[response] askTypeCompletion at (19,20)
retrieved 40 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(17,9)
================================================================================
-[response] aksTypeCompletion at (17,9)
+[response] askTypeCompletion at (17,9)
retrieved 44 members
[accessible: true] `lazy value fooInt`
[accessible: true] `method !=(x$1: Any)Boolean`
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(14,12)
================================================================================
-[response] aksTypeCompletion at (14,12)
+[response] askTypeCompletion at (14,12)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -46,7 +46,7 @@ retrieved 42 members
askTypeCompletion at Completions.scala(16,11)
================================================================================
-[response] aksTypeCompletion at (16,11)
+[response] askTypeCompletion at (16,11)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -90,7 +90,7 @@ retrieved 42 members
askTypeCompletion at Completions.scala(22,11)
================================================================================
-[response] aksTypeCompletion at (22,11)
+[response] askTypeCompletion at (22,11)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -134,7 +134,7 @@ retrieved 42 members
askTypeCompletion at Completions.scala(28,10)
================================================================================
-[response] aksTypeCompletion at (28,10)
+[response] askTypeCompletion at (28,10)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`
@@ -178,7 +178,7 @@ retrieved 42 members
askTypeCompletion at Completions.scala(37,8)
================================================================================
-[response] aksTypeCompletion at (37,8)
+[response] askTypeCompletion at (37,8)
retrieved 42 members
[accessible: true] `method !=(x$1: Any)Boolean`
[accessible: true] `method !=(x$1: AnyRef)Boolean`

0 comments on commit 3a8796d

Please sign in to comment.