diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/reify_lazyunit.check | 3 | ||||
-rw-r--r-- | test/files/run/reify_lazyunit.scala | 13 | ||||
-rw-r--r-- | test/files/run/showraw_aliases.check | 2 | ||||
-rw-r--r-- | test/files/run/showraw_aliases.scala | 15 | ||||
-rw-r--r-- | test/files/run/t6023.check | 12 | ||||
-rw-r--r-- | test/files/run/t6023.scala | 17 | ||||
-rw-r--r-- | test/files/run/t6150.scala | 44 | ||||
-rw-r--r-- | test/files/run/t6488.check | 1 | ||||
-rw-r--r-- | test/files/run/t6488.scala | 11 | ||||
-rw-r--r-- | test/files/run/t6632.check | 3 | ||||
-rw-r--r-- | test/files/run/t6632.scala | 29 | ||||
-rw-r--r-- | test/files/run/t6633.check | 3 | ||||
-rw-r--r-- | test/files/run/t6633.scala | 33 | ||||
-rw-r--r-- | test/files/run/t6634.check | 31 | ||||
-rw-r--r-- | test/files/run/t6634.scala | 80 | ||||
-rw-r--r-- | test/files/run/t6662.check | 1 | ||||
-rw-r--r-- | test/files/run/t6662/Macro_1.scala | 8 | ||||
-rw-r--r-- | test/files/run/t6662/Test_2.scala | 8 | ||||
-rw-r--r-- | test/files/run/t6663.check | 1 | ||||
-rw-r--r-- | test/files/run/t6663.scala | 17 | ||||
-rw-r--r-- | test/files/run/t6673.check | 1 | ||||
-rw-r--r-- | test/files/run/t6673.scala | 5 | ||||
-rw-r--r-- | test/files/run/t6695.scala | 18 |
23 files changed, 356 insertions, 0 deletions
diff --git a/test/files/run/reify_lazyunit.check b/test/files/run/reify_lazyunit.check new file mode 100644 index 0000000000..1b46c909be --- /dev/null +++ b/test/files/run/reify_lazyunit.check @@ -0,0 +1,3 @@ +12 +one +two diff --git a/test/files/run/reify_lazyunit.scala b/test/files/run/reify_lazyunit.scala new file mode 100644 index 0000000000..78b00cde28 --- /dev/null +++ b/test/files/run/reify_lazyunit.scala @@ -0,0 +1,13 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + lazy val x = { 0; println("12")} + x + println("one") + x + println("two") + }.eval +} + diff --git a/test/files/run/showraw_aliases.check b/test/files/run/showraw_aliases.check new file mode 100644 index 0000000000..1838bf9bec --- /dev/null +++ b/test/files/run/showraw_aliases.check @@ -0,0 +1,2 @@ +Block(List(Import(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), List(ImportSelector(newTermName("universe"), 52, newTermName("ru"), 64)))), Select(Select(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), scala.reflect.runtime.package), [newTermName("universe") aka newTermName("ru")])) +Block(List(Import(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), List(ImportSelector(newTermName("universe"), 52, newTermName("ru"), 64)))), Select(Select(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), scala.reflect.runtime.package#<id>), [newTermName("universe")#<id> aka newTermName("ru")])) diff --git a/test/files/run/showraw_aliases.scala b/test/files/run/showraw_aliases.scala new file mode 100644 index 0000000000..3a68ca37b2 --- /dev/null +++ b/test/files/run/showraw_aliases.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = runtimeMirror(getClass.getClassLoader).mkToolBox() + val tree = tb.parse(""" + import scala.reflect.runtime.{universe => ru} + ru + """) + val ttree = tb.typeCheck(tree) + + def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>") + println(showRaw(ttree)) + println(stabilize(showRaw(ttree, printIds = true))) +}
\ No newline at end of file diff --git a/test/files/run/t6023.check b/test/files/run/t6023.check new file mode 100644 index 0000000000..ee93565234 --- /dev/null +++ b/test/files/run/t6023.check @@ -0,0 +1,12 @@ +{ + abstract trait Foo extends AnyRef { + <stable> <accessor> def a: Int + }; + () +} +{ + abstract trait Foo extends AnyRef { + <stable> <accessor> def a: Int + }; + () +} diff --git a/test/files/run/t6023.scala b/test/files/run/t6023.scala new file mode 100644 index 0000000000..07af3685a5 --- /dev/null +++ b/test/files/run/t6023.scala @@ -0,0 +1,17 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + // test 1: reify + val tree = reify{ trait Foo { val a: Int } }.tree + println(tree.toString) + + // test 2: import and typecheck + val toolbox = cm.mkToolBox() + val ttree = toolbox.typeCheck(tree) + println(ttree.toString) + + // test 3: import and compile + toolbox.eval(tree) +} diff --git a/test/files/run/t6150.scala b/test/files/run/t6150.scala new file mode 100644 index 0000000000..bd8af5d460 --- /dev/null +++ b/test/files/run/t6150.scala @@ -0,0 +1,44 @@ + + + + +object Test { + import collection.{ immutable, mutable, generic } + def TheOneTrueCBF = collection.IndexedSeq.ReusableCBF + + val cbf1 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, collection.IndexedSeq[Int]]] + val cbf2 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, collection.IndexedSeq[Int]]] + val cbf3 = implicitly[generic.CanBuildFrom[collection.IndexedSeq[Int], Int, collection.IndexedSeq[Int]]] + + val cbf4 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, immutable.IndexedSeq[Int]]] + val cbf5 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, immutable.Vector[Int]]] + val cbf6 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, immutable.IndexedSeq[Int]]] + + def check[C](v: C) = { + assert(v == Vector(1, 2, 3, 4)) + assert(v.isInstanceOf[Vector[_]]) + } + def checkRealMccoy(x: AnyRef) = { + assert(x eq TheOneTrueCBF, cbf1) + } + + val v = immutable.Vector(1, 2, 3) + val iiv: immutable.IndexedSeq[Int] = immutable.Vector(1, 2, 3) + val iv: IndexedSeq[Int] = immutable.Vector(1, 2, 3) + + def main(args: Array[String]): Unit = { + List(cbf1, cbf2, cbf3, cbf4, cbf5, cbf6) foreach checkRealMccoy + check(v.:+(4)(cbf1)) + check(v.:+(4)(cbf2)) + check(v.:+(4)(cbf3)) + + check(iiv.:+(4)(cbf2)) + check(iiv.:+(4)(cbf3)) + + check(iv.:+(4)(cbf3)) + } +} + + + + diff --git a/test/files/run/t6488.check b/test/files/run/t6488.check new file mode 100644 index 0000000000..35821117c8 --- /dev/null +++ b/test/files/run/t6488.check @@ -0,0 +1 @@ +Success diff --git a/test/files/run/t6488.scala b/test/files/run/t6488.scala new file mode 100644 index 0000000000..487614ecfd --- /dev/null +++ b/test/files/run/t6488.scala @@ -0,0 +1,11 @@ +import sys.process._ +object Test { + // Program that prints "Success" if the command was successfully run then destroyed + // It will silently pass if the command "/bin/ls" does not exist + // It will fail due to the uncatchable exception in t6488 race condition + def main(args: Array[String]) { + try Process("/bin/ls").run(ProcessLogger { _ => () }).destroy + catch { case _ => () } + println("Success") + } +} diff --git a/test/files/run/t6632.check b/test/files/run/t6632.check new file mode 100644 index 0000000000..1f084b1dac --- /dev/null +++ b/test/files/run/t6632.check @@ -0,0 +1,3 @@ +java.lang.IndexOutOfBoundsException: -1 +java.lang.IndexOutOfBoundsException: -2 +java.lang.IndexOutOfBoundsException: -3 diff --git a/test/files/run/t6632.scala b/test/files/run/t6632.scala new file mode 100644 index 0000000000..c1c8d4abe0 --- /dev/null +++ b/test/files/run/t6632.scala @@ -0,0 +1,29 @@ +object Test extends App { + import collection.mutable.ListBuffer + + def newLB = ListBuffer('a, 'b, 'c, 'd, 'e) + + val lb0 = newLB + + try { + lb0.insert(-1, 'x) + } catch { + case ex: IndexOutOfBoundsException => println(ex) + } + + val lb1 = newLB + + try { + lb1.insertAll(-2, Array('x, 'y, 'z)) + } catch { + case ex: IndexOutOfBoundsException => println(ex) + } + + val lb2 = newLB + + try { + lb2.update(-3, 'u) + } catch { + case ex: IndexOutOfBoundsException => println(ex) + } +}
\ No newline at end of file diff --git a/test/files/run/t6633.check b/test/files/run/t6633.check new file mode 100644 index 0000000000..1ff8cdbc44 --- /dev/null +++ b/test/files/run/t6633.check @@ -0,0 +1,3 @@ +java.lang.IndexOutOfBoundsException: 9 +replStringOf OK +length OK diff --git a/test/files/run/t6633.scala b/test/files/run/t6633.scala new file mode 100644 index 0000000000..bd993c8d88 --- /dev/null +++ b/test/files/run/t6633.scala @@ -0,0 +1,33 @@ +object Test extends App { + import collection.mutable.ListBuffer + + def newLB = ListBuffer('a, 'b, 'c, 'd, 'e) + + val lb0 = newLB + + try { + lb0.insert(9, 'x) + } catch { + case ex: IndexOutOfBoundsException => println(ex) + } + + val lb1 = newLB + + try { + lb1.insert(9, 'x) + } catch { + case ex: IndexOutOfBoundsException => + } + + val replStr = scala.runtime.ScalaRunTime.replStringOf(lb1, 100) + if (replStr == "ListBuffer('a, 'b, 'c, 'd, 'e)\n") + println("replStringOf OK") + else + println("replStringOf FAILED: " + replStr) + + val len = lb1.length + if (len == 5) + println("length OK") + else + println("length FAILED: " + len) +}
\ No newline at end of file diff --git a/test/files/run/t6634.check b/test/files/run/t6634.check new file mode 100644 index 0000000000..f6cbb30c67 --- /dev/null +++ b/test/files/run/t6634.check @@ -0,0 +1,31 @@ +Trying lb0 ... +Checking ... +String OK. +Length OK. + +Trying lb1 ... +Checking ... +String OK. +Length OK. + +Trying lb2 ... +Checking ... +String OK. +Length OK. + +Trying lb3 ... +Checking ... +String OK. +Length OK. + +Trying lb4 ... +Checking ... +String OK. +Length OK. + +Trying lb5 ... +java.lang.IllegalArgumentException: removing negative number (-1) of elements +Checking ... +String OK. +Length OK. + diff --git a/test/files/run/t6634.scala b/test/files/run/t6634.scala new file mode 100644 index 0000000000..759e6d519d --- /dev/null +++ b/test/files/run/t6634.scala @@ -0,0 +1,80 @@ +import collection.mutable.ListBuffer + +object Test extends App { + def newLB = ListBuffer('a, 'b, 'c, 'd, 'e) + + val lb0 = newLB + println("Trying lb0 ...") + try { + lb0.remove(5, 0) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IndexOutOfBoundsException => println(ex) + } + checkNotCorrupted(lb0) + + val lb1 = newLB + println("Trying lb1 ...") + try { + lb1.remove(6, 6) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IndexOutOfBoundsException => println(ex) + } + checkNotCorrupted(lb1) + + val lb2 = newLB + println("Trying lb2 ...") + try { + lb2.remove(99, 6) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IndexOutOfBoundsException => println(ex) + } + checkNotCorrupted(lb2) + + val lb3 = newLB + println("Trying lb3 ...") + try { + lb3.remove(1, 9) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IllegalArgumentException => println(ex) + } + checkNotCorrupted(lb3, "ListBuffer('a)", 1) + + val lb4 = newLB + println("Trying lb4 ...") + try { + lb4.remove(-1, 1) + } catch { + // Not thrown in 2.10, will be thrown in 2.11 + case ex: IndexOutOfBoundsException => println(ex) + } + checkNotCorrupted(lb4, "ListBuffer('b, 'c, 'd, 'e)", 4) + + val lb5 = newLB + println("Trying lb5 ...") + try { + lb5.remove(1, -1) + } catch { + case ex: IllegalArgumentException => println(ex) + } + checkNotCorrupted(lb5) + + // buffer should neither be changed nor corrupted after calling remove with invalid arguments + def checkNotCorrupted( + lb: ListBuffer[Symbol], + expectedString: String = "ListBuffer('a, 'b, 'c, 'd, 'e)", + expectedLength: Int = 5) = { + println("Checking ...") + val replStr = scala.runtime.ScalaRunTime.replStringOf(lb, 100) + if (replStr == expectedString + "\n") println("String OK.") + else println("!!! replStringOf FAILED: " + replStr) + + val len = lb.length + if (len == expectedLength) println("Length OK.") + else println("!!! length FAILED: " + len) + println() + } +}
\ No newline at end of file diff --git a/test/files/run/t6662.check b/test/files/run/t6662.check new file mode 100644 index 0000000000..6a452c185a --- /dev/null +++ b/test/files/run/t6662.check @@ -0,0 +1 @@ +() diff --git a/test/files/run/t6662/Macro_1.scala b/test/files/run/t6662/Macro_1.scala new file mode 100644 index 0000000000..f373eaaf94 --- /dev/null +++ b/test/files/run/t6662/Macro_1.scala @@ -0,0 +1,8 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +object Demo { + def id[T](a: T): T = macro idImpl[T] + + def idImpl[T: c.WeakTypeTag](c: Context)(a: c.Expr[T]): c.Expr[T] = a +} diff --git a/test/files/run/t6662/Test_2.scala b/test/files/run/t6662/Test_2.scala new file mode 100644 index 0000000000..03a80b655a --- /dev/null +++ b/test/files/run/t6662/Test_2.scala @@ -0,0 +1,8 @@ +// Macro usage: + +object Test { + def main(args: Array[String]) { + val s = Demo id () + println(s) + } +} diff --git a/test/files/run/t6663.check b/test/files/run/t6663.check new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/test/files/run/t6663.check @@ -0,0 +1 @@ +42 diff --git a/test/files/run/t6663.scala b/test/files/run/t6663.scala new file mode 100644 index 0000000000..6818d286d9 --- /dev/null +++ b/test/files/run/t6663.scala @@ -0,0 +1,17 @@ +import language.dynamics + +class C(v: Any) extends Dynamic { + def selectDynamic[T](n: String): Option[T] = Option(v.asInstanceOf[T]) + def applyDynamic[T](n: String)(): Option[T] = Option(v.asInstanceOf[T]) +} + +object Test extends App { + // this should be converted to + // C(42).selectDynamic[Int]("foo").get + // but, before fixing SI-6663, became + // C(42).selectDynamic[Nothing]("foo").get + // leading to a ClassCastException + var v = new C(42).foo[Int].get + println(v) +} + diff --git a/test/files/run/t6673.check b/test/files/run/t6673.check new file mode 100644 index 0000000000..ef2aa551dc --- /dev/null +++ b/test/files/run/t6673.check @@ -0,0 +1 @@ +List(x) diff --git a/test/files/run/t6673.scala b/test/files/run/t6673.scala new file mode 100644 index 0000000000..115bbdf234 --- /dev/null +++ b/test/files/run/t6673.scala @@ -0,0 +1,5 @@ +object Test extends App { + def foo(f: String => Array[String])(s: String) = f(s) + val test = foo(Array(_)) _ + println(test("x").toList) +}
\ No newline at end of file diff --git a/test/files/run/t6695.scala b/test/files/run/t6695.scala new file mode 100644 index 0000000000..b527238a51 --- /dev/null +++ b/test/files/run/t6695.scala @@ -0,0 +1,18 @@ +object Test extends App { + try { + Array("a", "b", "c") match { + case Array("a", "x", "c") => println("x") + case Array("a", "b", "x") => println("a"); + case Array("a", "d", _*) => println("wrongly positive") + } + assert(false, "match succeeded") + } catch { + case _: MatchError => // okay + } + + Array("a", "b", "c") match { + case Array("a", "x", "c") => println("x") + case Array("a", "b", "x") => println("a"); + case Array("a", "b", _*) => // okay + } +} |