summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/macro-basic.check1
-rw-r--r--test/files/run/macro-basic.flags1
-rw-r--r--test/files/run/macro-basic/Macros_1.scala10
-rw-r--r--test/files/run/macro-basic/Test_2.scala4
-rw-r--r--test/files/run/macro-repl-basic.check25
-rw-r--r--test/files/run/macro-repl-basic.scala18
-rw-r--r--test/files/run/macro-repl-dontexpand.check9
-rw-r--r--test/files/run/macro-repl-dontexpand.scala8
-rw-r--r--test/files/run/macro-rettype-mismatch.check5
-rw-r--r--test/files/run/macro-rettype-mismatch.flags1
-rw-r--r--test/files/run/macro-rettype-mismatch/Macros_1.scala3
-rw-r--r--test/files/run/macro-rettype-mismatch/Test_2.scala16
-rw-r--r--test/files/run/t4770.check2
-rw-r--r--test/files/run/t4770.scala15
-rw-r--r--test/files/run/t4794.check2
-rw-r--r--test/files/run/t5488-fn.check17
-rw-r--r--test/files/run/t5488-fn.scala49
-rw-r--r--test/files/run/t5488.check14
-rw-r--r--test/files/run/t5488.scala26
-rw-r--r--test/files/run/virtpatmat_partial.check4
-rw-r--r--test/files/run/virtpatmat_partial.scala23
-rw-r--r--test/files/run/virtpatmat_switch.scala8
-rw-r--r--test/files/run/virtpatmat_try.check2
-rw-r--r--test/files/run/virtpatmat_try.flags1
-rw-r--r--test/files/run/virtpatmat_try.scala47
25 files changed, 291 insertions, 20 deletions
diff --git a/test/files/run/macro-basic.check b/test/files/run/macro-basic.check
new file mode 100644
index 0000000000..d434014897
--- /dev/null
+++ b/test/files/run/macro-basic.check
@@ -0,0 +1 @@
+10
diff --git a/test/files/run/macro-basic.flags b/test/files/run/macro-basic.flags
new file mode 100644
index 0000000000..06a7b31f11
--- /dev/null
+++ b/test/files/run/macro-basic.flags
@@ -0,0 +1 @@
+-Xmacros
diff --git a/test/files/run/macro-basic/Macros_1.scala b/test/files/run/macro-basic/Macros_1.scala
new file mode 100644
index 0000000000..c2ea183abe
--- /dev/null
+++ b/test/files/run/macro-basic/Macros_1.scala
@@ -0,0 +1,10 @@
+object Macros {
+ object Shmacros {
+ def macro foo(x: Int): Int = x
+ }
+ def macro bar(x: Int): Int = x
+}
+
+class Macros {
+ def macro quux(x: Int): Int = x
+} \ No newline at end of file
diff --git a/test/files/run/macro-basic/Test_2.scala b/test/files/run/macro-basic/Test_2.scala
new file mode 100644
index 0000000000..e9a10e20c9
--- /dev/null
+++ b/test/files/run/macro-basic/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ import Macros.Shmacros._
+ println(foo(2) + Macros.bar(2) * new Macros().quux(4))
+} \ No newline at end of file
diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check
new file mode 100644
index 0000000000..f8f0d3ad29
--- /dev/null
+++ b/test/files/run/macro-repl-basic.check
@@ -0,0 +1,25 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> object Macros {
+ object Shmacros {
+ def macro foo(x: Int): Int = x
+ }
+ def macro bar(x: Int): Int = x
+}; class Macros {
+ def macro quux(x: Int): Int = x
+}
+defined module Macros
+defined class Macros
+
+scala>
+
+scala> import Macros.Shmacros._
+import Macros.Shmacros._
+
+scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4))
+10
+
+scala>
diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala
new file mode 100644
index 0000000000..9b1a53343b
--- /dev/null
+++ b/test/files/run/macro-repl-basic.scala
@@ -0,0 +1,18 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ override def extraSettings = "-Xmacros"
+ def code = """
+ |object Macros {
+ | object Shmacros {
+ | def macro foo(x: Int): Int = x
+ | }
+ | def macro bar(x: Int): Int = x
+ |}; class Macros {
+ | def macro quux(x: Int): Int = x
+ |}
+ |
+ |import Macros.Shmacros._
+ |println(foo(2) + Macros.bar(2) * new Macros().quux(4))
+ |""".stripMargin
+} \ No newline at end of file
diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check
new file mode 100644
index 0000000000..d2bb89b6f7
--- /dev/null
+++ b/test/files/run/macro-repl-dontexpand.check
@@ -0,0 +1,9 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> def macro foo = ???
+foo: Any
+
+scala>
diff --git a/test/files/run/macro-repl-dontexpand.scala b/test/files/run/macro-repl-dontexpand.scala
new file mode 100644
index 0000000000..254bce894c
--- /dev/null
+++ b/test/files/run/macro-repl-dontexpand.scala
@@ -0,0 +1,8 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ override def extraSettings = "-Xmacros"
+ def code = """
+ |def macro foo = ???
+ |""".stripMargin
+} \ No newline at end of file
diff --git a/test/files/run/macro-rettype-mismatch.check b/test/files/run/macro-rettype-mismatch.check
new file mode 100644
index 0000000000..f6e4bc09fd
--- /dev/null
+++ b/test/files/run/macro-rettype-mismatch.check
@@ -0,0 +1,5 @@
+error: type mismatch;
+ found : Int(2)
+ required: String
+
+java.lang.Error: reflective compilation has failed
diff --git a/test/files/run/macro-rettype-mismatch.flags b/test/files/run/macro-rettype-mismatch.flags
new file mode 100644
index 0000000000..7fea2ff901
--- /dev/null
+++ b/test/files/run/macro-rettype-mismatch.flags
@@ -0,0 +1 @@
+-Xmacros \ No newline at end of file
diff --git a/test/files/run/macro-rettype-mismatch/Macros_1.scala b/test/files/run/macro-rettype-mismatch/Macros_1.scala
new file mode 100644
index 0000000000..64e5b93468
--- /dev/null
+++ b/test/files/run/macro-rettype-mismatch/Macros_1.scala
@@ -0,0 +1,3 @@
+object Macros {
+ def macro foo(x: Int): String = x
+} \ No newline at end of file
diff --git a/test/files/run/macro-rettype-mismatch/Test_2.scala b/test/files/run/macro-rettype-mismatch/Test_2.scala
new file mode 100644
index 0000000000..39a7c7ad1a
--- /dev/null
+++ b/test/files/run/macro-rettype-mismatch/Test_2.scala
@@ -0,0 +1,16 @@
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+object Test extends App {
+ import scala.reflect.mirror._
+ val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(2))))
+
+ val stderr = new java.io.ByteArrayOutputStream()
+ Console.setErr(new java.io.PrintStream(stderr))
+
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ try { toolbox.runExpr(tree) }
+ catch { case ex: Throwable => println(stderr); println(ex) }
+}
diff --git a/test/files/run/t4770.check b/test/files/run/t4770.check
deleted file mode 100644
index 38e5a831fa..0000000000
--- a/test/files/run/t4770.check
+++ /dev/null
@@ -1,2 +0,0 @@
-(a,2)
-(2,a)
diff --git a/test/files/run/t4770.scala b/test/files/run/t4770.scala
deleted file mode 100644
index 25bf3050c3..0000000000
--- a/test/files/run/t4770.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-package crasher {
- class Z[@specialized A, @specialized(AnyRef) B](var a: A, var b: B) {
- override def toString = "" + ((a, b))
- }
- object O {
- def apply[@specialized A, @specialized(AnyRef) B](a0: A, b0: B) = new Z(a0, b0)
- }
-}
-
-object Test {
- def main(args: Array[String]): Unit = {
- println(crasher.O("a", 2))
- println(crasher.O(2, "a"))
- }
-}
diff --git a/test/files/run/t4794.check b/test/files/run/t4794.check
index b4de394767..f599e28b8a 100644
--- a/test/files/run/t4794.check
+++ b/test/files/run/t4794.check
@@ -1 +1 @@
-11
+10
diff --git a/test/files/run/t5488-fn.check b/test/files/run/t5488-fn.check
new file mode 100644
index 0000000000..196f58d063
--- /dev/null
+++ b/test/files/run/t5488-fn.check
@@ -0,0 +1,17 @@
+B$mcII$sp
+B
+B$mcIV$sp
+B$mcLI$sp
+B
+B$mcLV$sp
+B$mcVI$sp
+B
+B$mcVV$sp
+C$mcIII$sp
+C
+C$mcILI$sp
+C
+C$mcLII$sp
+C
+C$mcLLI$sp
+C
diff --git a/test/files/run/t5488-fn.scala b/test/files/run/t5488-fn.scala
new file mode 100644
index 0000000000..9e4f60002b
--- /dev/null
+++ b/test/files/run/t5488-fn.scala
@@ -0,0 +1,49 @@
+class B[@specialized(Int, AnyRef, Unit) A, @specialized(Int, Unit) B](f: A => B)
+class C[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B, @specialized(Int) C](f: (A, B) => C)
+// Not yet:
+// class B[@specialized(Int, AnyRef, Unit) A, @specialized(Int, AnyRef, Unit) B](f: A => B)
+// class C[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B, @specialized(Int, AnyRef) C](f: (A, B) => C)
+
+object Test {
+ def main(args:Array[String]) {
+ def show(x: Any) = println(x.getClass.getName)
+
+ show(new B((x: Int) => 1))
+ show(new B((x: Int) => "abc"))
+ show(new B((x: Int) => ()))
+ show(new B((x: AnyRef) => 1))
+ show(new B((x: AnyRef) => "abc"))
+ show(new B((x: AnyRef) => ()))
+ show(new B((x: Unit) => 1))
+ show(new B((x: Unit) => "abc"))
+ show(new B((x: Unit) => ()))
+
+ show(new C((x: Int, y: Int) => 1))
+ show(new C((x: Int, y: Int) => "abc"))
+ show(new C((x: Int, y: AnyRef) => 1))
+ show(new C((x: Int, y: AnyRef) => "abc"))
+ show(new C((x: AnyRef, y: Int) => 1))
+ show(new C((x: AnyRef, y: Int) => "abc"))
+ show(new C((x: AnyRef, y: AnyRef) => 1))
+ show(new C((x: AnyRef, y: AnyRef) => "abc"))
+ }
+}
+/** If the return types are specialized on AnyRef as well:
+
+files/run/t5488-fn.scala:18: error: type mismatch;
+ found : Unit => String
+ required: Unit => B$sp
+ show(new B((x: Unit) => "abc"))
+ ^
+files/run/t5488-fn.scala:24: error: type mismatch;
+ found : (Int, Object) => String
+ required: (Int, B$sp) => C$sp
+ show(new C((x: Int, y: AnyRef) => "abc"))
+ ^
+files/run/t5488-fn.scala:26: error: type mismatch;
+ found : (Object, Int) => String
+ required: (A$sp, Int) => C$sp
+ show(new C((x: AnyRef, y: Int) => "abc"))
+ ^
+three errors found
+**/
diff --git a/test/files/run/t5488.check b/test/files/run/t5488.check
new file mode 100644
index 0000000000..ccd98c4dbc
--- /dev/null
+++ b/test/files/run/t5488.check
@@ -0,0 +1,14 @@
+A0$mcI$sp
+A0
+B0$mcII$sp
+B0$mcIL$sp
+B0$mcLI$sp
+B0
+C0$mcIII$sp
+C0$mcIIL$sp
+C0$mcILI$sp
+C0$mcILL$sp
+C0$mcLII$sp
+C0$mcLIL$sp
+C0$mcLLI$sp
+C0
diff --git a/test/files/run/t5488.scala b/test/files/run/t5488.scala
new file mode 100644
index 0000000000..7bab0cdc3c
--- /dev/null
+++ b/test/files/run/t5488.scala
@@ -0,0 +1,26 @@
+class A0[@specialized(Int, AnyRef) A]()
+class B0[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B]()
+class C0[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B, @specialized(Int, AnyRef) C]()
+
+object Test {
+ def main(args:Array[String]) {
+ def show(x: Any) = println(x.getClass.getName)
+
+ show(new A0[Int]())
+ show(new A0[AnyRef]())
+
+ show(new B0[Int, Int]())
+ show(new B0[Int, AnyRef]())
+ show(new B0[AnyRef, Int]())
+ show(new B0[AnyRef, AnyRef]())
+
+ show(new C0[Int, Int, Int]())
+ show(new C0[Int, Int, AnyRef]())
+ show(new C0[Int, AnyRef, Int]())
+ show(new C0[Int, AnyRef, AnyRef]())
+ show(new C0[AnyRef, Int, Int]())
+ show(new C0[AnyRef, Int, AnyRef]())
+ show(new C0[AnyRef, AnyRef, Int]())
+ show(new C0[AnyRef, AnyRef, AnyRef]())
+ }
+}
diff --git a/test/files/run/virtpatmat_partial.check b/test/files/run/virtpatmat_partial.check
index 093020ce05..1555eca82b 100644
--- a/test/files/run/virtpatmat_partial.check
+++ b/test/files/run/virtpatmat_partial.check
@@ -1,2 +1,4 @@
Map(a -> Some(1), b -> None)
-Map(a -> 1) \ No newline at end of file
+79
+undefined
+Map(a -> 1)
diff --git a/test/files/run/virtpatmat_partial.scala b/test/files/run/virtpatmat_partial.scala
index c408b31983..6597f2f5ae 100644
--- a/test/files/run/virtpatmat_partial.scala
+++ b/test/files/run/virtpatmat_partial.scala
@@ -4,6 +4,29 @@ object Test extends App {
val res = a collect {case (p, Some(a)) => (p, a)}
+ final val GT = 79
+ final val GTGT = 93
+ final val GTGTGT = 94
+ final val GTEQ = 81
+ final val GTGTEQ = 113
+ final val GTGTGTEQ = 114
+ final val ASSIGN = 75
+
+ def acceptClosingAngle(in: Int) {
+ val closers: PartialFunction[Int, Int] = {
+ case GTGTGTEQ => GTGTEQ
+ case GTGTGT => GTGT
+ case GTGTEQ => GTEQ
+ case GTGT => GT
+ case GTEQ => ASSIGN
+ }
+ if (closers isDefinedAt in) println(closers(in))
+ else println("undefined")
+ }
+
+ acceptClosingAngle(GTGT)
+ acceptClosingAngle(ASSIGN)
+
// should uncurry to:
// val res: Map[String,Int] = a.collect[(String, Int), Map[String,Int]](
// new PartialFunction[(String, Option[Int]),(String, Int)] {
diff --git a/test/files/run/virtpatmat_switch.scala b/test/files/run/virtpatmat_switch.scala
index 2e2c31e8e5..1329c19d0f 100644
--- a/test/files/run/virtpatmat_switch.scala
+++ b/test/files/run/virtpatmat_switch.scala
@@ -14,9 +14,15 @@ object Test extends App {
case 'b' => "got b"
case _ => "got some letter"
}
+
+ def byteSwitch(x: Byte) = x match {
+ case 'a' => "got a"
+ case 'b' => "got b"
+ case _ => "got some letter"
+ }
println(charSwitch('a'))
- println(charSwitch('b'))
+ println(byteSwitch('b'))
println(charSwitch('z'))
def implicitDefault(x: Int) = x match {
diff --git a/test/files/run/virtpatmat_try.check b/test/files/run/virtpatmat_try.check
new file mode 100644
index 0000000000..80ebbf494a
--- /dev/null
+++ b/test/files/run/virtpatmat_try.check
@@ -0,0 +1,2 @@
+meh
+B
diff --git a/test/files/run/virtpatmat_try.flags b/test/files/run/virtpatmat_try.flags
new file mode 100644
index 0000000000..9769db9257
--- /dev/null
+++ b/test/files/run/virtpatmat_try.flags
@@ -0,0 +1 @@
+ -Yvirtpatmat -Xexperimental
diff --git a/test/files/run/virtpatmat_try.scala b/test/files/run/virtpatmat_try.scala
new file mode 100644
index 0000000000..46e67cb72e
--- /dev/null
+++ b/test/files/run/virtpatmat_try.scala
@@ -0,0 +1,47 @@
+object Test extends App {
+ case class A(val x: String) extends Throwable
+ class B extends Exception { override def toString = "B" }
+ def bla = 0
+
+ try {
+ throw new A("meh")
+ } catch { // this should emit a "catch-switch"
+ case y: A => println(y.x)
+ case (_ : A | _ : B) => println("B")
+ case _ => println("other")
+ }
+
+ try {
+ throw new B()
+ } catch { // case classes and alternative flattening aren't supported yet, but could be in principle
+ // case A(x) => println(x)
+ case y: A => println(y.x)
+ case x@((_ : A) | (_ : B)) => println(x)
+ case _ => println("other")
+ }
+
+ def simpleTry {
+ try {
+ bla
+ } catch {
+ case x: Exception if x.getMessage == "test" => println("first case " + x)
+ case x: Exception => println("second case " + x)
+ }
+ }
+
+ def typedWildcardTry {
+ try { bla } catch { case _: ClassCastException => bla }
+ }
+
+ def wildcardTry {
+ try { bla } catch { case _ => bla }
+ }
+
+ def tryPlusFinally {
+ try { bla } finally { println("finally") }
+ }
+
+ def catchAndPassToLambda {
+ try { bla } catch { case ex: Exception => val f = () => ex }
+ }
+} \ No newline at end of file