summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/t7265.scala27
-rw-r--r--test/files/run/t7336.scala31
-rw-r--r--test/files/run/t7455.check4
-rw-r--r--test/files/run/t7455/Outer.java31
-rw-r--r--test/files/run/t7455/Test.scala30
-rw-r--r--test/files/run/t7617a.check2
-rw-r--r--test/files/run/t7617a/Macros_1.scala22
-rw-r--r--test/files/run/t7617a/Test_2.scala5
-rw-r--r--test/files/run/t7617b.check1
-rw-r--r--test/files/run/t7617b/Macros_1.scala8
-rw-r--r--test/files/run/t7617b/Test_2.scala11
-rw-r--r--test/files/run/t7657.check3
-rw-r--r--test/files/run/t7657/Macros_1.scala8
-rw-r--r--test/files/run/t7657/Test_2.scala6
14 files changed, 189 insertions, 0 deletions
diff --git a/test/files/run/t7265.scala b/test/files/run/t7265.scala
new file mode 100644
index 0000000000..c556930303
--- /dev/null
+++ b/test/files/run/t7265.scala
@@ -0,0 +1,27 @@
+
+import scala.util.Properties._
+
+object Test extends App {
+
+ setProp("java.specification.version", "1.7")
+
+ assert( isJavaAtLeast("1.5"))
+ assert( isJavaAtLeast("1.6"))
+ assert( isJavaAtLeast("1.7"))
+ assert(!isJavaAtLeast("1.8"))
+ assert(!isJavaAtLeast("1.71"))
+
+ failing(isJavaAtLeast("1.a"))
+ failing(isJavaAtLeast("1"))
+ failing(isJavaAtLeast(""))
+ failing(isJavaAtLeast("."))
+ failing(isJavaAtLeast(".5"))
+ failing(isJavaAtLeast("1.7.1"))
+
+ def failing(u: =>Unit) = try {
+ u
+ assert(false, "Expected Exception")
+ } catch {
+ case _: NumberFormatException =>
+ }
+}
diff --git a/test/files/run/t7336.scala b/test/files/run/t7336.scala
new file mode 100644
index 0000000000..ace83f2c1f
--- /dev/null
+++ b/test/files/run/t7336.scala
@@ -0,0 +1,31 @@
+import scala.concurrent.Await
+import scala.concurrent.ExecutionContext.Implicits.global
+import scala.concurrent.Future
+import scala.concurrent.duration.Duration
+
+/** This test uses recursive calls to Future.flatMap to create arrays whose
+ * combined size is slightly greater than the JVM heap size. A previous
+ * implementation of Future.flatMap would retain references to each array,
+ * resulting in a speedy OutOfMemoryError. Now, each array should be freed soon
+ * after it is created and the test should complete without problems.
+ */
+object Test {
+ def main(args: Array[String]) {
+ def loop(i: Int, arraySize: Int): Future[Unit] = {
+ val array = new Array[Byte](arraySize)
+ Future.successful(i).flatMap { i =>
+ if (i == 0) {
+ Future.successful(())
+ } else {
+ array.size // Force closure to refer to array
+ loop(i - 1, arraySize)
+ }
+
+ }
+ }
+
+ val arraySize = 1000000
+ val tooManyArrays = (Runtime.getRuntime().totalMemory() / arraySize).toInt + 1
+ Await.ready(loop(tooManyArrays, arraySize), Duration.Inf)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t7455.check b/test/files/run/t7455.check
new file mode 100644
index 0000000000..0eb9342888
--- /dev/null
+++ b/test/files/run/t7455.check
@@ -0,0 +1,4 @@
+private[package <empty>] def <init>(x$1: String): Outer[E]
+private[package <empty>] def <init>(): Outer$PrivateInner
+private[package <empty>] def <init>(): Outer$PrivateStaticInner
+private[package <empty>] def <init>(x$2: String): Outer$PublicInner
diff --git a/test/files/run/t7455/Outer.java b/test/files/run/t7455/Outer.java
new file mode 100644
index 0000000000..10c97a9150
--- /dev/null
+++ b/test/files/run/t7455/Outer.java
@@ -0,0 +1,31 @@
+public class Outer<E> {
+ public void elements() {
+ new C<E>() {
+ };
+ }
+
+ private Outer(String a) {}
+
+ static class SubSelf extends Outer<String> {
+ public SubSelf() { super(""); }
+ }
+
+ private class PrivateInner {
+ }
+ class SubPrivateInner extends PrivateInner {
+ }
+
+ private class PublicInner {
+ private PublicInner(String a) {}
+ }
+ class SubPublicInner extends PublicInner {
+ public SubPublicInner() { super(""); }
+ }
+
+ private static class PrivateStaticInner {
+ }
+ public static class SubPrivateStaticInner extends PrivateStaticInner {
+ }
+}
+
+class C<E> {}
diff --git a/test/files/run/t7455/Test.scala b/test/files/run/t7455/Test.scala
new file mode 100644
index 0000000000..b23a724c78
--- /dev/null
+++ b/test/files/run/t7455/Test.scala
@@ -0,0 +1,30 @@
+import scala.tools.partest._
+
+// javac adds dummy parameters of type Outer$1 to synthetic access constructors
+// This test shows that we strip them from the signatures. If we don't, we trigger
+// parsing of Outer$1 which can fail if it references type parameters of the Outer.
+//
+// OLD OUTPUT:
+// private[package <empty>] def <init>(x$2: Outer$1): Outer$PrivateInner
+// error: error while loading Outer$1, class file 't7455-run.obj/Outer$1.class' is broken
+// (class java.util.NoSuchElementException/key not found: E)
+// ...
+object Test extends DirectTest {
+ override def code = ""
+
+ def show {
+ val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
+ val compiler = newCompiler("-cp", classpath, "-d", testOutput.path)
+ import compiler._, definitions._
+ new compiler.Run
+
+ for {
+ name <- Seq("Outer", "Outer$PrivateInner", "Outer$PrivateStaticInner", "Outer$PublicInner")
+ clazz = compiler.rootMirror.staticClass(name)
+ constr <- clazz.info.member(nme.CONSTRUCTOR).alternatives
+ } {
+ println(constr.defString)
+ fullyInitializeSymbol(constr)
+ }
+ }
+}
diff --git a/test/files/run/t7617a.check b/test/files/run/t7617a.check
new file mode 100644
index 0000000000..94954abda4
--- /dev/null
+++ b/test/files/run/t7617a.check
@@ -0,0 +1,2 @@
+hello
+world
diff --git a/test/files/run/t7617a/Macros_1.scala b/test/files/run/t7617a/Macros_1.scala
new file mode 100644
index 0000000000..f9772c83c0
--- /dev/null
+++ b/test/files/run/t7617a/Macros_1.scala
@@ -0,0 +1,22 @@
+import scala.reflect.macros.Context
+import language.experimental.macros
+
+object Macros {
+ def getValueImpl[T](c: Context): c.Expr[T] = {
+ import c.universe._
+ c.Expr[T](Apply(Select(c.prefix.tree, newTermName("getVal")), Nil))
+ }
+ def setValueImpl[T](c: Context)(value: c.Expr[T]): c.Expr[Unit] = {
+ import c.universe._
+ c.Expr[Unit](Apply(Select(c.prefix.tree, newTermName("setVal")), List(value.tree)))
+ }
+}
+
+object Module {
+ private var _val: String = "hello"
+ def setVal(value: String): Unit = this._val = value
+ def getVal(): String = this._val
+
+ def value: String = macro Macros.getValueImpl[String]
+ def value_=(value: String): Unit = macro Macros.setValueImpl[String]
+}
diff --git a/test/files/run/t7617a/Test_2.scala b/test/files/run/t7617a/Test_2.scala
new file mode 100644
index 0000000000..da6e34e09d
--- /dev/null
+++ b/test/files/run/t7617a/Test_2.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ println(Module.value)
+ Module.value = "world"
+ println(Module.value)
+} \ No newline at end of file
diff --git a/test/files/run/t7617b.check b/test/files/run/t7617b.check
new file mode 100644
index 0000000000..81ec7e8b74
--- /dev/null
+++ b/test/files/run/t7617b.check
@@ -0,0 +1 @@
+foo = 2
diff --git a/test/files/run/t7617b/Macros_1.scala b/test/files/run/t7617b/Macros_1.scala
new file mode 100644
index 0000000000..bc919935c9
--- /dev/null
+++ b/test/files/run/t7617b/Macros_1.scala
@@ -0,0 +1,8 @@
+import scala.reflect.macros.Context
+
+object Macros {
+ def impl(c: Context)(name: c.Expr[String])(value: c.Expr[Any]) = {
+ import c.universe._
+ reify(println(s"${name.splice} = ${value.splice}"))
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t7617b/Test_2.scala b/test/files/run/t7617b/Test_2.scala
new file mode 100644
index 0000000000..e27f650e80
--- /dev/null
+++ b/test/files/run/t7617b/Test_2.scala
@@ -0,0 +1,11 @@
+import scala.language.dynamics
+import language.experimental.macros
+
+class C extends Dynamic {
+ def updateDynamic(name: String)(value: Any) = macro Macros.impl
+}
+
+object Test extends App {
+ val c = new C
+ c.foo = 2
+} \ No newline at end of file
diff --git a/test/files/run/t7657.check b/test/files/run/t7657.check
new file mode 100644
index 0000000000..c25d8d1c1b
--- /dev/null
+++ b/test/files/run/t7657.check
@@ -0,0 +1,3 @@
+()
+()
+()
diff --git a/test/files/run/t7657/Macros_1.scala b/test/files/run/t7657/Macros_1.scala
new file mode 100644
index 0000000000..b1e31aa2dd
--- /dev/null
+++ b/test/files/run/t7657/Macros_1.scala
@@ -0,0 +1,8 @@
+import scala.reflect.macros.Context
+import language.experimental.macros
+
+trait T { def t(): Unit }
+abstract class A extends T { override def t(): Unit = () }
+
+object Macro { def t(c: Context)(): c.Expr[Unit] = c.universe.reify(()) }
+class C extends A { override def t(): Unit = macro Macro.t }
diff --git a/test/files/run/t7657/Test_2.scala b/test/files/run/t7657/Test_2.scala
new file mode 100644
index 0000000000..5cc46b6aa1
--- /dev/null
+++ b/test/files/run/t7657/Test_2.scala
@@ -0,0 +1,6 @@
+object Test extends App {
+ val c = new C()
+ println(c.t())
+ println((c: T).t())
+ println((c: A).t())
+} \ No newline at end of file