diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/t7265.scala | 27 | ||||
-rw-r--r-- | test/files/run/t7336.scala | 31 | ||||
-rw-r--r-- | test/files/run/t7569.check | 12 | ||||
-rw-r--r-- | test/files/run/t7569.scala | 19 | ||||
-rw-r--r-- | test/files/run/t7617a.check | 2 | ||||
-rw-r--r-- | test/files/run/t7617a/Macros_1.scala | 22 | ||||
-rw-r--r-- | test/files/run/t7617a/Test_2.scala | 5 | ||||
-rw-r--r-- | test/files/run/t7617b.check | 1 | ||||
-rw-r--r-- | test/files/run/t7617b/Macros_1.scala | 8 | ||||
-rw-r--r-- | test/files/run/t7617b/Test_2.scala | 11 | ||||
-rw-r--r-- | test/files/run/t7657.check | 3 | ||||
-rw-r--r-- | test/files/run/t7657/Macros_1.scala | 8 | ||||
-rw-r--r-- | test/files/run/t7657/Test_2.scala | 6 |
13 files changed, 155 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/t7569.check b/test/files/run/t7569.check new file mode 100644 index 0000000000..aade96d233 --- /dev/null +++ b/test/files/run/t7569.check @@ -0,0 +1,12 @@ +source-newSource1.scala,line-3,offset=49 A.this.one +source-newSource1.scala,line-3,offset=49 A.this +source-newSource1.scala,line-2,offset=41 A.super.<init>() +source-newSource1.scala,line-2,offset=41 A.super.<init> +source-newSource1.scala,line-2,offset=41 this +source-newSource1.scala,line-3,offset=49 A.this.one +source-newSource1.scala,line-3,offset=49 A.this +RangePosition(newSource1.scala, 55, 57, 65) scala.Int.box(1).toString() +RangePosition(newSource1.scala, 55, 57, 65) scala.Int.box(1).toString +RangePosition(newSource1.scala, 55, 55, 56) scala.Int.box(1) +NoPosition scala.Int.box +NoPosition scala.Int diff --git a/test/files/run/t7569.scala b/test/files/run/t7569.scala new file mode 100644 index 0000000000..b1b1443a18 --- /dev/null +++ b/test/files/run/t7569.scala @@ -0,0 +1,19 @@ +import scala.tools.partest._ +object Test extends CompilerTest { + import global._ + override def extraSettings = super.extraSettings + " -Yrangepos" + override def sources = List( + """|import scala.language.postfixOps + |class A { + | val one = 1 toString + |}""".stripMargin + ) + def check(source: String, unit: CompilationUnit) { + for (ClassDef(_, _, _, Template(_, _, stats)) <- unit.body ; stat <- stats ; t <- stat) { + t match { + case _: Select | _ : Apply | _:This => println("%-15s %s".format(t.pos.toString, t)) + case _ => + } + } + } +} 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 |