diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/private-inline.flags | 2 | ||||
-rw-r--r-- | test/files/run/range.scala | 18 | ||||
-rw-r--r-- | test/files/run/repl-serialization.check | 25 | ||||
-rw-r--r-- | test/files/run/repl-serialization.scala | 68 | ||||
-rw-r--r-- | test/files/run/synchronized.check | 5 | ||||
-rw-r--r-- | test/files/run/synchronized.scala | 3 | ||||
-rw-r--r-- | test/files/run/t6102.check | 5 | ||||
-rw-r--r-- | test/files/run/t7747-repl.check | 41 | ||||
-rw-r--r-- | test/files/run/t7747-repl.scala | 6 | ||||
-rw-r--r-- | test/files/run/t8601-closure-elim.flags | 2 | ||||
-rw-r--r-- | test/files/run/toolbox-varargs/Test.scala | 13 | ||||
-rw-r--r-- | test/files/run/toolbox-varargs/Varargs.java | 8 |
12 files changed, 173 insertions, 23 deletions
diff --git a/test/files/run/private-inline.flags b/test/files/run/private-inline.flags index 00d3643fd4..c550fdce16 100644 --- a/test/files/run/private-inline.flags +++ b/test/files/run/private-inline.flags @@ -1 +1 @@ --optimise -Yinline-warnings +-optimise -Yinline-warnings -Ybackend:GenASM diff --git a/test/files/run/range.scala b/test/files/run/range.scala index 4637ab874d..e50d0ac6a5 100644 --- a/test/files/run/range.scala +++ b/test/files/run/range.scala @@ -36,16 +36,19 @@ object Test { def gr1 = NumericRange(x, x, x) def gr2 = NumericRange.inclusive(x, x, x) - def gr3 = NumericRange(x, x * fromInt(10), x) - def gr4 = NumericRange.inclusive(x, x * fromInt(10), x) - def gr5 = gr3.toList ::: negated.gr3.toList + def gr3 = NumericRange(x, x * fromInt(4), x * fromInt(2)) // SI-9348 + def gr4 = NumericRange(x, x * fromInt(-2), x * fromInt(-2)) + def gr5 = NumericRange(x, x * fromInt(10), x) + def gr6 = NumericRange.inclusive(x, x * fromInt(10), x) + def gr7 = gr3.toList ::: negated.gr3.toList def check = { assert(gr1.isEmpty && !gr2.isEmpty) - assert(gr3.size == 9 && gr4.size == 10) - assert(gr5.sum == num.zero, gr5.toString) - assert(!(gr3 contains (x * fromInt(10)))) - assert((gr4 contains (x * fromInt(10)))) + assert(gr3.size == 2 && gr4.size == 2) + assert(gr5.size == 9 && gr6.size == 10) + assert(gr7.sum == num.zero, gr7.toString) + assert(!(gr5 contains (x * fromInt(10)))) + assert(gr6 contains (x * fromInt(10))) } } @@ -55,6 +58,7 @@ object Test { val _grs = List[GR[_]]( GR(BigDecimal(5.0)), + GR(BigDecimal(0.25)), // SI-9348 GR(BigInt(5)), GR(5L), GR(5.0d), diff --git a/test/files/run/repl-serialization.check b/test/files/run/repl-serialization.check new file mode 100644 index 0000000000..eb62729f5c --- /dev/null +++ b/test/files/run/repl-serialization.check @@ -0,0 +1,25 @@ +== evaluating lines +extract: AnyRef => Unit = <function1> + evaluating x +x: Int = 0 +getX: ()Int +defined class U +y: Int = <lazy> + evaluating z + evaluating zz +defined class D +z: Int = 0 +zz: Int = 0 +defined object O +defined class A +defined type alias AA +constructing U +u: U = U +== evaluating lambda + evaluating y + evaluating O + constructing A +== reconstituting into a fresh classloader + evaluating O +== evaluating reconstituted lambda + constructing A diff --git a/test/files/run/repl-serialization.scala b/test/files/run/repl-serialization.scala new file mode 100644 index 0000000000..55b7519631 --- /dev/null +++ b/test/files/run/repl-serialization.scala @@ -0,0 +1,68 @@ +import java.io._ + +import scala.reflect.io.AbstractFile +import scala.tools.nsc.Settings +import scala.tools.nsc.interpreter.IMain +import scala.tools.nsc.util._ +import scala.reflect.internal.util.AbstractFileClassLoader + +object Test { + def main(args: Array[String]) { + run() + } + + def run(): Unit = { + val settings = new Settings() + settings.Yreplclassbased.value = true + settings.usejavacp.value = true + + var imain: IMain = null + object extract extends ((AnyRef) => Unit) with Serializable { + var value: AnyRef = null + + def apply(a: AnyRef) = value = a + } + + val code = + """val x = {println(" evaluating x"); 0 } + |def getX() = x + |class U extends Serializable { println("constructing U"); val x = 0 ; override def toString = "U" } + |lazy val y = {println(" evaluating y"); 0 } + |class D; val z = {println(" evaluating z"); 0}; val zz = {println(" evaluating zz"); 0} + |object O extends Serializable { val apply = {println(" evaluating O"); 0} } + |class A(i: Int) { println(" constructing A") } + |type AA = A + |val u = new U() + |extract(() => new AA(x + getX() + y + z + zz + O.apply + u.x)) + """.stripMargin + + imain = new IMain(settings) + println("== evaluating lines") + imain.directBind("extract", "(AnyRef => Unit)", extract) + code.lines.foreach(imain.interpret) + + val virtualFile: AbstractFile = extract.value.getClass.getClassLoader.asInstanceOf[AbstractFileClassLoader].root + val newLoader = new AbstractFileClassLoader(virtualFile, getClass.getClassLoader) + + def deserializeInNewLoader(string: Array[Byte]): AnyRef = { + val bis = new ByteArrayInputStream(string) + val in = new ObjectInputStream(bis) { + override def resolveClass(desc: ObjectStreamClass) = Class.forName(desc.getName, false, newLoader) + } + in.readObject() + } + def serialize(o: AnyRef): Array[Byte] = { + val bos = new ByteArrayOutputStream() + val out = new ObjectOutputStream(bos) + out.writeObject(o) + out.close() + bos.toByteArray + } + println("== evaluating lambda") + extract.value.asInstanceOf[() => Any].apply() + println("== reconstituting into a fresh classloader") + val reconstituted = deserializeInNewLoader(serialize(extract.value)).asInstanceOf[() => Any] + println("== evaluating reconstituted lambda") + reconstituted.apply() // should not print("evaluating x") a second time + } +} diff --git a/test/files/run/synchronized.check b/test/files/run/synchronized.check index 9add05ea0c..dd9f4ef424 100644 --- a/test/files/run/synchronized.check +++ b/test/files/run/synchronized.check @@ -1,8 +1,3 @@ -#partest !-Ybackend:GenBCode -warning: there were 14 inliner warnings; re-run with -Yinline-warnings for details -#partest -Ybackend:GenBCode -warning: there were 14 inliner warnings; re-run with -Yopt-warnings for details -#partest .|. c1.f1: OK .|. c1.fi: OK .|... c1.fv: OK diff --git a/test/files/run/synchronized.scala b/test/files/run/synchronized.scala index 1f0e32992b..077e9d02e8 100644 --- a/test/files/run/synchronized.scala +++ b/test/files/run/synchronized.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warnings; re-run with + */ import java.lang.Thread.holdsLock import scala.collection.mutable.StringBuilder diff --git a/test/files/run/t6102.check b/test/files/run/t6102.check index aa3e6cc9e2..07378f5ed4 100644 --- a/test/files/run/t6102.check +++ b/test/files/run/t6102.check @@ -28,5 +28,10 @@ [running phase constopt on t6102.scala] #partest [running phase dce on t6102.scala] +#partest !-Ybackend:GenBCode [running phase jvm on icode] +#partest -Ybackend:GenBCode +[running phase jvm on t6102.scala] +[running phase jvm on t6102.scala] +#partest hello diff --git a/test/files/run/t7747-repl.check b/test/files/run/t7747-repl.check index 105b238d01..5f436ba6b1 100644 --- a/test/files/run/t7747-repl.check +++ b/test/files/run/t7747-repl.check @@ -112,7 +112,7 @@ scala> 55 ; ((2 + 2)) ; (1, 2, 3) res15: (Int, Int, Int) = (1,2,3) scala> 55 ; (x: Int) => x + 1 ; () => ((5)) -<console>:8: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses +<console>:9: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses 55 ; (x: Int) => x + 1 ;; ^ res16: () => Int = <function0> @@ -258,12 +258,12 @@ class $read extends Serializable { super.<init>; () }; - import $line44.$read.$iw.$iw.BippyBups; - import $line44.$read.$iw.$iw.BippyBups; - import $line45.$read.$iw.$iw.PuppyPups; - import $line45.$read.$iw.$iw.PuppyPups; - import $line46.$read.$iw.$iw.Bingo; - import $line46.$read.$iw.$iw.Bingo; + import $line44.$read.INSTANCE.$iw.$iw.BippyBups; + import $line44.$read.INSTANCE.$iw.$iw.BippyBups; + import $line45.$read.INSTANCE.$iw.$iw.PuppyPups; + import $line45.$read.INSTANCE.$iw.$iw.PuppyPups; + import $line46.$read.INSTANCE.$iw.$iw.Bingo; + import $line46.$read.INSTANCE.$iw.$iw.Bingo; class $iw extends Serializable { def <init>() = { super.<init>; @@ -275,12 +275,35 @@ class $read extends Serializable { }; val $iw = new $iw.<init> } -object $read extends $read { +object $read extends scala.AnyRef { def <init>() = { super.<init>; () - } + }; + val INSTANCE = new $read.<init> } res3: List[Product with Serializable] = List(BippyBups(), PuppyPups(), Bingo()) +scala> case class Sum(exp: String, exp2: String) +defined class Sum + +scala> val a = Sum("A", "B") +a: Sum = Sum(A,B) + +scala> def b(a: Sum): String = a match { case Sum(_, _) => "Found Sum" } +b: (a: Sum)String + +scala> b(a) +res4: String = Found Sum + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> intp.lastRequest +res5: $r.intp.Request = Request(line=def $ires3 = intp.global, 1 trees) + scala> :quit diff --git a/test/files/run/t7747-repl.scala b/test/files/run/t7747-repl.scala index 0e64210460..141c2d9844 100644 --- a/test/files/run/t7747-repl.scala +++ b/test/files/run/t7747-repl.scala @@ -65,5 +65,11 @@ object Test extends ReplTest { |case class PuppyPups() |case class Bingo() |List(BippyBups(), PuppyPups(), Bingo()) // show + |case class Sum(exp: String, exp2: String) + |val a = Sum("A", "B") + |def b(a: Sum): String = a match { case Sum(_, _) => "Found Sum" } + |b(a) + |:power + |intp.lastRequest |""".stripMargin } diff --git a/test/files/run/t8601-closure-elim.flags b/test/files/run/t8601-closure-elim.flags index 2b5fd8a7b2..9158076b71 100644 --- a/test/files/run/t8601-closure-elim.flags +++ b/test/files/run/t8601-closure-elim.flags @@ -1 +1 @@ --optimize -Ydelambdafy:inline +-optimize -Ydelambdafy:inline -Ybackend:GenASM diff --git a/test/files/run/toolbox-varargs/Test.scala b/test/files/run/toolbox-varargs/Test.scala new file mode 100644 index 0000000000..be5ab45768 --- /dev/null +++ b/test/files/run/toolbox-varargs/Test.scala @@ -0,0 +1,13 @@ +object Test { + def main(args: Array[String]): Unit = { + import scala.tools.reflect.ToolBox + val m = reflect.runtime.currentMirror + val u = m.universe + import u._ + val tb = m.mkToolBox(); + tb.compile(q"new p.Varargs(null, null)") + tb.compile(q"p.Varargs.staticMethod(null, null)") + tb.compile(q"(null: p.Varargs).instanceMethod(null, null)") + } +} + diff --git a/test/files/run/toolbox-varargs/Varargs.java b/test/files/run/toolbox-varargs/Varargs.java new file mode 100644 index 0000000000..da1dbbacc9 --- /dev/null +++ b/test/files/run/toolbox-varargs/Varargs.java @@ -0,0 +1,8 @@ +package p; + +public class Varargs { + public Varargs(String... args) {} + public static void staticMethod(String... args) {} + + public void instanceMethod(String... args) {} +} |