diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-18 17:37:42 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-18 17:37:42 +0200 |
commit | 79026e6975b1f27750be968eab239ad456ebd64f (patch) | |
tree | 24434575d356948cdb19a73ddc7a16034c103a76 /test/files | |
parent | 2e34310cb1c82d8589d7c222d9d7c9352f3e944b (diff) | |
parent | 019f0c6d81b6979754563ecbf62a846c99823110 (diff) | |
download | scala-79026e6975b1f27750be968eab239ad456ebd64f.tar.gz scala-79026e6975b1f27750be968eab239ad456ebd64f.tar.bz2 scala-79026e6975b1f27750be968eab239ad456ebd64f.zip |
Merge branch '2.10.x'
Diffstat (limited to 'test/files')
72 files changed, 394 insertions, 308 deletions
diff --git a/test/files/instrumented/InstrumentationTest.check b/test/files/instrumented/InstrumentationTest.check new file mode 100644 index 0000000000..3652df270a --- /dev/null +++ b/test/files/instrumented/InstrumentationTest.check @@ -0,0 +1,4 @@ +true +Method call statistics: + 1 scala/Predef$.println(Ljava/lang/Object;)V + 1 scala/runtime/BoxesRunTime.boxToBoolean(Z)Ljava/lang/Boolean; diff --git a/test/files/instrumented/InstrumentationTest.scala b/test/files/instrumented/InstrumentationTest.scala new file mode 100644 index 0000000000..ec5314c624 --- /dev/null +++ b/test/files/instrumented/InstrumentationTest.scala @@ -0,0 +1,14 @@ +import scala.tools.partest.instrumented.Instrumentation._ + +/** Tests if instrumentation itself works correctly */ +object Test { + def main(args: Array[String]) { + // force predef initialization before profiling + Predef + startProfiling() + // should box the boolean + println(true) + stopProfiling() + printStatistics() + } +} diff --git a/test/files/instrumented/README b/test/files/instrumented/README new file mode 100644 index 0000000000..32d0ef2da5 --- /dev/null +++ b/test/files/instrumented/README @@ -0,0 +1,15 @@ +Tests in `instrumented` directory are executed the same way as in `run` but +they have additional byte-code instrumentation performed for profiling. You +should put your tests in `instrumented` directory if you are interested in +method call counts. Examples include tests for specialization (you want to +count boxing and unboxing method calls) or high-level tests for optimizer +where you are interested if methods are successfuly inlined (so they should +not be called at runtime) or closures are eliminated (so no constructors +of closures are called). + +Check `scala.tools.partest.instrumented.Instrumentation` to learn how to +use the instrumentation infrastructure. + +The instrumentation itself is achieved by attaching a Java agent to the forked +VM process that injects calls to profiler. Check +`scala.tools.partest.instrumented.Instrumentation`. diff --git a/test/files/neg/t1286.check b/test/files/neg/t1286.check index c937fb9cf1..912709613c 100644 --- a/test/files/neg/t1286.check +++ b/test/files/neg/t1286.check @@ -1,9 +1,5 @@ -a.scala:1: error: Companions 'object Foo' and 'trait Foo' must be defined in same file: - Found in t1286/b.scala and t1286/a.scala -trait Foo { - ^ b.scala:1: error: Companions 'trait Foo' and 'object Foo' must be defined in same file: Found in t1286/a.scala and t1286/b.scala object Foo extends Foo { ^ -two errors found +one error found diff --git a/test/files/neg/t5830.check b/test/files/neg/t5830.check index 85cb84378f..726fac2a1e 100644 --- a/test/files/neg/t5830.check +++ b/test/files/neg/t5830.check @@ -1,4 +1,7 @@ t5830.scala:6: error: unreachable code case 'a' => println("b") // unreachable ^ -one error found +t5830.scala:4: error: could not emit switch for @switch annotated match + def unreachable(ch: Char) = (ch: @switch) match { + ^ +two errors found diff --git a/test/files/neg/t5956.check b/test/files/neg/t5956.check new file mode 100644 index 0000000000..6641dac97f --- /dev/null +++ b/test/files/neg/t5956.check @@ -0,0 +1,20 @@ +t5956.scala:1: warning: case classes without a parameter list have been deprecated; +use either case objects or case classes with `()' as parameter list. +object O { case class C[T]; class C } + ^ +t5956.scala:2: warning: case classes without a parameter list have been deprecated; +use either case objects or case classes with `()' as parameter list. +object T { case class C[T]; case class C } + ^ +t5956.scala:2: warning: case classes without a parameter list have been deprecated; +use either case objects or case classes with `()' as parameter list. +object T { case class C[T]; case class C } + ^ +t5956.scala:1: error: C is already defined as case class C +object O { case class C[T]; class C } + ^ +t5956.scala:2: error: C is already defined as case class C +object T { case class C[T]; case class C } + ^ +three warnings found +two errors found diff --git a/test/files/neg/t5956.scala b/test/files/neg/t5956.scala new file mode 100644 index 0000000000..d985fa97a4 --- /dev/null +++ b/test/files/neg/t5956.scala @@ -0,0 +1,2 @@ +object O { case class C[T]; class C } +object T { case class C[T]; case class C } diff --git a/test/files/neg/t6011.check b/test/files/neg/t6011.check new file mode 100644 index 0000000000..5b5a861e5b --- /dev/null +++ b/test/files/neg/t6011.check @@ -0,0 +1,10 @@ +t6011.scala:4: error: unreachable code + case 'a' | 'c' => 1 // unreachable + ^ +t6011.scala:10: error: unreachable code + case 'b' | 'a' => 1 // unreachable + ^ +t6011.scala:8: error: could not emit switch for @switch annotated match + def f2(ch: Char): Any = (ch: @annotation.switch) match { + ^ +three errors found diff --git a/test/files/neg/t6011.flags b/test/files/neg/t6011.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t6011.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t6011.scala b/test/files/neg/t6011.scala new file mode 100644 index 0000000000..a36cca7897 --- /dev/null +++ b/test/files/neg/t6011.scala @@ -0,0 +1,23 @@ +object Test { + def f(ch: Char): Any = ch match { + case 'a' => 1 + case 'a' | 'c' => 1 // unreachable + } + + // won't be compiled to a switch since it has an unreachable (duplicate) case + def f2(ch: Char): Any = (ch: @annotation.switch) match { + case 'a' | 'b' => 1 + case 'b' | 'a' => 1 // unreachable + case _ => + } + + // s'all good + def f3(ch: Char): Any = (ch: @annotation.switch) match { + case 'a' | 'b' if (true: Boolean) => 1 + case 'b' | 'a' => 1 // ok + case _ => // need third case to check switch annotation (two-case switches are always okay to compile to if-then-else) + } + + + def main(args: Array[String]): Unit = f('a') +}
\ No newline at end of file diff --git a/test/files/neg/t6048.check b/test/files/neg/t6048.check new file mode 100644 index 0000000000..051f41877e --- /dev/null +++ b/test/files/neg/t6048.check @@ -0,0 +1,10 @@ +t6048.scala:3: error: unreachable code + case _ if false => x // unreachable + ^ +t6048.scala:8: error: unreachable code + case _ if false => x // unreachable + ^ +t6048.scala:14: error: unreachable code + case 5 if true => x // unreachable + ^ +three errors found diff --git a/test/files/neg/t6048.flags b/test/files/neg/t6048.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t6048.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t6048.scala b/test/files/neg/t6048.scala new file mode 100644 index 0000000000..803e651d19 --- /dev/null +++ b/test/files/neg/t6048.scala @@ -0,0 +1,22 @@ +class A { + def f1(x: Int) = x match { + case _ if false => x // unreachable + case 5 => x + } + + def f2(x: Int) = x match { + case _ if false => x // unreachable + case 5 if true => x + } + + def f3(x: Int) = x match { + case _ => x + case 5 if true => x // unreachable + } + + def test1(x: Int) = x match { + case c if c < 0 => 0 + case 1 => 1 + case _ => 2 + } +} diff --git a/test/files/pos/t1751.cmds b/test/files/pos/t1751.cmds deleted file mode 100644 index d4a4898ffd..0000000000 --- a/test/files/pos/t1751.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac SuiteClasses.java -scalac A2_1.scala -scalac A1_2.scala diff --git a/test/files/pos/t1751/A1_2.scala b/test/files/pos/t1751/A1_2.scala deleted file mode 100644 index 354d5eecd0..0000000000 --- a/test/files/pos/t1751/A1_2.scala +++ /dev/null @@ -1,2 +0,0 @@ -@SuiteClasses(Array(classOf[A2])) -class A1 diff --git a/test/files/pos/t1751/A2_1.scala b/test/files/pos/t1751/A2_1.scala deleted file mode 100644 index c768062e43..0000000000 --- a/test/files/pos/t1751/A2_1.scala +++ /dev/null @@ -1,2 +0,0 @@ -@SuiteClasses(Array()) -class A2 diff --git a/test/files/pos/t1751/SuiteClasses.java b/test/files/pos/t1751/SuiteClasses.java deleted file mode 100644 index a415e4f572..0000000000 --- a/test/files/pos/t1751/SuiteClasses.java +++ /dev/null @@ -1,3 +0,0 @@ -public @interface SuiteClasses { - public Class<?>[] value(); -} diff --git a/test/files/pos/t1782.cmds b/test/files/pos/t1782.cmds deleted file mode 100644 index 61f3d3788e..0000000000 --- a/test/files/pos/t1782.cmds +++ /dev/null @@ -1,2 +0,0 @@ -javac Ann.java Days.java ImplementedBy.java -scalac Test_1.scala diff --git a/test/files/pos/t1782/Ann.java b/test/files/pos/t1782/Ann.java deleted file mode 100644 index 0dcfbd2ed7..0000000000 --- a/test/files/pos/t1782/Ann.java +++ /dev/null @@ -1,3 +0,0 @@ -public @interface Ann { - public Days value(); -} diff --git a/test/files/pos/t1782/Days.java b/test/files/pos/t1782/Days.java deleted file mode 100644 index 203a87b1c2..0000000000 --- a/test/files/pos/t1782/Days.java +++ /dev/null @@ -1,3 +0,0 @@ -public enum Days { - Friday, Sunday -} diff --git a/test/files/pos/t1782/ImplementedBy.java b/test/files/pos/t1782/ImplementedBy.java deleted file mode 100644 index 6aa8b4fa9e..0000000000 --- a/test/files/pos/t1782/ImplementedBy.java +++ /dev/null @@ -1,3 +0,0 @@ -public @interface ImplementedBy { - public Class<?> value(); -} diff --git a/test/files/pos/t1782/Test_1.scala b/test/files/pos/t1782/Test_1.scala deleted file mode 100644 index 6467a74c29..0000000000 --- a/test/files/pos/t1782/Test_1.scala +++ /dev/null @@ -1,16 +0,0 @@ -@ImplementedBy(classOf[Provider]) -trait Service { - def someMethod() -} - -class Provider - extends Service -{ - // test enumeration java annotations - @Ann(Days.Friday) def someMethod() = () - - // #2103 - @scala.beans.BeanProperty - @Ann(value = Days.Sunday) - val t2103 = "test" -} diff --git a/test/files/pos/t294.cmds b/test/files/pos/t294.cmds deleted file mode 100644 index 62c9a5a068..0000000000 --- a/test/files/pos/t294.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac Ann.java Ann2.java -scalac Test_1.scala -scalac Test_2.scala diff --git a/test/files/pos/t294/Ann.java b/test/files/pos/t294/Ann.java deleted file mode 100644 index 934ca46297..0000000000 --- a/test/files/pos/t294/Ann.java +++ /dev/null @@ -1,3 +0,0 @@ -public @interface Ann { - public Ann2[] nested(); -} diff --git a/test/files/pos/t294/Ann2.java b/test/files/pos/t294/Ann2.java deleted file mode 100644 index 025b79e794..0000000000 --- a/test/files/pos/t294/Ann2.java +++ /dev/null @@ -1,3 +0,0 @@ -public @interface Ann2 { - public int value(); -} diff --git a/test/files/pos/t294/Test_1.scala b/test/files/pos/t294/Test_1.scala deleted file mode 100644 index ff1f34b10e..0000000000 --- a/test/files/pos/t294/Test_1.scala +++ /dev/null @@ -1,7 +0,0 @@ -// also test pickling of java annotations; Test_2.scala will -// read this class file -@Ann(nested = Array(new Ann2(10))) class Test { - @Ann2(100) var ctx: Object = _ - @Ann(nested = Array()) def foo = 10 - @Ann(nested = Array(new Ann2(10), new Ann2(23))) val bam = -3 -} diff --git a/test/files/pos/t294/Test_2.scala b/test/files/pos/t294/Test_2.scala deleted file mode 100644 index 9fb1c6e175..0000000000 --- a/test/files/pos/t294/Test_2.scala +++ /dev/null @@ -1 +0,0 @@ -class Test2 extends Test diff --git a/test/files/pos/t6028/t6028_1.scala b/test/files/pos/t6028/t6028_1.scala new file mode 100644 index 0000000000..6edb76069e --- /dev/null +++ b/test/files/pos/t6028/t6028_1.scala @@ -0,0 +1,3 @@ +class C { + def foo(a: Int): Unit = () => a +} diff --git a/test/files/pos/t6028/t6028_2.scala b/test/files/pos/t6028/t6028_2.scala new file mode 100644 index 0000000000..f44048c0ab --- /dev/null +++ b/test/files/pos/t6028/t6028_2.scala @@ -0,0 +1,4 @@ +object Test { + // ensure that parameter names are untouched by lambdalift + new C().foo(a = 0) +} diff --git a/test/files/run/reflect-resolveoverload-invalid.scala b/test/files/run/reflect-resolveoverload-invalid.scala index def28ccbb4..8c5dc9f94b 100644 --- a/test/files/run/reflect-resolveoverload-invalid.scala +++ b/test/files/run/reflect-resolveoverload-invalid.scala @@ -27,7 +27,7 @@ object Test extends App { val d = t member u.newTermName("d") asTermSymbol val e = t member u.newTermName("e") asTermSymbol - val n1 = a.resolveOverloaded(posVargs = List(u.typeOf[Char])) + val n1 = a.resolveOverloaded(posVargs = List(u.typeOf[Long])) val n2 = b.resolveOverloaded(posVargs = List(u.typeOf[A])) val n3 = c.resolveOverloaded(posVargs = List(u.typeOf[B], u.typeOf[B])) val n4 = d.resolveOverloaded(targs = List(u.typeOf[Int])) diff --git a/test/files/run/reflect-resolveoverload2.scala b/test/files/run/reflect-resolveoverload2.scala index b5f719814b..a800a3e92c 100644 --- a/test/files/run/reflect-resolveoverload2.scala +++ b/test/files/run/reflect-resolveoverload2.scala @@ -2,16 +2,20 @@ class A class B extends A class C { - def a(x: Int) = 1 - def a(x: String) = 2 - //def b(x: => Int)(s: String) = 1 - //def b(x: => String)(a: Array[_]) = 2 - def c(x: A) = 1 - def c(x: B) = 2 - //def d(x: => A)(s: String) = 1 - //def d(x: => B)(a: Array[_]) = 2 - def e(x: A) = 1 - def e(x: B = new B) = 2 + def a(x: Int) = 1 + def a(x: String) = 2 + //def b(x: => Int)(s: String) = 1 + //def b(x: => String)(a: Array[_]) = 2 + def c(x: A) = 1 + def c(x: B) = 2 + //def d(x: => A)(s: String) = 1 + //def d(x: => B)(a: Array[_]) = 2 + def e(x: A) = 1 + def e(x: B = new B) = 2 + def f(x: Int) = 1 + def f(x: String) = 2 + def f(x: Long) = 3 + def f(x: Double) = 4 } object Test extends App { @@ -29,6 +33,8 @@ object Test extends App { } assert(c.a(1) == invoke("a", 1, u.typeOf[Int])) assert(c.a("a") == invoke("a", "a", u.typeOf[String])) + assert(c.a('a') == invoke("a", 'a', u.typeOf[Char])) + assert(c.a(3: Byte) == invoke("a", 3: Byte, u.typeOf[Byte])) //assert(c.b(1)(null) == invoke("b", 1, u.typeOf[Int])) //assert(c.b("a")(null) == invoke("b", "a", u.typeOf[String])) assert(c.c(new A) == invoke("c", new A, u.typeOf[A])) @@ -37,4 +43,9 @@ object Test extends App { //assert(c.d(new B)(null) == invoke("d", new B, u.typeOf[B])) assert(c.e(new A) == invoke("e", new A, u.typeOf[A])) assert(c.e(new B) == invoke("e", new B, u.typeOf[B])) + assert(c.f(1: Short) == invoke("f", 1: Short, u.typeOf[Short])) + assert(c.f(2) == invoke("f", 2, u.typeOf[Int])) + assert(c.f(3L) == invoke("f", 3L, u.typeOf[Long])) + assert(c.f(4f) == invoke("f", 4f, u.typeOf[Float])) + assert(c.f(5d) == invoke("f", 5d, u.typeOf[Double])) } diff --git a/test/files/run/t3897.check b/test/files/run/t3897.check deleted file mode 100644 index 244b83716f..0000000000 --- a/test/files/run/t3897.check +++ /dev/null @@ -1,8 +0,0 @@ -(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) -(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) -(messages,scala.collection.mutable.MutableList<java.lang.String>) -(messages,scala.collection.mutable.MutableList<java.lang.String>) -(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) -(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) -(messages,scala.collection.mutable.MutableList<java.lang.String>) -(messages,scala.collection.mutable.MutableList<java.lang.String>) diff --git a/test/files/run/t3897/J_2.java b/test/files/run/t3897/J_2.java deleted file mode 100644 index 178412dc92..0000000000 --- a/test/files/run/t3897/J_2.java +++ /dev/null @@ -1,27 +0,0 @@ -import java.lang.reflect.*; - -public class J_2 { - public void f1(Class<?> clazz) { - Field[] fields = clazz.getDeclaredFields(); - for (int i = 0 ; i < fields.length; i++) { - String name = fields[i].getName(); - if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { } - else System.out.println("(" + name + "," + fields[i].getGenericType() + ")"); - } - } - public void f2(Class<?> clazz) { - Method[] methods = clazz.getDeclaredMethods(); - for (int i = 0 ; i < methods.length; i++) { - String name = methods[i].getName(); - if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { } - else System.out.println("(" + name + "," + methods[i].getGenericReturnType() + ")"); - } - } - - public void javaRun() { - f1(One.class); - f2(One.class); - f1(Two.class); - f2(Two.class); - } -}
\ No newline at end of file diff --git a/test/files/run/t3897/a_1.scala b/test/files/run/t3897/a_1.scala deleted file mode 100644 index 4da959e2ac..0000000000 --- a/test/files/run/t3897/a_1.scala +++ /dev/null @@ -1,8 +0,0 @@ -class One { - private val messages = new collection.mutable.MutableList[String] - List("a") foreach { messages += _ } -} - -class Two { - private val messages = new collection.mutable.MutableList[String] -} diff --git a/test/files/run/t3897/a_2.scala b/test/files/run/t3897/a_2.scala deleted file mode 100644 index 4d9e59ef05..0000000000 --- a/test/files/run/t3897/a_2.scala +++ /dev/null @@ -1,23 +0,0 @@ -object Test { - def f1(clazz: Class[_]) = ( - clazz.getDeclaredFields.toList - . filterNot (_.getName contains "bitmap$") - . map (f => (f.getName, f.getGenericType)) - . foreach (println) - ) - def f2(clazz: Class[_]) = ( - clazz.getDeclaredMethods.toList - . filterNot (_.getName contains "bitmap$") - . map (f => (f.getName, f.getGenericReturnType)) - . foreach (println) - ) - - def main(args: Array[String]): Unit = { - f1(classOf[One]) - f2(classOf[One]) - f1(classOf[Two]) - f2(classOf[Two]) - - new J_2().javaRun - } -} diff --git a/test/files/run/t5293-map.scala b/test/files/run/t5293-map.scala deleted file mode 100644 index 2707aed07e..0000000000 --- a/test/files/run/t5293-map.scala +++ /dev/null @@ -1,88 +0,0 @@ - - - -import scala.collection.JavaConverters._ - - - -object Test extends App { - - def bench(label: String)(body: => Unit): Long = { - val start = System.nanoTime - - 0.until(10).foreach(_ => body) - - val end = System.nanoTime - - //println("%s: %s ms".format(label, (end - start) / 1000.0 / 1000.0)) - - end - start - } - - def benchJava(values: java.util.Map[Int, Int]) = { - bench("Java Map") { - val m = new java.util.HashMap[Int, Int] - - m.putAll(values) - } - } - - def benchScala(values: Iterable[(Int, Int)]) = { - bench("Scala Map") { - val m = new scala.collection.mutable.HashMap[Int, Int] - - m ++= values - } - } - - def benchScalaSorted(values: Iterable[(Int, Int)]) = { - bench("Scala Map sorted") { - val m = new scala.collection.mutable.HashMap[Int, Int] - - m ++= values.toArray.sorted - } - } - - def benchScalaPar(values: Iterable[(Int, Int)]) = { - bench("Scala ParMap") { - val m = new scala.collection.parallel.mutable.ParHashMap[Int, Int] map { x => x } - - m ++= values - } - } - - val total = 50000 - val values = (0 until total) zip (0 until total) - val map = scala.collection.mutable.HashMap.empty[Int, Int] - - map ++= values - - // warmup - for (x <- 0 until 5) { - benchJava(map.asJava) - benchScala(map) - benchScalaPar(map) - benchJava(map.asJava) - benchScala(map) - benchScalaPar(map) - } - - val javamap = benchJava(map.asJava) - val scalamap = benchScala(map) - val scalaparmap = benchScalaPar(map) - - // println(javamap) - // println(scalamap) - // println(scalaparmap) - - assert(scalamap < (javamap * 10), "scalamap: " + scalamap + " vs. javamap: " + javamap) - assert(scalaparmap < (javamap * 10), "scalaparmap: " + scalaparmap + " vs. javamap: " + javamap) -} - - - - - - - - diff --git a/test/files/run/t5293.scala b/test/files/run/t5293.scala deleted file mode 100644 index 01ead45d2a..0000000000 --- a/test/files/run/t5293.scala +++ /dev/null @@ -1,83 +0,0 @@ - - - -import scala.collection.JavaConverters._ - - - -object Test extends App { - - def bench(label: String)(body: => Unit): Long = { - val start = System.nanoTime - - 0.until(10).foreach(_ => body) - - val end = System.nanoTime - - //println("%s: %s ms".format(label, (end - start) / 1000.0 / 1000.0)) - - end - start - } - - def benchJava(values: java.util.Collection[Int]) = { - bench("Java Set") { - val set = new java.util.HashSet[Int] - - set.addAll(values) - } - } - - def benchScala(values: Iterable[Int]) = { - bench("Scala Set") { - val set = new scala.collection.mutable.HashSet[Int] - - set ++= values - } - } - - def benchScalaSorted(values: Iterable[Int]) = { - bench("Scala Set sorted") { - val set = new scala.collection.mutable.HashSet[Int] - - set ++= values.toArray.sorted - } - } - - def benchScalaPar(values: Iterable[Int]) = { - bench("Scala ParSet") { - val set = new scala.collection.parallel.mutable.ParHashSet[Int] map { x => x } - - set ++= values - } - } - - val values = 0 until 50000 - val set = scala.collection.mutable.HashSet.empty[Int] - - set ++= values - - // warmup - for (x <- 0 until 5) { - benchJava(set.asJava) - benchScala(set) - benchScalaPar(set) - benchJava(set.asJava) - benchScala(set) - benchScalaPar(set) - } - - val javaset = benchJava(set.asJava) - val scalaset = benchScala(set) - val scalaparset = benchScalaPar(set) - - assert(scalaset < (javaset * 8), "scalaset: " + scalaset + " vs. javaset: " + javaset) - assert(scalaparset < (javaset * 8), "scalaparset: " + scalaparset + " vs. javaset: " + javaset) -} - - - - - - - - diff --git a/test/files/run/t5588.check b/test/files/run/t5588.check new file mode 100644 index 0000000000..bb101b641b --- /dev/null +++ b/test/files/run/t5588.check @@ -0,0 +1,2 @@ +true +true diff --git a/test/files/run/t5588.scala b/test/files/run/t5588.scala new file mode 100644 index 0000000000..f214d16684 --- /dev/null +++ b/test/files/run/t5588.scala @@ -0,0 +1,14 @@ +object Test { + object MyEnum extends Enumeration { + val Foo = Value(2000000000) + val Bar = Value(-2000000000) + val X = Value(Integer.MAX_VALUE) + val Y = Value(Integer.MIN_VALUE) + } + + import MyEnum._ + def main(args: Array[String]) { + println(Foo > Bar) + println(X > Y) + } +} diff --git a/test/files/run/t6011b.check b/test/files/run/t6011b.check new file mode 100644 index 0000000000..00750edc07 --- /dev/null +++ b/test/files/run/t6011b.check @@ -0,0 +1 @@ +3 diff --git a/test/files/run/t6011b.scala b/test/files/run/t6011b.scala new file mode 100644 index 0000000000..3d405e0705 --- /dev/null +++ b/test/files/run/t6011b.scala @@ -0,0 +1,11 @@ +object Test extends App { + var cond = true + + // should not generate a switch + def f(ch: Char): Int = ch match { + case 'a' if cond => 1 + case 'z' | 'a' => 2 + } + + println(f('a') + f('z')) // 3 +}
\ No newline at end of file diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check new file mode 100644 index 0000000000..dca61115ad --- /dev/null +++ b/test/files/run/t6028.check @@ -0,0 +1,84 @@ +[[syntax trees at end of lambdalift]] // newSource1 +package <empty> { + class T extends Object { + <paramaccessor> val T$$classParam: Int = _; + def <init>(classParam: Int): T = { + T.super.<init>(); + () + }; + private[this] val field: Int = 0; + <stable> <accessor> def field(): Int = T.this.field; + def foo(methodParam: Int): Function0 = { + val methodLocal: Int = 0; + { + (new anonymous class $anonfun$foo$1(T.this, methodParam, methodLocal): Function0) + } + }; + def bar(barParam: Int): Object = { + @volatile var MethodLocalObject$module: scala.runtime.VolatileObjectRef = new scala.runtime.VolatileObjectRef(<empty>); + T.this.MethodLocalObject$1(barParam, MethodLocalObject$module) + }; + def tryy(tryyParam: Int): Function0 = { + var tryyLocal: scala.runtime.IntRef = new scala.runtime.IntRef(0); + { + (new anonymous class $anonfun$tryy$1(T.this, tryyParam, tryyLocal): Function0) + } + }; + @SerialVersionUID(0) final <synthetic> class $anonfun$foo$1 extends scala.runtime.AbstractFunction0$mcI$sp with Serializable { + def <init>($outer: T, methodParam$1: Int, methodLocal$1: Int): anonymous class $anonfun$foo$1 = { + $anonfun$foo$1.super.<init>(); + () + }; + final def apply(): Int = $anonfun$foo$1.this.apply$mcI$sp(); + <specialized> def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.T$$classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); + <synthetic> <paramaccessor> private[this] val $outer: T = _; + <synthetic> <stable> def T$$anonfun$$$outer(): T = $anonfun$foo$1.this.$outer; + final <bridge> def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); + <synthetic> <paramaccessor> private[this] val methodParam$1: Int = _; + <synthetic> <paramaccessor> private[this] val methodLocal$1: Int = _ + }; + abstract trait MethodLocalTrait$1 extends Object { + <synthetic> <stable> def T$MethodLocalTrait$$$outer(): T + }; + object MethodLocalObject$2 extends Object with T#MethodLocalTrait$1 { + def <init>($outer: T, barParam$1: Int): ... = { + MethodLocalObject$2.super.<init>(); + MethodLocalObject$2.this.$asInstanceOf[T#MethodLocalTrait$1$class]()./*MethodLocalTrait$1$class*/$init$(barParam$1); + () + }; + <synthetic> <paramaccessor> private[this] val $outer: T = _; + <synthetic> <stable> def T$MethodLocalObject$$$outer(): T = MethodLocalObject$2.this.$outer; + <synthetic> <stable> def T$MethodLocalTrait$$$outer(): T = MethodLocalObject$2.this.$outer + }; + final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: scala.runtime.VolatileObjectRef): ... = { + MethodLocalObject$module$1.elem = new ...(T.this, barParam$1); + MethodLocalObject$module$1.elem.$asInstanceOf[...]() + }; + abstract trait MethodLocalTrait$1$class extends Object with T#MethodLocalTrait$1 { + def /*MethodLocalTrait$1$class*/$init$(barParam$1: Int): Unit = { + () + }; + scala.this.Predef.print(scala.Int.box(barParam$1)) + }; + @SerialVersionUID(0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable { + def <init>($outer: T, tryyParam$1: Int, tryyLocal$1: scala.runtime.IntRef): anonymous class $anonfun$tryy$1 = { + $anonfun$tryy$1.super.<init>(); + () + }; + final def apply(): Unit = $anonfun$tryy$1.this.apply$mcV$sp(); + <specialized> def apply$mcV$sp(): Unit = try { + $anonfun$tryy$1.this.tryyLocal$1.elem = $anonfun$tryy$1.this.tryyParam$1 + } finally (); + <synthetic> <paramaccessor> private[this] val $outer: T = _; + <synthetic> <stable> def T$$anonfun$$$outer(): T = $anonfun$tryy$1.this.$outer; + final <bridge> def apply(): Object = { + $anonfun$tryy$1.this.apply(); + scala.runtime.BoxedUnit.UNIT + }; + <synthetic> <paramaccessor> private[this] val tryyParam$1: Int = _; + <synthetic> <paramaccessor> private[this] val tryyLocal$1: scala.runtime.IntRef = _ + } + } +} + +warning: there were 1 feature warnings; re-run with -feature for details diff --git a/test/files/run/t6028.scala b/test/files/run/t6028.scala new file mode 100644 index 0000000000..cab17535fc --- /dev/null +++ b/test/files/run/t6028.scala @@ -0,0 +1,21 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:lambdalift -d " + testOutput.path + + override def code = """class T(classParam: Int) { + | val field: Int = 0 + | def foo(methodParam: Int) = {val methodLocal = 0 ; () => classParam + field + methodParam + methodLocal } + | def bar(barParam: Int) = { trait MethodLocalTrait { print(barParam) }; object MethodLocalObject extends MethodLocalTrait; MethodLocalObject } + | def tryy(tryyParam: Int) = { var tryyLocal = 0; () => try { tryyLocal = tryyParam } finally () } + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/t6077_patmat_cse_irrefutable.check b/test/files/run/t6077_patmat_cse_irrefutable.check new file mode 100644 index 0000000000..9766475a41 --- /dev/null +++ b/test/files/run/t6077_patmat_cse_irrefutable.check @@ -0,0 +1 @@ +ok diff --git a/test/files/run/t6077_patmat_cse_irrefutable.scala b/test/files/run/t6077_patmat_cse_irrefutable.scala new file mode 100644 index 0000000000..b130ae7813 --- /dev/null +++ b/test/files/run/t6077_patmat_cse_irrefutable.scala @@ -0,0 +1,13 @@ +class LiteralNode(val value: Any) + +object LiteralNode { + // irrefutable + def unapply(n: LiteralNode) = Some(n.value) +} + +object Test extends App { + ((new LiteralNode(false)): Any) match { + case LiteralNode(true) => println("uh-oh") + case LiteralNode(false) => println("ok") + } +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-classmanifest-basic.check b/test/files/run/valueclasses-classmanifest-basic.check new file mode 100644 index 0000000000..554c75e074 --- /dev/null +++ b/test/files/run/valueclasses-classmanifest-basic.check @@ -0,0 +1 @@ +Foo
diff --git a/test/files/run/valueclasses-classmanifest-basic.scala b/test/files/run/valueclasses-classmanifest-basic.scala new file mode 100644 index 0000000000..c2aa08ef86 --- /dev/null +++ b/test/files/run/valueclasses-classmanifest-basic.scala @@ -0,0 +1,5 @@ +class Foo(val x: Int) extends AnyVal + +object Test extends App { + println(classManifest[Foo]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-classmanifest-existential.check b/test/files/run/valueclasses-classmanifest-existential.check new file mode 100644 index 0000000000..e9fc6e27ea --- /dev/null +++ b/test/files/run/valueclasses-classmanifest-existential.check @@ -0,0 +1 @@ +Foo[<?>]
diff --git a/test/files/run/valueclasses-classmanifest-existential.scala b/test/files/run/valueclasses-classmanifest-existential.scala new file mode 100644 index 0000000000..11999df678 --- /dev/null +++ b/test/files/run/valueclasses-classmanifest-existential.scala @@ -0,0 +1,5 @@ +class Foo[T](val x: T) extends AnyVal + +object Test extends App { + println(classManifest[Foo[_]]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-classmanifest-generic.check b/test/files/run/valueclasses-classmanifest-generic.check new file mode 100644 index 0000000000..1418c5cff9 --- /dev/null +++ b/test/files/run/valueclasses-classmanifest-generic.check @@ -0,0 +1 @@ +Foo[java.lang.String]
diff --git a/test/files/run/valueclasses-classmanifest-generic.scala b/test/files/run/valueclasses-classmanifest-generic.scala new file mode 100644 index 0000000000..280152dc1d --- /dev/null +++ b/test/files/run/valueclasses-classmanifest-generic.scala @@ -0,0 +1,5 @@ +class Foo[T](val x: T) extends AnyVal + +object Test extends App { + println(classManifest[Foo[String]]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-classtag-basic.check b/test/files/run/valueclasses-classtag-basic.check new file mode 100644 index 0000000000..0c13986b32 --- /dev/null +++ b/test/files/run/valueclasses-classtag-basic.check @@ -0,0 +1 @@ +ClassTag[class Foo]
diff --git a/test/files/run/valueclasses-classtag-basic.scala b/test/files/run/valueclasses-classtag-basic.scala new file mode 100644 index 0000000000..912a4bb019 --- /dev/null +++ b/test/files/run/valueclasses-classtag-basic.scala @@ -0,0 +1,5 @@ +class Foo(val x: Int) extends AnyVal + +object Test extends App { + println(scala.reflect.classTag[Foo]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-classtag-existential.check b/test/files/run/valueclasses-classtag-existential.check new file mode 100644 index 0000000000..95e94e7aee --- /dev/null +++ b/test/files/run/valueclasses-classtag-existential.check @@ -0,0 +1 @@ +ClassTag[class java.lang.Object]
diff --git a/test/files/run/valueclasses-classtag-existential.scala b/test/files/run/valueclasses-classtag-existential.scala new file mode 100644 index 0000000000..e0db9cdd75 --- /dev/null +++ b/test/files/run/valueclasses-classtag-existential.scala @@ -0,0 +1,5 @@ +class Foo[T](val x: T) extends AnyVal + +object Test extends App { + println(scala.reflect.classTag[Foo[_]]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-classtag-generic.check b/test/files/run/valueclasses-classtag-generic.check new file mode 100644 index 0000000000..0c13986b32 --- /dev/null +++ b/test/files/run/valueclasses-classtag-generic.check @@ -0,0 +1 @@ +ClassTag[class Foo]
diff --git a/test/files/run/valueclasses-classtag-generic.scala b/test/files/run/valueclasses-classtag-generic.scala new file mode 100644 index 0000000000..bd1f213835 --- /dev/null +++ b/test/files/run/valueclasses-classtag-generic.scala @@ -0,0 +1,5 @@ +class Foo[T](val x: T) extends AnyVal + +object Test extends App { + println(scala.reflect.classTag[Foo[String]]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-manifest-basic.check b/test/files/run/valueclasses-manifest-basic.check new file mode 100644 index 0000000000..554c75e074 --- /dev/null +++ b/test/files/run/valueclasses-manifest-basic.check @@ -0,0 +1 @@ +Foo
diff --git a/test/files/run/valueclasses-manifest-basic.scala b/test/files/run/valueclasses-manifest-basic.scala new file mode 100644 index 0000000000..eefab20168 --- /dev/null +++ b/test/files/run/valueclasses-manifest-basic.scala @@ -0,0 +1,5 @@ +class Foo(val x: Int) extends AnyVal + +object Test extends App { + println(manifest[Foo]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-manifest-existential.check b/test/files/run/valueclasses-manifest-existential.check new file mode 100644 index 0000000000..fdce051039 --- /dev/null +++ b/test/files/run/valueclasses-manifest-existential.check @@ -0,0 +1 @@ +Foo[_ <: Any]
diff --git a/test/files/run/valueclasses-manifest-existential.scala b/test/files/run/valueclasses-manifest-existential.scala new file mode 100644 index 0000000000..47eb6d64dd --- /dev/null +++ b/test/files/run/valueclasses-manifest-existential.scala @@ -0,0 +1,5 @@ +class Foo[T](val x: T) extends AnyVal + +object Test extends App { + println(manifest[Foo[_]]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-manifest-generic.check b/test/files/run/valueclasses-manifest-generic.check new file mode 100644 index 0000000000..1418c5cff9 --- /dev/null +++ b/test/files/run/valueclasses-manifest-generic.check @@ -0,0 +1 @@ +Foo[java.lang.String]
diff --git a/test/files/run/valueclasses-manifest-generic.scala b/test/files/run/valueclasses-manifest-generic.scala new file mode 100644 index 0000000000..18313fba6f --- /dev/null +++ b/test/files/run/valueclasses-manifest-generic.scala @@ -0,0 +1,5 @@ +class Foo[T](val x: T) extends AnyVal + +object Test extends App { + println(manifest[Foo[String]]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-typetag-basic.check b/test/files/run/valueclasses-typetag-basic.check new file mode 100644 index 0000000000..554c75e074 --- /dev/null +++ b/test/files/run/valueclasses-typetag-basic.check @@ -0,0 +1 @@ +Foo
diff --git a/test/files/run/valueclasses-typetag-basic.scala b/test/files/run/valueclasses-typetag-basic.scala new file mode 100644 index 0000000000..d0243f7378 --- /dev/null +++ b/test/files/run/valueclasses-typetag-basic.scala @@ -0,0 +1,5 @@ +class Foo(val x: Int) extends AnyVal + +object Test extends App { + println(scala.reflect.runtime.universe.typeOf[Foo]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-typetag-existential.check b/test/files/run/valueclasses-typetag-existential.check new file mode 100644 index 0000000000..0efa24a45f --- /dev/null +++ b/test/files/run/valueclasses-typetag-existential.check @@ -0,0 +1 @@ +Foo[_]
diff --git a/test/files/run/valueclasses-typetag-existential.scala b/test/files/run/valueclasses-typetag-existential.scala new file mode 100644 index 0000000000..4cdaa44a83 --- /dev/null +++ b/test/files/run/valueclasses-typetag-existential.scala @@ -0,0 +1,5 @@ +class Foo[T](val x: T) extends AnyVal + +object Test extends App { + println(scala.reflect.runtime.universe.typeOf[Foo[_]]) +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-typetag-generic.check b/test/files/run/valueclasses-typetag-generic.check new file mode 100644 index 0000000000..fce2e64f79 --- /dev/null +++ b/test/files/run/valueclasses-typetag-generic.check @@ -0,0 +1 @@ +Foo[String]
diff --git a/test/files/run/valueclasses-typetag-generic.scala b/test/files/run/valueclasses-typetag-generic.scala new file mode 100644 index 0000000000..eb32dfcadb --- /dev/null +++ b/test/files/run/valueclasses-typetag-generic.scala @@ -0,0 +1,5 @@ +class Foo[T](val x: T) extends AnyVal + +object Test extends App { + println(scala.reflect.runtime.universe.typeOf[Foo[String]]) +}
\ No newline at end of file diff --git a/test/files/specialized/t6035.check b/test/files/specialized/t6035.check new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/test/files/specialized/t6035.check @@ -0,0 +1 @@ +0 diff --git a/test/files/specialized/t6035/first_1.scala b/test/files/specialized/t6035/first_1.scala new file mode 100644 index 0000000000..1289e9f48e --- /dev/null +++ b/test/files/specialized/t6035/first_1.scala @@ -0,0 +1,5 @@ +trait Foo[@specialized(Int) A] { + def foo(x: A): A +} + +abstract class Inter extends Foo[Int] diff --git a/test/files/specialized/t6035/second_2.scala b/test/files/specialized/t6035/second_2.scala new file mode 100644 index 0000000000..fb317e2a6a --- /dev/null +++ b/test/files/specialized/t6035/second_2.scala @@ -0,0 +1,13 @@ +class Baz extends Inter { + def foo(x: Int) = x + 1 +} + +object Test { + def main(args: Array[String]) { + // it's important that the type is Inter so we do not call Baz.foo(I)I directly! + val baz: Inter = new Baz + // here we should go through specialized version of foo and thus have zero boxing + baz.foo(1) + println(runtime.BoxesRunTime.integerBoxCount) + } +} |