summaryrefslogtreecommitdiff
path: root/test/files/presentation
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-12-13 11:14:25 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-12-13 11:14:25 -0800
commitf8b56c86a4625e032198b5104e71be7a4d101fab (patch)
tree8f264815c20e5021ad202bc77c6192a7f82de636 /test/files/presentation
parentf1131b60a2f8cd4cafc42073ee1f2f4bdd0c983d (diff)
parent760df9843a910d6c3618e490c752eb03fb6924bd (diff)
downloadscala-f8b56c86a4625e032198b5104e71be7a4d101fab.tar.gz
scala-f8b56c86a4625e032198b5104e71be7a4d101fab.tar.bz2
scala-f8b56c86a4625e032198b5104e71be7a4d101fab.zip
Merge pull request #3262 from densh/si/8030
SI-8030 force symbols on presentation compiler initialization
Diffstat (limited to 'test/files/presentation')
-rw-r--r--test/files/presentation/ide-t1001326.check4
-rw-r--r--test/files/presentation/ide-t1001326/src/a/A.scala5
-rw-r--r--test/files/presentation/parse-invariants.check5
-rw-r--r--test/files/presentation/parse-invariants/Test.scala (renamed from test/files/presentation/ide-t1001326/Test.scala)32
-rw-r--r--test/files/presentation/parse-invariants/src/a/A.scala138
5 files changed, 167 insertions, 17 deletions
diff --git a/test/files/presentation/ide-t1001326.check b/test/files/presentation/ide-t1001326.check
deleted file mode 100644
index 0ac15faed4..0000000000
--- a/test/files/presentation/ide-t1001326.check
+++ /dev/null
@@ -1,4 +0,0 @@
-Unique OK
-Unattributed OK
-NeverModify OK
-AlwaysParseTree OK \ No newline at end of file
diff --git a/test/files/presentation/ide-t1001326/src/a/A.scala b/test/files/presentation/ide-t1001326/src/a/A.scala
deleted file mode 100644
index c82ca02231..0000000000
--- a/test/files/presentation/ide-t1001326/src/a/A.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package a
-
-class A {
- def foo(s: String) = s + s
-} \ No newline at end of file
diff --git a/test/files/presentation/parse-invariants.check b/test/files/presentation/parse-invariants.check
new file mode 100644
index 0000000000..32e9c846ab
--- /dev/null
+++ b/test/files/presentation/parse-invariants.check
@@ -0,0 +1,5 @@
+NoNewSymbolsEntered OK
+Unique OK
+Unattributed OK
+NeverModify OK
+AlwaysParseTree OK
diff --git a/test/files/presentation/ide-t1001326/Test.scala b/test/files/presentation/parse-invariants/Test.scala
index ff63b9770a..128896ccaa 100644
--- a/test/files/presentation/ide-t1001326/Test.scala
+++ b/test/files/presentation/parse-invariants/Test.scala
@@ -6,16 +6,32 @@ object Test extends InteractiveTest {
override def execute(): Unit = {
val sf = sourceFiles.find(_.file.name == "A.scala").head
- uniqueParseTree_t1001326(sf)
- unattributedParseTree_t1001326(sf)
- neverModifyParseTree_t1001326(sf)
- shouldAlwaysReturnParseTree_t1001326(sf)
+ noNewSymbols(sf)
+ uniqueParseTree(sf)
+ unattributedParseTree(sf)
+ neverModifyParseTree(sf)
+ shouldAlwaysReturnParseTree(sf)
+ }
+
+ /**
+ * Asking for a parseTree should not enter any new symbols.
+ */
+ private def noNewSymbols(sf: SourceFile) {
+ def nextId() = compiler.NoSymbol.newTermSymbol(compiler.TermName("dummy"), compiler.NoPosition, compiler.NoFlags).id
+ val id = nextId()
+ val tree = compiler.parseTree(sf)
+ val id2 = nextId()
+ if (id2 == id + 1) {
+ reporter.println("NoNewSymbolsEntered OK")
+ } else {
+ reporter.println("NoNewSymbolsEntered FAILED")
+ }
}
/**
* Asking twice for a parseTree on the same source should always return a new tree
*/
- private def uniqueParseTree_t1001326(sf: SourceFile) {
+ private def uniqueParseTree(sf: SourceFile) {
val parseTree1 = compiler.parseTree(sf)
val parseTree2 = compiler.parseTree(sf)
if (parseTree1 != parseTree2) {
@@ -28,7 +44,7 @@ object Test extends InteractiveTest {
/**
* A parseTree should never contain any symbols or types
*/
- private def unattributedParseTree_t1001326(sf: SourceFile) {
+ private def unattributedParseTree(sf: SourceFile) {
if (noSymbolsOrTypes(compiler.parseTree(sf))) {
reporter.println("Unattributed OK")
} else {
@@ -39,7 +55,7 @@ object Test extends InteractiveTest {
/**
* Once you have obtained a parseTree it should never change
*/
- private def neverModifyParseTree_t1001326(sf: SourceFile) {
+ private def neverModifyParseTree(sf: SourceFile) {
val parsedTree = compiler.parseTree(sf)
loadSourceAndWaitUntilTypechecked(sf)
if (noSymbolsOrTypes(parsedTree)) {
@@ -52,7 +68,7 @@ object Test extends InteractiveTest {
/**
* Should always return a parse tree
*/
- private def shouldAlwaysReturnParseTree_t1001326(sf: SourceFile) {
+ private def shouldAlwaysReturnParseTree(sf: SourceFile) {
loadSourceAndWaitUntilTypechecked(sf)
if (noSymbolsOrTypes(compiler.parseTree(sf))) {
reporter.println("AlwaysParseTree OK")
diff --git a/test/files/presentation/parse-invariants/src/a/A.scala b/test/files/presentation/parse-invariants/src/a/A.scala
new file mode 100644
index 0000000000..1ae78cad05
--- /dev/null
+++ b/test/files/presentation/parse-invariants/src/a/A.scala
@@ -0,0 +1,138 @@
+package syntax
+
+object Terms {
+ object Literals {
+ 0
+ 0l
+ 0f
+ 0d
+ 0xb33f
+ 'c'
+ "string"
+ """
+ multi-line
+ string
+ """
+ 'symbol
+ true
+ false
+ null
+ ()
+ }
+
+ object Patterns {
+ 0 match { case 0 => }
+ 1 match { case (0 | 1) => }
+ 2 match { case _: Int => }
+ 3 match { case _ => }
+ Some(0) match { case Some(0) => }
+ Some(0) match { case name @ Some(_) => }
+ Some(Some(0)) match { case nested @ Some(deeper @ Some(_)) => }
+ List(1, 2, 3) match { case unapplySeq @ List(1, 2, _*) => }
+ 0 match { case i if i > 0 => }
+ List(1) match { case _: List[t] => List.empty[t] }
+ }
+
+ object New {
+ class Foo
+ trait Bar
+ new Foo
+ new Foo { selfie => }
+ new Foo with Bar
+ new { val early = 1 } with Bar
+ new { val name = "anon "}
+ }
+
+ def tuple = (1, 'two, "three")
+ def lambda = (x: Int, y: Int) => x + y
+ def lambda2 = (_: Int) + (_: Int)
+ def blocks = { { {}; {} }; {} }
+ def ascription = (1: Int)
+ def select = Nil.size
+ def method1 = "s".replace("foo", "bar")
+ def method2 = "s" + "s"
+ def method3 = Nil.foreach { e => }
+ def method4 = 1 :: 2 :: 3 :: Nil
+ def if1 = if (true) true else false
+ def if2 = if (true) true
+ def `return`: Int = { return 0 }
+ def `throw` = throw new Exception
+ def `match` = 0 match { case 0 => case _ => }
+ def `try` = try 0 catch { case _ => } finally 0
+ def `while` = while(true) 0
+ def `do while` = do 0 while(true)
+ def `for` = for (i <- 1 to 10; if i % 2 == 0; j = i + 1) j
+ def `for yield` = for (a <- List(List(1)); b <- a; c = b * 2) yield b
+ def interpolation = s"$tuple and maybe also $blocks"
+ def assign = { var x = 1; x = 2 }
+ def assign2 = { object o { var x = 1 }; o.x = 2 }
+ def update = { val v = collection.mutable.Seq(1); v(0) = 2 }
+ def `this` = this
+}
+
+object Types {
+ type Reference = scala.App
+ type Tuple = (Int, String, Double)
+ type Function = (Int, String) => Double
+ type Refined = Int { val meta: Any }
+ type Lambda = ({ type F[T] = List[T] })#F[_]
+ type Infix = Int Either String
+ type Application = List[Int]
+ type Existential = List[T] forSome { type T }
+ object O { type T = Int }
+ type Dependent = O.T
+ class O { type T = Int }
+ type Selection = O#T
+}
+
+object Definitions {
+ private val x1 = 0
+ private[this] val x2 = 0
+ private[Definitions] val x3 = 0
+ protected val x4 = 0
+ protected[AcessManagement] val x5 = 0
+ val x1 = 1
+ val x2: Int = 1
+ val x3, y3 = 1
+ lazy val x4 = 1
+ implicit val x5 = 1
+ final val x6 = 1
+ lazy final val x7 = 1
+ val Some(x8) = Some(0)
+ var x9 = 1
+ var x10, y10 = 1
+ var x11: Int = 1
+
+ implicit def implicitView: Option[Int] = None
+ def implicitArg1(implicit i: Int) = i + 2
+ def implicitArg2[T: Fooable] = implicitly[Fooable[T]]
+ def bound1[T <: Int](x: T): T = x
+ def bound2[T >: Any](x: T): T = x
+ def bound3[T <% Int](x: T): Int = x
+ def vararg(args: Int*) = args.toList
+ def sum(x: Int, y: Int) = x + y
+ def multipleArgLists(x: Int)(y: Int) = x + y
+
+ type _0 = Int
+ type _1[T] = List[T]
+ type _2[A, B] = Either[A, B]
+
+ class Val(value: Int) extends AnyVal
+ implicit class Impl(value: Int) { def foo = "foo" }
+ abstract class Abs
+ sealed class Sealed
+ class Child extends Sealed
+ case class Point(x: Int, y: Int)
+
+ trait Fooable[T]
+ trait Barable with Fooable[Barable]
+
+ object Foo
+ object Foo with Fooable[Foo]
+ case object Zero
+}
+
+package Packages {
+ package object PackageObject
+ package Nested { package Deeper { } }
+}