diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/applydynamic_sip.scala | 2 | ||||
-rw-r--r-- | test/files/run/bitsets.check | 1 | ||||
-rw-r--r-- | test/files/run/icode-reader-dead-code.check | 8 | ||||
-rw-r--r-- | test/files/run/t5313.scala | 2 | ||||
-rw-r--r-- | test/files/run/t6114.scala | 2 | ||||
-rw-r--r-- | test/files/run/t6502.check | 8 | ||||
-rw-r--r-- | test/files/run/t6502.scala | 70 | ||||
-rw-r--r-- | test/files/run/t7459a.scala | 14 | ||||
-rw-r--r-- | test/files/run/t7459b-optimize.flags | 1 | ||||
-rw-r--r-- | test/files/run/t7459b-optimize.scala | 21 | ||||
-rw-r--r-- | test/files/run/t7459b.scala | 21 | ||||
-rw-r--r-- | test/files/run/t7459c.scala | 16 | ||||
-rw-r--r-- | test/files/run/t7459d.scala | 15 | ||||
-rw-r--r-- | test/files/run/t7459f.scala | 12 | ||||
-rw-r--r-- | test/files/run/t7965.scala | 54 | ||||
-rw-r--r-- | test/files/run/t8253.scala | 2 | ||||
-rw-r--r-- | test/files/run/t9030.scala | 19 |
17 files changed, 236 insertions, 32 deletions
diff --git a/test/files/run/applydynamic_sip.scala b/test/files/run/applydynamic_sip.scala index cf918a82ed..47d0c6a303 100644 --- a/test/files/run/applydynamic_sip.scala +++ b/test/files/run/applydynamic_sip.scala @@ -40,7 +40,7 @@ object Test extends App { // qual.sel(arg = a, a2: _*) // qual.sel(arg, arg2 = "a2", a2: _*) - // If qual.sel appears immediately on the left-hand side of an assigment + // If qual.sel appears immediately on the left-hand side of an assignment // qual.updateDynamic(“sel”)(expr) qual.sel = expr diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check index 41c2ccdcb8..c24fd6238f 100644 --- a/test/files/run/bitsets.check +++ b/test/files/run/bitsets.check @@ -1,3 +1,4 @@ +warning: there were three deprecation warnings; re-run with -deprecation for details ms0 = BitSet(2) ms1 = BitSet(2) ms2 = BitSet(2) diff --git a/test/files/run/icode-reader-dead-code.check b/test/files/run/icode-reader-dead-code.check index d1739fed3b..c9de93283e 100644 --- a/test/files/run/icode-reader-dead-code.check +++ b/test/files/run/icode-reader-dead-code.check @@ -1,4 +1,7 @@ Bytecode for method f + + // access flags 0x11 + public final f()I L0 LINENUMBER 4 L0 ICONST_1 @@ -7,7 +10,11 @@ Bytecode for method f LOCALVARIABLE this Lp/A; L0 L1 0 MAXSTACK = 1 MAXLOCALS = 1 + Bytecode for method f + + // access flags 0x11 + public final f()I L0 LINENUMBER 4 L0 ICONST_1 @@ -17,3 +24,4 @@ Bytecode for method f LOCALVARIABLE this Lp/A; L0 L1 0 MAXSTACK = 1 MAXLOCALS = 1 + diff --git a/test/files/run/t5313.scala b/test/files/run/t5313.scala index 0d7168fa89..7f5af74c3f 100644 --- a/test/files/run/t5313.scala +++ b/test/files/run/t5313.scala @@ -11,7 +11,7 @@ object Test extends IcodeComparison { def bar = { var kept1 = new Object val result = new java.lang.ref.WeakReference(kept1) - kept1 = null // we can't eliminate this assigment because result can observe + kept1 = null // we can't eliminate this assignment because result can observe // when the object has no more references. See SI-5313 kept1 = new Object // but we can eliminate this one because kept1 has already been clobbered var erased2 = null // we can eliminate this store because it's never used diff --git a/test/files/run/t6114.scala b/test/files/run/t6114.scala index cb880ece00..8ad02d5bb2 100644 --- a/test/files/run/t6114.scala +++ b/test/files/run/t6114.scala @@ -51,7 +51,7 @@ object Test extends App { val next = list.asScala ++ List(4,5,6) assert(next != list.asScala) - // Note: Clone is hidden at this level, so no overriden cloning. + // Note: Clone is hidden at this level, so no overridden cloning. } testList diff --git a/test/files/run/t6502.check b/test/files/run/t6502.check deleted file mode 100644 index 95d36ee221..0000000000 --- a/test/files/run/t6502.check +++ /dev/null @@ -1,8 +0,0 @@ -test1 res1: true -test1 res2: true -test2 res1: true -test2 res2: true -test3 res1: true -test3 res2: true -test4 res1: true -test4 res2: true diff --git a/test/files/run/t6502.scala b/test/files/run/t6502.scala index 4ce034a482..52fabef6b8 100644 --- a/test/files/run/t6502.scala +++ b/test/files/run/t6502.scala @@ -46,6 +46,12 @@ object Test extends StoreReporterDirectTest { } }""" + def app6 = """ + package test6 + class A extends Test { println("created test6.A") } + class Z extends Test { println("created test6.Z") } + trait Test""" + def test1(): Unit = { val jar = "test1.jar" compileCode(app1, jar) @@ -53,11 +59,12 @@ object Test extends StoreReporterDirectTest { val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "test.Test.test()") val output = ILoop.run(codeToRun, settings) val lines = output.split("\n") - val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") - val res2 = lines(lines.length-3).contains("testing...") - - println(s"test1 res1: $res1") - println(s"test1 res2: $res2") + assert { + lines(4).contains("Added") && lines(4).contains("test1.jar") + } + assert { + lines(lines.length-3).contains("testing...") + } } def test2(): Unit = { @@ -69,11 +76,12 @@ object Test extends StoreReporterDirectTest { val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar2") val output = ILoop.run(codeToRun, settings) val lines = output.split("\n") - val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") - val res2 = lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict") - - println(s"test2 res1: $res1") - println(s"test2 res2: $res2") + assert { + lines(4).contains("Added") && lines(4).contains("test1.jar") + } + assert { + lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + } } def test3(): Unit = { @@ -85,11 +93,12 @@ object Test extends StoreReporterDirectTest { val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar3", "test.Test3.test()") val output = ILoop.run(codeToRun, settings) val lines = output.split("\n") - val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") - val res2 = lines(lines.length-3).contains("new object in existing package") - - println(s"test3 res1: $res1") - println(s"test3 res2: $res2") + assert { + lines(4).contains("Added") && lines(4).contains("test1.jar") + } + assert { + lines(lines.length-3).contains("new object in existing package") + } } def test4(): Unit = { @@ -98,11 +107,30 @@ object Test extends StoreReporterDirectTest { val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar1") val output = ILoop.run(codeToRun, settings) val lines = output.split("\n") - val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") - val res2 = lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + assert { + lines(4).contains("Added") && lines(4).contains("test1.jar") + } + assert { + lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + } + } - println(s"test4 res1: $res1") - println(s"test4 res2: $res2") + def test5(): Unit = { + val codeToRun = ":require /does/not/exist.jar" + val output = ILoop.run(codeToRun, settings) + assert(!output.contains("NullPointerException"), output) + assert(output.contains("Cannot load '/does/not/exist.jar'"), output) + } + + def test6(): Unit = { + // Avoid java.lang.NoClassDefFoundError triggered by the old appoach of using a Java + // classloader to parse .class files in order to read their names. + val jar = "test6.jar" + compileCode(app6, jar) + val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "import test6._; new A; new Z") + val output = ILoop.run(codeToRun, settings) + assert(output.contains("created test6.A"), output) + assert(output.contains("created test6.Z"), output) } def show(): Unit = { @@ -110,7 +138,9 @@ object Test extends StoreReporterDirectTest { test2() test3() test4() + test5() + test6() } - def toCodeInSeparateLines(lines: String*): String = lines.map(_ + "\n").mkString + def toCodeInSeparateLines(lines: String*): String = lines mkString "\n" } diff --git a/test/files/run/t7459a.scala b/test/files/run/t7459a.scala new file mode 100644 index 0000000000..e9653c6e79 --- /dev/null +++ b/test/files/run/t7459a.scala @@ -0,0 +1,14 @@ +class LM { + class Node[B1] + case class CC(n: LM) + + // crash + val f: (LM => Any) = { + case tttt => + new tttt.Node[Any]() + } +} + +object Test extends App { + new LM().f(new LM()) +} diff --git a/test/files/run/t7459b-optimize.flags b/test/files/run/t7459b-optimize.flags new file mode 100644 index 0000000000..49d036a887 --- /dev/null +++ b/test/files/run/t7459b-optimize.flags @@ -0,0 +1 @@ +-optimize diff --git a/test/files/run/t7459b-optimize.scala b/test/files/run/t7459b-optimize.scala new file mode 100644 index 0000000000..605890962c --- /dev/null +++ b/test/files/run/t7459b-optimize.scala @@ -0,0 +1,21 @@ +class LM { + class Node[B1] + + // crash + val g: (CC => Any) = { + case CC(tttt) => + new tttt.Node[Any]() + } + + val h: (Some[CC] => Any) = { + case Some(CC(tttt)) => + new tttt.Node[Any]() + } +} + +object Test extends App { + new LM().g(new CC(new LM())) + new LM().h(Some(new CC(new LM()))) +} +case class CC(n: LM) + diff --git a/test/files/run/t7459b.scala b/test/files/run/t7459b.scala new file mode 100644 index 0000000000..605890962c --- /dev/null +++ b/test/files/run/t7459b.scala @@ -0,0 +1,21 @@ +class LM { + class Node[B1] + + // crash + val g: (CC => Any) = { + case CC(tttt) => + new tttt.Node[Any]() + } + + val h: (Some[CC] => Any) = { + case Some(CC(tttt)) => + new tttt.Node[Any]() + } +} + +object Test extends App { + new LM().g(new CC(new LM())) + new LM().h(Some(new CC(new LM()))) +} +case class CC(n: LM) + diff --git a/test/files/run/t7459c.scala b/test/files/run/t7459c.scala new file mode 100644 index 0000000000..144c5d793b --- /dev/null +++ b/test/files/run/t7459c.scala @@ -0,0 +1,16 @@ +class LM { + class Node[B1] + + // crash + val g: (CC => Any) = { + case CC(tttt) => + tttt.## // no crash + new tttt.Node[Any]() + } +} + +object Test extends App { + new LM().g(new CC(new LM())) +} +case class CC(n: LM) + diff --git a/test/files/run/t7459d.scala b/test/files/run/t7459d.scala new file mode 100644 index 0000000000..3263701f9d --- /dev/null +++ b/test/files/run/t7459d.scala @@ -0,0 +1,15 @@ +class LM { + class Node[B1] + case class CC(n: LM) + + // crash + val f: (LM => Any) = { + case tttt => + val uuuu: (tttt.type, Any) = (tttt, 0) + new uuuu._1.Node[Any]() + } +} + +object Test extends App { + new LM().f(new LM()) +} diff --git a/test/files/run/t7459f.scala b/test/files/run/t7459f.scala new file mode 100644 index 0000000000..63e2109560 --- /dev/null +++ b/test/files/run/t7459f.scala @@ -0,0 +1,12 @@ +object Test extends App { + class C + + case class FooSeq(x: Int, y: String, z: C*) + + FooSeq(1, "a", new C()) match { + case FooSeq(1, "a", x@_* ) => + //println(x.toList) + x.asInstanceOf[x.type] + assert(x.isInstanceOf[x.type]) + } +} diff --git a/test/files/run/t7965.scala b/test/files/run/t7965.scala new file mode 100644 index 0000000000..df80d4b5bb --- /dev/null +++ b/test/files/run/t7965.scala @@ -0,0 +1,54 @@ +// Test that scala doesn't apply boxing or varargs conversions to the +// @PolymorphicSignature magical methods, MethodHandle#{invoke, invokeExact} +object Test { + val code = """ + +object O { + private def foo = "foo" + private def bar(x: Int): Int = -x + private def baz(x: Box): Unit = x.a = "present" + val lookup = java.lang.invoke.MethodHandles.lookup +} + +import java.lang.invoke._ +class Box(var a: Any) + +object Test { + def main(args: Array[String]): Unit = { + def lookup(name: String, params: Array[Class[_]], ret: Class[_]) = { + val mt = MethodType.methodType(ret, params) + O.lookup.findVirtual(O.getClass, name, mt) + } + val fooResult = (lookup("foo", Array(), classOf[String]).invokeExact(O): Int) + assert(fooResult == "foo") + + val barResult = (lookup("bar", Array(classOf[Int]), classOf[Int]).invokeExact(O, 42): Int) + assert(barResult == -42) + + val box = new Box(null) + (lookup("baz", Array(classOf[Box]), Void.TYPE).invokeExact(O, box) : Unit) + assert(box.a == "present") + + // Note: Application in statement position in a block in Java also infers return type of Unit, + // but we don't support that, ascribe the type to Unit as above. + // as done in Java. + // lookup("baz", Array(classOf[Box]), Void.TYPE).invokeExact(O, box) + () + } +} + +""" + def main(args: Array[String]): Unit = { + if (util.Properties.isJavaAtLeast("1.7")) test() + } + + def test() { + import scala.reflect.runtime._ + import scala.tools.reflect.ToolBox + + val m = currentMirror + val tb = m.mkToolBox() + import tb._ + eval(parse(code)) + } +} diff --git a/test/files/run/t8253.scala b/test/files/run/t8253.scala index c4800b4491..a00d8b91a4 100644 --- a/test/files/run/t8253.scala +++ b/test/files/run/t8253.scala @@ -10,5 +10,5 @@ object Test extends App { show("<sample xmlns:foo={identity(ns1)}/>", q"<sample xmlns:foo={ns1}/>") // `identity(foo)` used to match the overly permissive match in SymbolXMLBuilder - // which was intented to more specifically match `_root_.scala.xml.Text(...)` + // which was intended to more specifically match `_root_.scala.xml.Text(...)` } diff --git a/test/files/run/t9030.scala b/test/files/run/t9030.scala new file mode 100644 index 0000000000..48d24e5b54 --- /dev/null +++ b/test/files/run/t9030.scala @@ -0,0 +1,19 @@ +object Test extends App { + + // For these methods, the compiler emits calls to BoxesRuntime.equalsNumNum/equalsNumChar/equalsNumObject directly + + def numNum(a: java.lang.Number, b: java.lang.Number) = assert(a == b) + def numChar(a: java.lang.Number, b: java.lang.Character) = assert(a == b) + def numObject(a: java.lang.Number, b: java.lang.Object) = assert(a == b) + + // The compiler doesn't use equalsCharObject directly, but still adding an example for completeness + + def charObject(a: java.lang.Character, b: java.lang.Object) = assert(a == b) + + numNum(new Integer(1), new Integer(1)) + numChar(new Integer(97), new Character('a')) + numObject(new Integer(1), new Integer(1)) + numObject(new Integer(97), new Character('a')) + + charObject(new Character('a'), new Integer(97)) +} |