diff options
Diffstat (limited to 'test')
585 files changed, 4663 insertions, 541 deletions
diff --git a/test/files/cli/test1/Main.check.j9vm5 b/test/attic/files/cli/test1/Main.check.j9vm5 index de454ef478..de454ef478 100644 --- a/test/files/cli/test1/Main.check.j9vm5 +++ b/test/attic/files/cli/test1/Main.check.j9vm5 diff --git a/test/files/cli/test1/Main.check.java b/test/attic/files/cli/test1/Main.check.java index 64410de98f..64410de98f 100644 --- a/test/files/cli/test1/Main.check.java +++ b/test/attic/files/cli/test1/Main.check.java diff --git a/test/files/cli/test1/Main.check.java5 b/test/attic/files/cli/test1/Main.check.java5 index 64410de98f..64410de98f 100644 --- a/test/files/cli/test1/Main.check.java5 +++ b/test/attic/files/cli/test1/Main.check.java5 diff --git a/test/files/cli/test1/Main.check.java5_api b/test/attic/files/cli/test1/Main.check.java5_api index 8693a5d92f..8693a5d92f 100644 --- a/test/files/cli/test1/Main.check.java5_api +++ b/test/attic/files/cli/test1/Main.check.java5_api diff --git a/test/files/cli/test1/Main.check.java5_j9 b/test/attic/files/cli/test1/Main.check.java5_j9 index de454ef478..de454ef478 100644 --- a/test/files/cli/test1/Main.check.java5_j9 +++ b/test/attic/files/cli/test1/Main.check.java5_j9 diff --git a/test/files/cli/test1/Main.check.javac b/test/attic/files/cli/test1/Main.check.javac index ba25d9b6ca..ba25d9b6ca 100644 --- a/test/files/cli/test1/Main.check.javac +++ b/test/attic/files/cli/test1/Main.check.javac diff --git a/test/files/cli/test1/Main.check.javac5 b/test/attic/files/cli/test1/Main.check.javac5 index 0cb29d31ff..0cb29d31ff 100644 --- a/test/files/cli/test1/Main.check.javac5 +++ b/test/attic/files/cli/test1/Main.check.javac5 diff --git a/test/files/cli/test1/Main.check.javac6 b/test/attic/files/cli/test1/Main.check.javac6 index 8f37a05bcb..8f37a05bcb 100644 --- a/test/files/cli/test1/Main.check.javac6 +++ b/test/attic/files/cli/test1/Main.check.javac6 diff --git a/test/files/cli/test1/Main.check.jikes b/test/attic/files/cli/test1/Main.check.jikes index cd891689db..cd891689db 100644 --- a/test/files/cli/test1/Main.check.jikes +++ b/test/attic/files/cli/test1/Main.check.jikes diff --git a/test/files/cli/test1/Main.check.jikes5 b/test/attic/files/cli/test1/Main.check.jikes5 index cd891689db..cd891689db 100644 --- a/test/files/cli/test1/Main.check.jikes5 +++ b/test/attic/files/cli/test1/Main.check.jikes5 diff --git a/test/files/cli/test1/Main.check.scala b/test/attic/files/cli/test1/Main.check.scala index 43b200ae02..43b200ae02 100644 --- a/test/files/cli/test1/Main.check.scala +++ b/test/attic/files/cli/test1/Main.check.scala diff --git a/test/files/cli/test1/Main.check.scala_api b/test/attic/files/cli/test1/Main.check.scala_api index 6fac39d3f0..6fac39d3f0 100644 --- a/test/files/cli/test1/Main.check.scala_api +++ b/test/attic/files/cli/test1/Main.check.scala_api diff --git a/test/files/cli/test1/Main.check.scala_j9 b/test/attic/files/cli/test1/Main.check.scala_j9 index 65d5ddaac4..65d5ddaac4 100644 --- a/test/files/cli/test1/Main.check.scala_j9 +++ b/test/attic/files/cli/test1/Main.check.scala_j9 diff --git a/test/files/cli/test1/Main.check.scalac b/test/attic/files/cli/test1/Main.check.scalac index 8465810d0b..8465810d0b 100644 --- a/test/files/cli/test1/Main.check.scalac +++ b/test/attic/files/cli/test1/Main.check.scalac diff --git a/test/files/cli/test1/Main.check.scalaint b/test/attic/files/cli/test1/Main.check.scalaint index 88345d1874..88345d1874 100644 --- a/test/files/cli/test1/Main.check.scalaint +++ b/test/attic/files/cli/test1/Main.check.scalaint diff --git a/test/files/cli/test1/Main.java b/test/attic/files/cli/test1/Main.java index 8850b87517..8850b87517 100644 --- a/test/files/cli/test1/Main.java +++ b/test/attic/files/cli/test1/Main.java diff --git a/test/files/cli/test1/Main.scala b/test/attic/files/cli/test1/Main.scala index f7dd8a0a36..f7dd8a0a36 100644 --- a/test/files/cli/test1/Main.scala +++ b/test/attic/files/cli/test1/Main.scala diff --git a/test/files/cli/test2/Main.check.j9vm5 b/test/attic/files/cli/test2/Main.check.j9vm5 index 8f4fdf8aa1..8f4fdf8aa1 100644 --- a/test/files/cli/test2/Main.check.j9vm5 +++ b/test/attic/files/cli/test2/Main.check.j9vm5 diff --git a/test/files/cli/test2/Main.check.java b/test/attic/files/cli/test2/Main.check.java index aca383de3e..aca383de3e 100644 --- a/test/files/cli/test2/Main.check.java +++ b/test/attic/files/cli/test2/Main.check.java diff --git a/test/files/cli/test2/Main.check.java5 b/test/attic/files/cli/test2/Main.check.java5 index aca383de3e..aca383de3e 100644 --- a/test/files/cli/test2/Main.check.java5 +++ b/test/attic/files/cli/test2/Main.check.java5 diff --git a/test/files/cli/test2/Main.check.java5_api b/test/attic/files/cli/test2/Main.check.java5_api index 4ff775c3da..4ff775c3da 100644 --- a/test/files/cli/test2/Main.check.java5_api +++ b/test/attic/files/cli/test2/Main.check.java5_api diff --git a/test/files/cli/test2/Main.check.java5_j9 b/test/attic/files/cli/test2/Main.check.java5_j9 index 2dcb6e892a..2dcb6e892a 100644 --- a/test/files/cli/test2/Main.check.java5_j9 +++ b/test/attic/files/cli/test2/Main.check.java5_j9 diff --git a/test/files/cli/test2/Main.check.javac b/test/attic/files/cli/test2/Main.check.javac index c40c0a7a89..c40c0a7a89 100644 --- a/test/files/cli/test2/Main.check.javac +++ b/test/attic/files/cli/test2/Main.check.javac diff --git a/test/files/cli/test2/Main.check.javac5 b/test/attic/files/cli/test2/Main.check.javac5 index 0ac32b056e..0ac32b056e 100644 --- a/test/files/cli/test2/Main.check.javac5 +++ b/test/attic/files/cli/test2/Main.check.javac5 diff --git a/test/files/cli/test2/Main.check.javac6 b/test/attic/files/cli/test2/Main.check.javac6 index 350d3253bc..350d3253bc 100644 --- a/test/files/cli/test2/Main.check.javac6 +++ b/test/attic/files/cli/test2/Main.check.javac6 diff --git a/test/files/cli/test2/Main.check.jikes b/test/attic/files/cli/test2/Main.check.jikes index 97943e8347..97943e8347 100644 --- a/test/files/cli/test2/Main.check.jikes +++ b/test/attic/files/cli/test2/Main.check.jikes diff --git a/test/files/cli/test2/Main.check.jikes5 b/test/attic/files/cli/test2/Main.check.jikes5 index 97943e8347..97943e8347 100644 --- a/test/files/cli/test2/Main.check.jikes5 +++ b/test/attic/files/cli/test2/Main.check.jikes5 diff --git a/test/files/cli/test2/Main.check.scala b/test/attic/files/cli/test2/Main.check.scala index 7e5f17625b..7e5f17625b 100644 --- a/test/files/cli/test2/Main.check.scala +++ b/test/attic/files/cli/test2/Main.check.scala diff --git a/test/files/cli/test2/Main.check.scala_api b/test/attic/files/cli/test2/Main.check.scala_api index bcb0f0c7fb..bcb0f0c7fb 100644 --- a/test/files/cli/test2/Main.check.scala_api +++ b/test/attic/files/cli/test2/Main.check.scala_api diff --git a/test/files/cli/test2/Main.check.scala_j9 b/test/attic/files/cli/test2/Main.check.scala_j9 index 80cbb50fa9..80cbb50fa9 100644 --- a/test/files/cli/test2/Main.check.scala_j9 +++ b/test/attic/files/cli/test2/Main.check.scala_j9 diff --git a/test/files/cli/test2/Main.check.scalac b/test/attic/files/cli/test2/Main.check.scalac index 8465810d0b..8465810d0b 100644 --- a/test/files/cli/test2/Main.check.scalac +++ b/test/attic/files/cli/test2/Main.check.scalac diff --git a/test/files/cli/test2/Main.check.scalaint b/test/attic/files/cli/test2/Main.check.scalaint index 89b6766bb5..89b6766bb5 100644 --- a/test/files/cli/test2/Main.check.scalaint +++ b/test/attic/files/cli/test2/Main.check.scalaint diff --git a/test/files/cli/test2/Main.java b/test/attic/files/cli/test2/Main.java index f6797632bf..f6797632bf 100644 --- a/test/files/cli/test2/Main.java +++ b/test/attic/files/cli/test2/Main.java diff --git a/test/files/cli/test2/Main.scala b/test/attic/files/cli/test2/Main.scala index 1d43759fdf..1d43759fdf 100644 --- a/test/files/cli/test2/Main.scala +++ b/test/attic/files/cli/test2/Main.scala diff --git a/test/files/cli/test3/Main.check.j9vm5 b/test/attic/files/cli/test3/Main.check.j9vm5 index a094dc8daf..a094dc8daf 100644 --- a/test/files/cli/test3/Main.check.j9vm5 +++ b/test/attic/files/cli/test3/Main.check.j9vm5 diff --git a/test/files/cli/test3/Main.check.java b/test/attic/files/cli/test3/Main.check.java index de3eb7b136..de3eb7b136 100644 --- a/test/files/cli/test3/Main.check.java +++ b/test/attic/files/cli/test3/Main.check.java diff --git a/test/files/cli/test3/Main.check.java5 b/test/attic/files/cli/test3/Main.check.java5 index de3eb7b136..de3eb7b136 100644 --- a/test/files/cli/test3/Main.check.java5 +++ b/test/attic/files/cli/test3/Main.check.java5 diff --git a/test/files/cli/test3/Main.check.java5_api b/test/attic/files/cli/test3/Main.check.java5_api index f6112211f0..f6112211f0 100644 --- a/test/files/cli/test3/Main.check.java5_api +++ b/test/attic/files/cli/test3/Main.check.java5_api diff --git a/test/files/cli/test3/Main.check.java5_j9 b/test/attic/files/cli/test3/Main.check.java5_j9 index 9e228d7649..9e228d7649 100644 --- a/test/files/cli/test3/Main.check.java5_j9 +++ b/test/attic/files/cli/test3/Main.check.java5_j9 diff --git a/test/files/cli/test3/Main.check.javac b/test/attic/files/cli/test3/Main.check.javac index 8d235b647b..8d235b647b 100644 --- a/test/files/cli/test3/Main.check.javac +++ b/test/attic/files/cli/test3/Main.check.javac diff --git a/test/files/cli/test3/Main.check.javac5 b/test/attic/files/cli/test3/Main.check.javac5 index 3a48fa000e..3a48fa000e 100644 --- a/test/files/cli/test3/Main.check.javac5 +++ b/test/attic/files/cli/test3/Main.check.javac5 diff --git a/test/files/cli/test3/Main.check.javac6 b/test/attic/files/cli/test3/Main.check.javac6 index 677b950aed..677b950aed 100644 --- a/test/files/cli/test3/Main.check.javac6 +++ b/test/attic/files/cli/test3/Main.check.javac6 diff --git a/test/files/cli/test3/Main.check.jikes b/test/attic/files/cli/test3/Main.check.jikes index 604333e81a..604333e81a 100644 --- a/test/files/cli/test3/Main.check.jikes +++ b/test/attic/files/cli/test3/Main.check.jikes diff --git a/test/files/cli/test3/Main.check.jikes5 b/test/attic/files/cli/test3/Main.check.jikes5 index 604333e81a..604333e81a 100644 --- a/test/files/cli/test3/Main.check.jikes5 +++ b/test/attic/files/cli/test3/Main.check.jikes5 diff --git a/test/files/cli/test3/Main.check.scala b/test/attic/files/cli/test3/Main.check.scala index f78729b9a2..f78729b9a2 100644 --- a/test/files/cli/test3/Main.check.scala +++ b/test/attic/files/cli/test3/Main.check.scala diff --git a/test/files/cli/test3/Main.check.scala_api b/test/attic/files/cli/test3/Main.check.scala_api index 4552819b5b..4552819b5b 100644 --- a/test/files/cli/test3/Main.check.scala_api +++ b/test/attic/files/cli/test3/Main.check.scala_api diff --git a/test/files/cli/test3/Main.check.scala_j9 b/test/attic/files/cli/test3/Main.check.scala_j9 index 3804c17636..3804c17636 100644 --- a/test/files/cli/test3/Main.check.scala_j9 +++ b/test/attic/files/cli/test3/Main.check.scala_j9 diff --git a/test/files/cli/test3/Main.check.scalac b/test/attic/files/cli/test3/Main.check.scalac index 8465810d0b..8465810d0b 100644 --- a/test/files/cli/test3/Main.check.scalac +++ b/test/attic/files/cli/test3/Main.check.scalac diff --git a/test/files/cli/test3/Main.check.scalaint b/test/attic/files/cli/test3/Main.check.scalaint index cffa02c5b6..cffa02c5b6 100644 --- a/test/files/cli/test3/Main.check.scalaint +++ b/test/attic/files/cli/test3/Main.check.scalaint diff --git a/test/files/cli/test3/Main.java b/test/attic/files/cli/test3/Main.java index 208863d012..208863d012 100644 --- a/test/files/cli/test3/Main.java +++ b/test/attic/files/cli/test3/Main.java diff --git a/test/files/cli/test3/Main.scala b/test/attic/files/cli/test3/Main.scala index 63fc11b771..63fc11b771 100644 --- a/test/files/cli/test3/Main.scala +++ b/test/attic/files/cli/test3/Main.scala diff --git a/test/continuations/neg/function0.check b/test/continuations/neg/function0.check new file mode 100644 index 0000000000..0a66763a0f --- /dev/null +++ b/test/continuations/neg/function0.check @@ -0,0 +1,6 @@ +function0.scala:11: error: type mismatch; + found : () => Int @scala.util.continuations.cpsParam[Int,Int] + required: () => Int + val g: () => Int = f + ^ +one error found diff --git a/test/continuations/neg/function0.scala b/test/continuations/neg/function0.scala new file mode 100644 index 0000000000..4112ee3835 --- /dev/null +++ b/test/continuations/neg/function0.scala @@ -0,0 +1,16 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def main(args: Array[String]): Any = { + + val f = () => shift { k: (Int=>Int) => k(7) } + val g: () => Int = f + + println(reset(g())) + } + +}
\ No newline at end of file diff --git a/test/continuations/neg/function2.check b/test/continuations/neg/function2.check new file mode 100644 index 0000000000..4833057652 --- /dev/null +++ b/test/continuations/neg/function2.check @@ -0,0 +1,6 @@ +function2.scala:11: error: type mismatch; + found : () => Int + required: () => Int @util.continuations.package.cps[Int] + val g: () => Int @cps[Int] = f + ^ +one error found diff --git a/test/continuations/neg/function2.scala b/test/continuations/neg/function2.scala new file mode 100644 index 0000000000..ae0fda509d --- /dev/null +++ b/test/continuations/neg/function2.scala @@ -0,0 +1,16 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def main(args: Array[String]): Any = { + + val f = () => 7 + val g: () => Int @cps[Int] = f + + println(reset(g())) + } + +}
\ No newline at end of file diff --git a/test/continuations/neg/function3.check b/test/continuations/neg/function3.check new file mode 100644 index 0000000000..4705ad9ed9 --- /dev/null +++ b/test/continuations/neg/function3.check @@ -0,0 +1,6 @@ +function3.scala:10: error: type mismatch; + found : Int @scala.util.continuations.cpsParam[Int,Int] + required: Int + val g: () => Int = () => shift { k: (Int=>Int) => k(7) } + ^ +one error found diff --git a/test/continuations/neg/function3.scala b/test/continuations/neg/function3.scala new file mode 100644 index 0000000000..0c3f1667e5 --- /dev/null +++ b/test/continuations/neg/function3.scala @@ -0,0 +1,15 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def main(args: Array[String]): Any = { + + val g: () => Int = () => shift { k: (Int=>Int) => k(7) } + + println(reset(g())) + } + +}
\ No newline at end of file diff --git a/test/continuations/neg/infer0.check b/test/continuations/neg/infer0.check new file mode 100644 index 0000000000..1dd072ef09 --- /dev/null +++ b/test/continuations/neg/infer0.check @@ -0,0 +1,4 @@ +infer0.scala:11: error: cannot cps-transform expression 8: type arguments [Int(8),String,Int] do not conform to method shiftUnit's type parameter bounds [A,B,C >: B] + test(8) + ^ +one error found diff --git a/test/continuations/neg/infer0.scala b/test/continuations/neg/infer0.scala new file mode 100644 index 0000000000..894d5228b1 --- /dev/null +++ b/test/continuations/neg/infer0.scala @@ -0,0 +1,14 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test(x: => Int @cpsParam[String,Int]) = 7 + + def main(args: Array[String]): Any = { + test(8) + } + +}
\ No newline at end of file diff --git a/test/continuations/neg/infer2.check b/test/continuations/neg/infer2.check new file mode 100644 index 0000000000..59eb670bc3 --- /dev/null +++ b/test/continuations/neg/infer2.check @@ -0,0 +1,4 @@ +infer2.scala:14: error: illegal answer type modification: scala.util.continuations.cpsParam[String,Int] andThen scala.util.continuations.cpsParam[String,Int] + test { sym(); sym() } + ^ +one error found diff --git a/test/continuations/neg/infer2.scala b/test/continuations/neg/infer2.scala new file mode 100644 index 0000000000..a890ac1fc4 --- /dev/null +++ b/test/continuations/neg/infer2.scala @@ -0,0 +1,19 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test(x: => Int @cpsParam[String,Int]) = 7 + + def sym() = shift { k: (Int => String) => 9 } + + + def main(args: Array[String]): Any = { + test { sym(); sym() } + } + +} + + diff --git a/test/continuations/neg/lazy.check b/test/continuations/neg/lazy.check new file mode 100644 index 0000000000..bfa44c59a4 --- /dev/null +++ b/test/continuations/neg/lazy.check @@ -0,0 +1,6 @@ +lazy.scala:5: error: type mismatch; + found : Unit @scala.util.continuations.cpsParam[Unit,Unit] + required: Unit + def foo = { + ^ +one error found diff --git a/test/continuations/neg/lazy.scala b/test/continuations/neg/lazy.scala new file mode 100644 index 0000000000..dffc57ffa0 --- /dev/null +++ b/test/continuations/neg/lazy.scala @@ -0,0 +1,16 @@ +import scala.util.continuations._ + +object Test { + + def foo = { + lazy val x = shift((k:Unit=>Unit)=>k()) + println(x) + } + + def main(args: Array[String]) { + reset { + foo + } + } + +}
\ No newline at end of file diff --git a/test/continuations/neg/t1929.check b/test/continuations/neg/t1929.check new file mode 100644 index 0000000000..f42c3a1e15 --- /dev/null +++ b/test/continuations/neg/t1929.check @@ -0,0 +1,6 @@ +t1929.scala:8: error: type mismatch; + found : Int @scala.util.continuations.cpsParam[String,java.lang.String] @scala.util.continuations.cpsSynth + required: Int @scala.util.continuations.cpsParam[Int,java.lang.String] + reset { + ^ +one error found diff --git a/test/continuations/neg/t1929.scala b/test/continuations/neg/t1929.scala new file mode 100644 index 0000000000..02eda9170d --- /dev/null +++ b/test/continuations/neg/t1929.scala @@ -0,0 +1,17 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + def main(args : Array[String]) { + reset { + println("up") + val x = shift((k:Int=>String) => k(8) + k(2)) + println("down " + x) + val y = shift((k:Int=>String) => k(3)) + println("down2 " + y) + y + x + } + } +}
\ No newline at end of file diff --git a/test/continuations/neg/t2285.check b/test/continuations/neg/t2285.check new file mode 100644 index 0000000000..d5dff6a4f2 --- /dev/null +++ b/test/continuations/neg/t2285.check @@ -0,0 +1,6 @@ +t2285.scala:9: error: type mismatch; + found : Int @scala.util.continuations.cpsParam[String,String] @scala.util.continuations.cpsSynth + required: Int @scala.util.continuations.cpsParam[Int,String] + def foo() = reset { bar(); 7 } + ^ +one error found diff --git a/test/continuations/neg/t2285.scala b/test/continuations/neg/t2285.scala new file mode 100644 index 0000000000..f3c7f4c89c --- /dev/null +++ b/test/continuations/neg/t2285.scala @@ -0,0 +1,11 @@ +// $Id$ + +import scala.util.continuations._ + +object Test { + + def bar() = shift { k: (String => String) => k("1") } + + def foo() = reset { bar(); 7 } + +} diff --git a/test/continuations/neg/t2949.check b/test/continuations/neg/t2949.check new file mode 100644 index 0000000000..dd9768807c --- /dev/null +++ b/test/continuations/neg/t2949.check @@ -0,0 +1,6 @@ +t2949.scala:13: error: type mismatch; + found : Int + required: ? @scala.util.continuations.cpsParam[List[?],Any] + x * y + ^ +one error found diff --git a/test/continuations/neg/t2949.scala b/test/continuations/neg/t2949.scala new file mode 100644 index 0000000000..ce27c7c0e8 --- /dev/null +++ b/test/continuations/neg/t2949.scala @@ -0,0 +1,15 @@ +// $Id$ + +import scala.util.continuations._ + +object Test { + + def reflect[A,B](xs : List[A]) = shift{ xs.flatMap[B, List[B]] } + def reify[A, B](x : A @cpsParam[List[A], B]) = reset{ List(x) } + + def main(args: Array[String]): Unit = println(reify { + val x = reflect[Int, Int](List(1,2,3)) + val y = reflect[Int, Int](List(2,4,8)) + x * y + }) +} diff --git a/test/continuations/neg/trycatch2.check b/test/continuations/neg/trycatch2.check new file mode 100644 index 0000000000..5ff2838bad --- /dev/null +++ b/test/continuations/neg/trycatch2.check @@ -0,0 +1,7 @@ +trycatch2.scala:11: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int]) + def foo1 = try { + ^ +trycatch2.scala:19: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int]) + def foo2 = try { + ^ +two errors found diff --git a/test/continuations/neg/trycatch2.scala b/test/continuations/neg/trycatch2.scala new file mode 100644 index 0000000000..761cee52ac --- /dev/null +++ b/test/continuations/neg/trycatch2.scala @@ -0,0 +1,33 @@ +// $Id$ + +import scala.util.continuations._ + +object Test { + + def fatal[T]: T = throw new Exception + def cpsIntStringInt = shift { k:(Int=>String) => k(3); 7 } + def cpsIntIntString = shift { k:(Int=>Int) => k(3); "7" } + + def foo1 = try { + fatal[Int] + cpsIntStringInt + } catch { + case ex => + cpsIntStringInt + } + + def foo2 = try { + fatal[Int] + cpsIntStringInt + } catch { + case ex => + cpsIntStringInt + } + + + def main(args: Array[String]): Unit = { + println(reset { foo1; "3" }) + println(reset { foo2; "3" }) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/basics.check b/test/continuations/run/basics.check new file mode 100755 index 0000000000..54c059fdcb --- /dev/null +++ b/test/continuations/run/basics.check @@ -0,0 +1,2 @@ +28 +28
\ No newline at end of file diff --git a/test/continuations/run/basics.scala b/test/continuations/run/basics.scala new file mode 100755 index 0000000000..9df209b11c --- /dev/null +++ b/test/continuations/run/basics.scala @@ -0,0 +1,23 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def m0() = { + shift((k:Int => Int) => k(k(7))) * 2 + } + + def m1() = { + 2 * shift((k:Int => Int) => k(k(7))) + } + + def main(args: Array[String]) = { + + println(reset(m0())) + println(reset(m1())) + + } + +} diff --git a/test/continuations/run/function1.check b/test/continuations/run/function1.check new file mode 100644 index 0000000000..7f8f011eb7 --- /dev/null +++ b/test/continuations/run/function1.check @@ -0,0 +1 @@ +7 diff --git a/test/continuations/run/function1.scala b/test/continuations/run/function1.scala new file mode 100644 index 0000000000..3b39722e3a --- /dev/null +++ b/test/continuations/run/function1.scala @@ -0,0 +1,16 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def main(args: Array[String]): Any = { + + val f = () => shift { k: (Int=>Int) => k(7) } + val g: () => Int @cps[Int] = f + + println(reset(g())) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/function4.check b/test/continuations/run/function4.check new file mode 100644 index 0000000000..c7930257df --- /dev/null +++ b/test/continuations/run/function4.check @@ -0,0 +1 @@ +7
\ No newline at end of file diff --git a/test/continuations/run/function4.scala b/test/continuations/run/function4.scala new file mode 100644 index 0000000000..b73eedb02c --- /dev/null +++ b/test/continuations/run/function4.scala @@ -0,0 +1,15 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def main(args: Array[String]): Any = { + + val g: () => Int @cps[Int] = () => shift { k: (Int=>Int) => k(7) } + + println(reset(g())) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/function5.check b/test/continuations/run/function5.check new file mode 100644 index 0000000000..c7930257df --- /dev/null +++ b/test/continuations/run/function5.check @@ -0,0 +1 @@ +7
\ No newline at end of file diff --git a/test/continuations/run/function5.scala b/test/continuations/run/function5.scala new file mode 100644 index 0000000000..a689ccf243 --- /dev/null +++ b/test/continuations/run/function5.scala @@ -0,0 +1,15 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def main(args: Array[String]): Any = { + + val g: () => Int @cps[Int] = () => 7 + + println(reset(g())) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/function6.check b/test/continuations/run/function6.check new file mode 100644 index 0000000000..c7930257df --- /dev/null +++ b/test/continuations/run/function6.check @@ -0,0 +1 @@ +7
\ No newline at end of file diff --git a/test/continuations/run/function6.scala b/test/continuations/run/function6.scala new file mode 100644 index 0000000000..1a2792370a --- /dev/null +++ b/test/continuations/run/function6.scala @@ -0,0 +1,16 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def main(args: Array[String]): Any = { + + val g: PartialFunction[Int, Int @cps[Int]] = { case x => 7 } + + println(reset(g(2))) + + } + +}
\ No newline at end of file diff --git a/test/continuations/run/ifelse0.check b/test/continuations/run/ifelse0.check new file mode 100644 index 0000000000..f8bc79860d --- /dev/null +++ b/test/continuations/run/ifelse0.check @@ -0,0 +1,2 @@ +10 +9
\ No newline at end of file diff --git a/test/continuations/run/ifelse0.scala b/test/continuations/run/ifelse0.scala new file mode 100644 index 0000000000..e34b86ee84 --- /dev/null +++ b/test/continuations/run/ifelse0.scala @@ -0,0 +1,18 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test(x:Int) = if (x <= 7) + shift { k: (Int=>Int) => k(k(k(x))) } + else + shift { k: (Int=>Int) => k(x) } + + def main(args: Array[String]): Any = { + println(reset(1 + test(7))) + println(reset(1 + test(8))) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/ifelse1.check b/test/continuations/run/ifelse1.check new file mode 100644 index 0000000000..86a3fbc0c1 --- /dev/null +++ b/test/continuations/run/ifelse1.check @@ -0,0 +1,4 @@ +10 +9 +8 +11
\ No newline at end of file diff --git a/test/continuations/run/ifelse1.scala b/test/continuations/run/ifelse1.scala new file mode 100644 index 0000000000..2ccc1ed730 --- /dev/null +++ b/test/continuations/run/ifelse1.scala @@ -0,0 +1,25 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test1(x:Int) = if (x <= 7) + shift { k: (Int=>Int) => k(k(k(x))) } + else + x + + def test2(x:Int) = if (x <= 7) + x + else + shift { k: (Int=>Int) => k(k(k(x))) } + + def main(args: Array[String]): Any = { + println(reset(1 + test1(7))) + println(reset(1 + test1(8))) + println(reset(1 + test2(7))) + println(reset(1 + test2(8))) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/ifelse2.check b/test/continuations/run/ifelse2.check new file mode 100644 index 0000000000..f97a95b08d --- /dev/null +++ b/test/continuations/run/ifelse2.check @@ -0,0 +1,4 @@ +abort +() +alive +() diff --git a/test/continuations/run/ifelse2.scala b/test/continuations/run/ifelse2.scala new file mode 100644 index 0000000000..536e350190 --- /dev/null +++ b/test/continuations/run/ifelse2.scala @@ -0,0 +1,16 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test(x:Int) = if (x <= 7) + shift { k: (Unit=>Unit) => println("abort") } + + def main(args: Array[String]): Any = { + println(reset{ test(7); println("alive") }) + println(reset{ test(8); println("alive") }) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/ifelse3.check b/test/continuations/run/ifelse3.check new file mode 100644 index 0000000000..95b562c8e6 --- /dev/null +++ b/test/continuations/run/ifelse3.check @@ -0,0 +1,2 @@ +6 +9 diff --git a/test/continuations/run/ifelse3.scala b/test/continuations/run/ifelse3.scala new file mode 100644 index 0000000000..5dbd079d1c --- /dev/null +++ b/test/continuations/run/ifelse3.scala @@ -0,0 +1,21 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def util(x: Boolean) = shift { k: (Boolean=>Int) => k(x) } + + def test(x:Int) = if (util(x <= 7)) + x - 1 + else + x + 1 + + + def main(args: Array[String]): Any = { + println(reset(test(7))) + println(reset(test(8))) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/infer1.scala b/test/continuations/run/infer1.scala new file mode 100644 index 0000000000..a6c6c07215 --- /dev/null +++ b/test/continuations/run/infer1.scala @@ -0,0 +1,33 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test(x: => Int @cpsParam[String,Int]) = 7 + + def test2() = { + val x = shift { k: (Int => String) => 9 } + x + } + + def test3(x: => Int @cpsParam[Int,Int]) = 7 + + + def util() = shift { k: (String => String) => "7" } + + def main(args: Array[String]): Any = { + test { shift { k: (Int => String) => 9 } } + test { shift { k: (Int => String) => 9 }; 2 } +// test { shift { k: (Int => String) => 9 }; util() } <-- doesn't work + test { shift { k: (Int => String) => 9 }; util(); 2 } + + + test { shift { k: (Int => String) => 9 }; { test3(0); 2 } } + + test3 { { test3(0); 2 } } + + } + +}
\ No newline at end of file diff --git a/test/continuations/run/match0.check b/test/continuations/run/match0.check new file mode 100644 index 0000000000..f8bc79860d --- /dev/null +++ b/test/continuations/run/match0.check @@ -0,0 +1,2 @@ +10 +9
\ No newline at end of file diff --git a/test/continuations/run/match0.scala b/test/continuations/run/match0.scala new file mode 100644 index 0000000000..bd36238d7f --- /dev/null +++ b/test/continuations/run/match0.scala @@ -0,0 +1,18 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test(x:Int) = x match { + case 7 => shift { k: (Int=>Int) => k(k(k(x))) } + case 8 => shift { k: (Int=>Int) => k(x) } + } + + def main(args: Array[String]): Any = { + println(reset(1 + test(7))) + println(reset(1 + test(8))) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/match1.check b/test/continuations/run/match1.check new file mode 100644 index 0000000000..73053d3f4f --- /dev/null +++ b/test/continuations/run/match1.check @@ -0,0 +1,2 @@ +10 +9 diff --git a/test/continuations/run/match1.scala b/test/continuations/run/match1.scala new file mode 100644 index 0000000000..ea4e219666 --- /dev/null +++ b/test/continuations/run/match1.scala @@ -0,0 +1,18 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test(x:Int) = x match { + case 7 => shift { k: (Int=>Int) => k(k(k(x))) } + case _ => x + } + + def main(args: Array[String]): Any = { + println(reset(1 + test(7))) + println(reset(1 + test(8))) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/match2.check b/test/continuations/run/match2.check new file mode 100644 index 0000000000..cbf91349cc --- /dev/null +++ b/test/continuations/run/match2.check @@ -0,0 +1,2 @@ +B +B diff --git a/test/continuations/run/match2.scala b/test/continuations/run/match2.scala new file mode 100644 index 0000000000..8d4f04870f --- /dev/null +++ b/test/continuations/run/match2.scala @@ -0,0 +1,26 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def test1() = { + val (a, b) = shift { k: (((String,String)) => String) => k("A","B") } + b + } + + case class Elem[T,U](a: T, b: U) + + def test2() = { + val Elem(a,b) = shift { k: (Elem[String,String] => String) => k(Elem("A","B")) } + b + } + + + def main(args: Array[String]): Any = { + println(reset(test1())) + println(reset(test2())) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/t1807.check b/test/continuations/run/t1807.check new file mode 100644 index 0000000000..56a6051ca2 --- /dev/null +++ b/test/continuations/run/t1807.check @@ -0,0 +1 @@ +1
\ No newline at end of file diff --git a/test/continuations/run/t1807.scala b/test/continuations/run/t1807.scala new file mode 100644 index 0000000000..278b3a9936 --- /dev/null +++ b/test/continuations/run/t1807.scala @@ -0,0 +1,14 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + def main(args: Array[String]): Unit = { + val z = reset { + val f: (() => Int @cps[Int]) = () => 1 + f() + } + println(z) + } +}
\ No newline at end of file diff --git a/test/continuations/run/t1808.scala b/test/continuations/run/t1808.scala new file mode 100644 index 0000000000..125c7c1cdf --- /dev/null +++ b/test/continuations/run/t1808.scala @@ -0,0 +1,10 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + def main(args: Array[String]): Unit = { + reset0 { 0 } + } +}
\ No newline at end of file diff --git a/test/continuations/run/t1820.scala b/test/continuations/run/t1820.scala new file mode 100644 index 0000000000..893ddab6d1 --- /dev/null +++ b/test/continuations/run/t1820.scala @@ -0,0 +1,14 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + def shifted: Unit @suspendable = shift { (k: Unit => Unit) => () } + def test1(b: => Boolean) = { + reset { + if (b) shifted + } + } + def main(args: Array[String]) = test1(true) +}
\ No newline at end of file diff --git a/test/continuations/run/t1821.check b/test/continuations/run/t1821.check new file mode 100644 index 0000000000..f7b76115db --- /dev/null +++ b/test/continuations/run/t1821.check @@ -0,0 +1,4 @@ +() +() +() +()
\ No newline at end of file diff --git a/test/continuations/run/t1821.scala b/test/continuations/run/t1821.scala new file mode 100644 index 0000000000..0d5fb553be --- /dev/null +++ b/test/continuations/run/t1821.scala @@ -0,0 +1,20 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + def suspended[A](x: A): A @suspendable = x + def test1[A](x: A): A @suspendable = suspended(x) match { case x => x } + def test2[A](x: List[A]): A @suspendable = suspended(x) match { case List(x) => x } + + def test3[A](x: A): A @suspendable = x match { case x => x } + def test4[A](x: List[A]): A @suspendable = x match { case List(x) => x } + + def main(args: Array[String]) = { + println(reset(test1())) + println(reset(test2(List(())))) + println(reset(test3())) + println(reset(test4(List(())))) + } +}
\ No newline at end of file diff --git a/test/continuations/run/t2864.check b/test/continuations/run/t2864.check new file mode 100644 index 0000000000..d411bb7c1a --- /dev/null +++ b/test/continuations/run/t2864.check @@ -0,0 +1 @@ +400 diff --git a/test/continuations/run/t2864.scala b/test/continuations/run/t2864.scala new file mode 100644 index 0000000000..7a2579e45c --- /dev/null +++ b/test/continuations/run/t2864.scala @@ -0,0 +1,30 @@ +import scala.util.continuations._ +object Test { + + def double[B](n : Int)(k : Int => B) : B = k(n * 2) + + def main(args : Array[String]) { + reset { + val result1 = shift(double[Unit](100)) + val result2 = shift(double[Unit](result1)) + println(result2) + } + } + + def foo: Int @cps[Int] = { + val a0 = shift((k:Int=>Int) => k(0)) + val x0 = 2 + val a1 = shift((k:Int=>Int) => x0) + 0 + } + +/* + def bar: ControlContext[Int,Int,Int] = { + shiftR((k:Int=>Int) => k(0)).flatMap { a0 => + val x0 = 2 + shiftR((k:Int=>Int) => x0).map { a1 => + 0 + }} + } +*/ +}
\ No newline at end of file diff --git a/test/continuations/run/t2934.check b/test/continuations/run/t2934.check new file mode 100644 index 0000000000..a92586538e --- /dev/null +++ b/test/continuations/run/t2934.check @@ -0,0 +1 @@ +List(3, 4, 5) diff --git a/test/continuations/run/t2934.scala b/test/continuations/run/t2934.scala new file mode 100644 index 0000000000..a1b8ca9e04 --- /dev/null +++ b/test/continuations/run/t2934.scala @@ -0,0 +1,10 @@ +import scala.util.continuations._ + +object Test { + def main(args : Array[String]) { + println(reset { + val x = shift(List(1,2,3).flatMap[Int, List[Int]]) + List(x + 2) + }) + } +} diff --git a/test/continuations/run/t3199.check b/test/continuations/run/t3199.check new file mode 100644 index 0000000000..a065247b8c --- /dev/null +++ b/test/continuations/run/t3199.check @@ -0,0 +1 @@ +Right(7) diff --git a/test/continuations/run/t3199.scala b/test/continuations/run/t3199.scala new file mode 100644 index 0000000000..3fd2f1959a --- /dev/null +++ b/test/continuations/run/t3199.scala @@ -0,0 +1,20 @@ +import _root_.scala.collection.Seq +import _root_.scala.util.control.Exception +import _root_.scala.util.continuations._ + +object Test { + + trait AbstractResource[+R <: AnyRef] { + def reflect[B] : R @cpsParam[B,Either[Throwable, B]] = shift(acquireFor) + def acquireFor[B](f : R => B) : Either[Throwable, B] = { + import Exception._ + catching(List(classOf[Throwable]) : _*) either (f(null.asInstanceOf[R])) + } + } + + def main(args: Array[String]) : Unit = { + val x = new AbstractResource[String] { } + val result = x.acquireFor( x => 7 ) + println(result) + } + } diff --git a/test/continuations/run/t3199b.check b/test/continuations/run/t3199b.check new file mode 100644 index 0000000000..b5d8bb58d9 --- /dev/null +++ b/test/continuations/run/t3199b.check @@ -0,0 +1 @@ +[1, 2, 3] diff --git a/test/continuations/run/t3199b.scala b/test/continuations/run/t3199b.scala new file mode 100644 index 0000000000..950c584153 --- /dev/null +++ b/test/continuations/run/t3199b.scala @@ -0,0 +1,11 @@ +object Test { + + def test() = { + java.util.Arrays.asList(Array(1,2,3):_*) + } + + def main(args: Array[String]) = { + println(test()) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/t3223.check b/test/continuations/run/t3223.check new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/test/continuations/run/t3223.check @@ -0,0 +1 @@ +9 diff --git a/test/continuations/run/t3223.scala b/test/continuations/run/t3223.scala new file mode 100644 index 0000000000..4e510178e6 --- /dev/null +++ b/test/continuations/run/t3223.scala @@ -0,0 +1,19 @@ +import scala.util.continuations._ +object Test { + + def foo(x:Int) = { + try { + throw new Exception + shiftUnit0[Int,Int](7) + } catch { + case ex => + val g = (a:Int)=>a + 9 + } + } + + def main(args: Array[String]) { + println(reset(foo(0))) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/t3225.check b/test/continuations/run/t3225.check new file mode 100644 index 0000000000..df1a8a9ce4 --- /dev/null +++ b/test/continuations/run/t3225.check @@ -0,0 +1,12 @@ +8 +8 +9 +9 +8 +9 +8 +8 +9 +9 +8 +9 diff --git a/test/continuations/run/t3225.scala b/test/continuations/run/t3225.scala new file mode 100644 index 0000000000..ecfde279cf --- /dev/null +++ b/test/continuations/run/t3225.scala @@ -0,0 +1,56 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + class Bla { + val x = 8 + def y[T] = 9 + } + +/* + def bla[A] = shift { k:(Bla=>A) => k(new Bla) } +*/ + + def bla1 = shift { k:(Bla=>Bla) => k(new Bla) } + def bla2 = shift { k:(Bla=>Int) => k(new Bla) } + + def fooA = bla2.x + def fooB[T] = bla2.y[T] + + def testMono() = { + println(reset(bla1).x) + println(reset(bla2.x)) + println(reset(bla2.y[Int])) + println(reset(bla2.y)) + println(reset(fooA)) + println(reset(fooB)) + 0 + } + + def blaX[A] = shift { k:(Bla=>A) => k(new Bla) } + + def fooX[A] = blaX[A].x + def fooY[A] = blaX[A].y[A] + + def testPoly() = { + println(reset(blaX[Bla]).x) + println(reset(blaX[Int].x)) + println(reset(blaX[Int].y[Int])) + println(reset(blaX[Int].y)) + println(reset(fooX[Int])) + println(reset(fooY[Int])) + 0 + } + + + // TODO: check whether this also applies to a::shift { k => ... } + + def main(args: Array[String]) = { + testMono() + testPoly() + } + +} diff --git a/test/continuations/run/trycatch0.check b/test/continuations/run/trycatch0.check new file mode 100644 index 0000000000..36806909d0 --- /dev/null +++ b/test/continuations/run/trycatch0.check @@ -0,0 +1,2 @@ +10 +10
\ No newline at end of file diff --git a/test/continuations/run/trycatch0.scala b/test/continuations/run/trycatch0.scala new file mode 100644 index 0000000000..74a078b5ef --- /dev/null +++ b/test/continuations/run/trycatch0.scala @@ -0,0 +1,25 @@ +// $Id$ + +import scala.util.continuations._ + +object Test { + + def foo = try { + shift((k: Int=>Int) => k(7)) + } catch { + case ex => + 9 + } + + def bar = try { + 7 + } catch { + case ex => + shiftUnit0[Int,Int](9) + } + + def main(args: Array[String]): Unit = { + println(reset { foo + 3 }) + println(reset { bar + 3 }) + } +}
\ No newline at end of file diff --git a/test/continuations/run/trycatch1.check b/test/continuations/run/trycatch1.check new file mode 100644 index 0000000000..a028d2b1e1 --- /dev/null +++ b/test/continuations/run/trycatch1.check @@ -0,0 +1,4 @@ +12 +12 +12 +12
\ No newline at end of file diff --git a/test/continuations/run/trycatch1.scala b/test/continuations/run/trycatch1.scala new file mode 100644 index 0000000000..ade13794e3 --- /dev/null +++ b/test/continuations/run/trycatch1.scala @@ -0,0 +1,48 @@ +// $Id$ + +import scala.util.continuations._ + +object Test { + + def fatal: Int = throw new Exception() + + def foo1 = try { + fatal + shift((k: Int=>Int) => k(7)) + } catch { + case ex => + 9 + } + + def foo2 = try { + shift((k: Int=>Int) => k(7)) + fatal + } catch { + case ex => + 9 + } + + def bar1 = try { + fatal + 7 + } catch { + case ex => + shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner + } + + def bar2 = try { + 7 + fatal + } catch { + case ex => + shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner + } + + def main(args: Array[String]): Unit = { + println(reset { foo1 + 3 }) + println(reset { foo2 + 3 }) + println(reset { bar1 + 3 }) + println(reset { bar2 + 3 }) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/while0.check b/test/continuations/run/while0.check new file mode 100644 index 0000000000..d58c55a31d --- /dev/null +++ b/test/continuations/run/while0.check @@ -0,0 +1 @@ +9000 diff --git a/test/continuations/run/while0.scala b/test/continuations/run/while0.scala new file mode 100644 index 0000000000..9735f9d2c3 --- /dev/null +++ b/test/continuations/run/while0.scala @@ -0,0 +1,22 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def foo(): Int @cps[Unit] = 2 + + def test(): Unit @cps[Unit] = { + var x = 0 + while (x < 9000) { // pick number large enough to require tail-call opt + x += foo() + } + println(x) + } + + def main(args: Array[String]): Any = { + reset(test()) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/while1.check b/test/continuations/run/while1.check new file mode 100644 index 0000000000..3d5f0b9a46 --- /dev/null +++ b/test/continuations/run/while1.check @@ -0,0 +1,11 @@ +up +up +up +up +up +10 +down +down +down +down +down diff --git a/test/continuations/run/while1.scala b/test/continuations/run/while1.scala new file mode 100644 index 0000000000..fb5dc0079a --- /dev/null +++ b/test/continuations/run/while1.scala @@ -0,0 +1,22 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def foo(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") } + + def test(): Unit @cps[Unit] = { + var x = 0 + while (x < 9) { + x += foo() + } + println(x) + } + + def main(args: Array[String]): Any = { + reset(test()) + } + +}
\ No newline at end of file diff --git a/test/continuations/run/while2.check b/test/continuations/run/while2.check new file mode 100644 index 0000000000..9fe515181b --- /dev/null +++ b/test/continuations/run/while2.check @@ -0,0 +1,19 @@ +up +up +up +up +up +up +up +up +up +9000 +down +down +down +down +down +down +down +down +down diff --git a/test/continuations/run/while2.scala b/test/continuations/run/while2.scala new file mode 100644 index 0000000000..f36288929e --- /dev/null +++ b/test/continuations/run/while2.scala @@ -0,0 +1,23 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + def foo1(): Int @cps[Unit] = 2 + def foo2(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") } + + def test(): Unit @cps[Unit] = { + var x = 0 + while (x < 9000) { // pick number large enough to require tail-call opt + x += (if (x % 1000 != 0) foo1() else foo2()) + } + println(x) + } + + def main(args: Array[String]): Any = { + reset(test()) + } + +}
\ No newline at end of file diff --git a/test/debug/buildmanager/.gitignore b/test/debug/buildmanager/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/buildmanager/.gitignore diff --git a/test/debug/jvm/.gitignore b/test/debug/jvm/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/jvm/.gitignore diff --git a/test/debug/neg/.gitignore b/test/debug/neg/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/neg/.gitignore diff --git a/test/debug/pos/.gitignore b/test/debug/pos/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/pos/.gitignore diff --git a/test/debug/res/.gitignore b/test/debug/res/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/res/.gitignore diff --git a/test/debug/run/.gitignore b/test/debug/run/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/run/.gitignore diff --git a/test/debug/scalacheck/.gitignore b/test/debug/scalacheck/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/scalacheck/.gitignore diff --git a/test/debug/scalap/.gitignore b/test/debug/scalap/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/scalap/.gitignore diff --git a/test/debug/shootout/.gitignore b/test/debug/shootout/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/debug/shootout/.gitignore diff --git a/test/files/script/loadAndExecute/loadAndExecute.check b/test/disabled-windows/script/loadAndExecute.check index ccd8cd6e37..ccd8cd6e37 100644 --- a/test/files/script/loadAndExecute/loadAndExecute.check +++ b/test/disabled-windows/script/loadAndExecute.check diff --git a/test/files/script/loadAndExecute/lAndE1.scala b/test/disabled-windows/script/loadAndExecute/lAndE1.scala index b20d1a9428..b20d1a9428 100755 --- a/test/files/script/loadAndExecute/lAndE1.scala +++ b/test/disabled-windows/script/loadAndExecute/lAndE1.scala diff --git a/test/files/script/loadAndExecute/lAndE2.scala b/test/disabled-windows/script/loadAndExecute/lAndE2.scala index ea15a04d86..ea15a04d86 100755 --- a/test/files/script/loadAndExecute/lAndE2.scala +++ b/test/disabled-windows/script/loadAndExecute/lAndE2.scala diff --git a/test/files/script/loadAndExecute/loadAndExecute.scala b/test/disabled-windows/script/loadAndExecute/loadAndExecute.scala index 2a9718382b..2a9718382b 100755 --- a/test/files/script/loadAndExecute/loadAndExecute.scala +++ b/test/disabled-windows/script/loadAndExecute/loadAndExecute.scala diff --git a/test/files/script/utf8.bat b/test/disabled-windows/script/utf8.bat index 8bc5c886f7..8bc5c886f7 100755 --- a/test/files/script/utf8.bat +++ b/test/disabled-windows/script/utf8.bat diff --git a/test/files/script/utf8.check b/test/disabled-windows/script/utf8.check index 29dc0518ff..29dc0518ff 100644 --- a/test/files/script/utf8.check +++ b/test/disabled-windows/script/utf8.check diff --git a/test/files/script/utf8.scala b/test/disabled-windows/script/utf8.scala index 5366562cee..f294498cd2 100755 --- a/test/files/script/utf8.scala +++ b/test/disabled-windows/script/utf8.scala @@ -1,6 +1,6 @@ #!/bin/sh -# fact - A simple Scala script that prints out the factorial of -# the argument specified on the command line. +# +# Checks if UTF-8 output makes it through unmangled. cygwin=false; case "`uname`" in @@ -18,8 +18,7 @@ then SOURCE=`cygpath --$format "$SOURCE"`; fi -export LC_CTYPE=en_US.UTF-8 -exec scala -nocompdaemon "$SOURCE" "$@" +exec scala -Dfile.encoding="UTF-8" -nocompdaemon "$SOURCE" "$@" !# /*Comment Комментарий*/ diff --git a/test/disabled/buildmanager/t2651_1/A.scala b/test/disabled/buildmanager/t2651_1/A.scala new file mode 100644 index 0000000000..d712f6febe --- /dev/null +++ b/test/disabled/buildmanager/t2651_1/A.scala @@ -0,0 +1 @@ +trait A[T] diff --git a/test/disabled/buildmanager/t2651_1/B.scala b/test/disabled/buildmanager/t2651_1/B.scala new file mode 100644 index 0000000000..a8aca3d0ed --- /dev/null +++ b/test/disabled/buildmanager/t2651_1/B.scala @@ -0,0 +1,2 @@ +trait B[T] extends A[T] + diff --git a/test/disabled/buildmanager/t2651_1/C.scala b/test/disabled/buildmanager/t2651_1/C.scala new file mode 100644 index 0000000000..690dcf518d --- /dev/null +++ b/test/disabled/buildmanager/t2651_1/C.scala @@ -0,0 +1,3 @@ +object C { + new A[Int] {} +} diff --git a/test/disabled/buildmanager/t2651_1/D.scala b/test/disabled/buildmanager/t2651_1/D.scala new file mode 100644 index 0000000000..51273ad986 --- /dev/null +++ b/test/disabled/buildmanager/t2651_1/D.scala @@ -0,0 +1,3 @@ +object D { + def x[T](a: A[T]) = a +} diff --git a/test/disabled/buildmanager/t2651_1/t2651_1.changes/A2.scala b/test/disabled/buildmanager/t2651_1/t2651_1.changes/A2.scala new file mode 100644 index 0000000000..574b522149 --- /dev/null +++ b/test/disabled/buildmanager/t2651_1/t2651_1.changes/A2.scala @@ -0,0 +1,2 @@ +trait A + diff --git a/test/disabled/buildmanager/t2651_1/t2651_1.check b/test/disabled/buildmanager/t2651_1/t2651_1.check new file mode 100644 index 0000000000..8d2cbc8194 --- /dev/null +++ b/test/disabled/buildmanager/t2651_1/t2651_1.check @@ -0,0 +1,19 @@ +builder > A.scala B.scala C.scala D.scala +compiling Set(A.scala, B.scala, C.scala, D.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(trait A -> List(Changed(Class(A))[ tparams: List()])) +invalidate B.scala because parents have changed [Changed(Class(A))[ tparams: List()]] +invalidate C.scala because parents have changed [Changed(Class(A))[ tparams: List()]] +invalidate D.scala because it references changed class [Changed(Class(A))[ tparams: List()]] +compiling Set(B.scala, C.scala, D.scala) +B.scala:1: error: A does not take type parameters +trait B[T] extends A[T] + ^ +C.scala:2: error: A does not take type parameters + new A[Int] {} + ^ +D.scala:2: error: A does not take type parameters + def x[T](a: A[T]) = a + ^ diff --git a/test/disabled/buildmanager/t2651_1/t2651_1.test b/test/disabled/buildmanager/t2651_1/t2651_1.test new file mode 100644 index 0000000000..4f67d5e233 --- /dev/null +++ b/test/disabled/buildmanager/t2651_1/t2651_1.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala C.scala D.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/jvm/JavaInteraction.check b/test/disabled/jvm/JavaInteraction.check index fb9d3cdd8c..fb9d3cdd8c 100644 --- a/test/files/jvm/JavaInteraction.check +++ b/test/disabled/jvm/JavaInteraction.check diff --git a/test/files/jvm/JavaInteraction.scala b/test/disabled/jvm/JavaInteraction.scala index 1316fad5d4..1316fad5d4 100644 --- a/test/files/jvm/JavaInteraction.scala +++ b/test/disabled/jvm/JavaInteraction.scala diff --git a/test/pending/pos/t1053.scala b/test/disabled/pos/t1053.scala index 1d4dfb637e..1d4dfb637e 100644 --- a/test/pending/pos/t1053.scala +++ b/test/disabled/pos/t1053.scala diff --git a/test/pending/pos/t2619.scala b/test/disabled/pos/t2619.scala index 565bc9572b..565bc9572b 100644 --- a/test/pending/pos/t2619.scala +++ b/test/disabled/pos/t2619.scala diff --git a/test/pending/pos/ticket2251.scala b/test/disabled/pos/ticket2251.scala index 7b6efb0ea0..7b6efb0ea0 100644 --- a/test/pending/pos/ticket2251.scala +++ b/test/disabled/pos/ticket2251.scala diff --git a/test/disabled/run/docgenerator.scala b/test/disabled/run/docgenerator.scala index 59f90ba415..8e0c7589ad 100644 --- a/test/disabled/run/docgenerator.scala +++ b/test/disabled/run/docgenerator.scala @@ -10,7 +10,7 @@ object Test { def main(args: Array[String]) { // overwrites value of UrlContext.generator in file DocUtil.scala System.setProperty("doc.generator", "scaladoc") - var dirname = System.getProperty("scalatest.output") + var dirname = System.getProperty("partest.output") if (dirname eq null) dirname = System.getProperty("java.io.tmpdir") val tmpDir = new File(dirname) tmpDir.mkdirs() @@ -116,7 +116,7 @@ object Foo2 { // when running that compiler, give it a scala-library to the classpath docSettings.classpath.value = System.getProperty("java.class.path") reporter = new ConsoleReporter(docSettings) - val command = new CompilerCommand(args.toList, docSettings, error, false) + val command = new CompilerCommand(args.toList, docSettings) try { object compiler extends Global(command.settings, reporter) { override protected def computeInternalPhases() : Unit = { diff --git a/test/files/bench/equality/eqeq.log b/test/files/bench/equality/eqeq.eqlog index d1e27aceed..d1e27aceed 100755..100644 --- a/test/files/bench/equality/eqeq.log +++ b/test/files/bench/equality/eqeq.eqlog diff --git a/test/files/buildmanager/annotated/A.scala b/test/files/buildmanager/annotated/A.scala new file mode 100644 index 0000000000..4130cf21ec --- /dev/null +++ b/test/files/buildmanager/annotated/A.scala @@ -0,0 +1 @@ +case class A[T](x: String, y: T) diff --git a/test/files/buildmanager/annotated/annotated.check b/test/files/buildmanager/annotated/annotated.check new file mode 100644 index 0000000000..ce92c9a294 --- /dev/null +++ b/test/files/buildmanager/annotated/annotated.check @@ -0,0 +1,6 @@ +builder > A.scala +compiling Set(A.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(), object A -> List()) diff --git a/test/files/buildmanager/annotated/annotated.test b/test/files/buildmanager/annotated/annotated.test new file mode 100644 index 0000000000..392e0d365f --- /dev/null +++ b/test/files/buildmanager/annotated/annotated.test @@ -0,0 +1,2 @@ +>>compile A.scala +>>compile A.scala diff --git a/test/files/buildmanager/freshnames/A.scala b/test/files/buildmanager/freshnames/A.scala new file mode 100644 index 0000000000..88ea44b3c7 --- /dev/null +++ b/test/files/buildmanager/freshnames/A.scala @@ -0,0 +1,16 @@ +abstract class A { + + var t: List[B] + + def foo(n: String): Option[B] = { + t.reverse find (_.names contains n) + } + + def bar(n: Int): Option[B] = { + t.reverse find (_.names contains n) + } +} + +//class A +case class B(names: List[String]) + diff --git a/test/files/buildmanager/freshnames/B.scala b/test/files/buildmanager/freshnames/B.scala new file mode 100644 index 0000000000..d700225c08 --- /dev/null +++ b/test/files/buildmanager/freshnames/B.scala @@ -0,0 +1,4 @@ +abstract class C extends A { + def test(n: Int) = bar(n) +} + diff --git a/test/files/buildmanager/freshnames/freshnames.check b/test/files/buildmanager/freshnames/freshnames.check new file mode 100644 index 0000000000..9f05fb8a36 --- /dev/null +++ b/test/files/buildmanager/freshnames/freshnames.check @@ -0,0 +1,6 @@ +builder > B.scala A.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(), class B -> List(), object B -> List()) diff --git a/test/files/buildmanager/freshnames/freshnames.test b/test/files/buildmanager/freshnames/freshnames.test new file mode 100644 index 0000000000..20b20298f9 --- /dev/null +++ b/test/files/buildmanager/freshnames/freshnames.test @@ -0,0 +1,2 @@ +>>compile B.scala A.scala +>>compile A.scala diff --git a/test/files/buildmanager/infer/A.scala b/test/files/buildmanager/infer/A.scala new file mode 100644 index 0000000000..5e0e268122 --- /dev/null +++ b/test/files/buildmanager/infer/A.scala @@ -0,0 +1,16 @@ +class Foo(flag: Boolean) { + val classpath = + if (flag) + new AClasspath + else + new BClasspath +} + +class AClasspath extends MergedClasspath[A] + +class BClasspath extends MergedClasspath[B] + +abstract class MergedClasspath[T] + +class A +class B diff --git a/test/files/buildmanager/infer/infer.check b/test/files/buildmanager/infer/infer.check new file mode 100644 index 0000000000..1f736977ff --- /dev/null +++ b/test/files/buildmanager/infer/infer.check @@ -0,0 +1,6 @@ +builder > A.scala +compiling Set(A.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(), class AClasspath -> List(), class B -> List(), class BClasspath -> List(), class Foo -> List(), class MergedClasspath -> List()) diff --git a/test/files/buildmanager/infer/infer.test b/test/files/buildmanager/infer/infer.test new file mode 100644 index 0000000000..392e0d365f --- /dev/null +++ b/test/files/buildmanager/infer/infer.test @@ -0,0 +1,2 @@ +>>compile A.scala +>>compile A.scala diff --git a/test/files/buildmanager/overloaded_1/A.scala b/test/files/buildmanager/overloaded_1/A.scala new file mode 100644 index 0000000000..c070faf978 --- /dev/null +++ b/test/files/buildmanager/overloaded_1/A.scala @@ -0,0 +1,11 @@ +trait As { + trait C extends D { + override def foo = this /// Shouldn't cause the change + override def foo(act: List[D]) = this + } + + abstract class D{ + def foo: D = this + def foo(act: List[D]) = this + } +} diff --git a/test/files/buildmanager/overloaded_1/overloaded_1.check b/test/files/buildmanager/overloaded_1/overloaded_1.check new file mode 100644 index 0000000000..4d643ce6b4 --- /dev/null +++ b/test/files/buildmanager/overloaded_1/overloaded_1.check @@ -0,0 +1,6 @@ +builder > A.scala +compiling Set(A.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class As$D -> List(), object As$C$class -> List(), object As$class -> List(), trait As -> List(), trait As$C -> List()) diff --git a/test/files/buildmanager/overloaded_1/overloaded_1.test b/test/files/buildmanager/overloaded_1/overloaded_1.test new file mode 100644 index 0000000000..392e0d365f --- /dev/null +++ b/test/files/buildmanager/overloaded_1/overloaded_1.test @@ -0,0 +1,2 @@ +>>compile A.scala +>>compile A.scala diff --git a/test/files/buildmanager/simpletest/A.scala b/test/files/buildmanager/simpletest/A.scala new file mode 100644 index 0000000000..ef704706bb --- /dev/null +++ b/test/files/buildmanager/simpletest/A.scala @@ -0,0 +1,3 @@ +class A { + def foo = 2 +} diff --git a/test/files/buildmanager/simpletest/B.scala b/test/files/buildmanager/simpletest/B.scala new file mode 100644 index 0000000000..364dc6e4cb --- /dev/null +++ b/test/files/buildmanager/simpletest/B.scala @@ -0,0 +1,3 @@ +class B extends A { + override def foo = 2 +} diff --git a/test/files/buildmanager/simpletest/simpletest.changes/A1.scala b/test/files/buildmanager/simpletest/simpletest.changes/A1.scala new file mode 100644 index 0000000000..83d15dc739 --- /dev/null +++ b/test/files/buildmanager/simpletest/simpletest.changes/A1.scala @@ -0,0 +1 @@ +class A diff --git a/test/files/buildmanager/simpletest/simpletest.check b/test/files/buildmanager/simpletest/simpletest.check new file mode 100644 index 0000000000..95ea2c4c0d --- /dev/null +++ b/test/files/buildmanager/simpletest/simpletest.check @@ -0,0 +1,11 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(Removed(Definition(A.foo)))) +invalidate B.scala because inherited method removed [Removed(Definition(A.foo))] +compiling Set(B.scala) +B.scala:2: error: method foo overrides nothing + override def foo = 2 + ^ diff --git a/test/files/buildmanager/simpletest/simpletest.test b/test/files/buildmanager/simpletest/simpletest.test new file mode 100644 index 0000000000..2c0be1502f --- /dev/null +++ b/test/files/buildmanager/simpletest/simpletest.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A1.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2280/A.scala b/test/files/buildmanager/t2280/A.scala new file mode 100644 index 0000000000..5febadeb06 --- /dev/null +++ b/test/files/buildmanager/t2280/A.scala @@ -0,0 +1 @@ +class A extends B diff --git a/test/files/buildmanager/t2280/B.java b/test/files/buildmanager/t2280/B.java new file mode 100644 index 0000000000..aef8e106e9 --- /dev/null +++ b/test/files/buildmanager/t2280/B.java @@ -0,0 +1,2 @@ +public class B {} + diff --git a/test/files/buildmanager/t2280/t2280.check b/test/files/buildmanager/t2280/t2280.check new file mode 100644 index 0000000000..7ea7511c63 --- /dev/null +++ b/test/files/buildmanager/t2280/t2280.check @@ -0,0 +1,6 @@ +builder > A.scala B.java +compiling Set(A.scala, B.java) +Changes: Map() +builder > B.java +compiling Set(B.java) +Changes: Map(class B -> List()) diff --git a/test/files/buildmanager/t2280/t2280.test b/test/files/buildmanager/t2280/t2280.test new file mode 100644 index 0000000000..2eda777853 --- /dev/null +++ b/test/files/buildmanager/t2280/t2280.test @@ -0,0 +1,2 @@ +>>compile A.scala B.java +>>compile B.java diff --git a/test/files/buildmanager/t2556_1/A.scala b/test/files/buildmanager/t2556_1/A.scala new file mode 100644 index 0000000000..c6e200b217 --- /dev/null +++ b/test/files/buildmanager/t2556_1/A.scala @@ -0,0 +1,3 @@ +class A { + def x(i: Int) = i+"3" +} diff --git a/test/files/buildmanager/t2556_1/B.scala b/test/files/buildmanager/t2556_1/B.scala new file mode 100644 index 0000000000..8529587b56 --- /dev/null +++ b/test/files/buildmanager/t2556_1/B.scala @@ -0,0 +1,3 @@ +class B extends A { + def x(s: String) = s+"5" +} diff --git a/test/files/buildmanager/t2556_1/t2556_1.changes/A2.scala b/test/files/buildmanager/t2556_1/t2556_1.changes/A2.scala new file mode 100644 index 0000000000..4ac1045e13 --- /dev/null +++ b/test/files/buildmanager/t2556_1/t2556_1.changes/A2.scala @@ -0,0 +1,4 @@ +class A { + def x(i: String) = i+"3" +} + diff --git a/test/files/buildmanager/t2556_1/t2556_1.check b/test/files/buildmanager/t2556_1/t2556_1.check new file mode 100644 index 0000000000..dc9437fa7e --- /dev/null +++ b/test/files/buildmanager/t2556_1/t2556_1.check @@ -0,0 +1,12 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(Changed(Definition(A.x))[method x changed from (i: Int)java.lang.String to (i: java.lang.String)java.lang.String flags: <method>])) +invalidate B.scala because inherited method changed [Changed(Definition(A.x))[method x changed from (i: Int)java.lang.String to (i: java.lang.String)java.lang.String flags: <method>]] +compiling Set(B.scala) +B.scala:2: error: overriding method x in class A of type (i: String)java.lang.String; + method x needs `override' modifier + def x(s: String) = s+"5" + ^ diff --git a/test/files/buildmanager/t2556_1/t2556_1.test b/test/files/buildmanager/t2556_1/t2556_1.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2556_1/t2556_1.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2556_2/A.scala b/test/files/buildmanager/t2556_2/A.scala new file mode 100644 index 0000000000..b8da5c8fb1 --- /dev/null +++ b/test/files/buildmanager/t2556_2/A.scala @@ -0,0 +1,4 @@ +class A { + def x(i: Int) = i+"3" +} + diff --git a/test/files/buildmanager/t2556_2/B.scala b/test/files/buildmanager/t2556_2/B.scala new file mode 100644 index 0000000000..80ff25d0ca --- /dev/null +++ b/test/files/buildmanager/t2556_2/B.scala @@ -0,0 +1,2 @@ +class B extends A + diff --git a/test/files/buildmanager/t2556_2/C.scala b/test/files/buildmanager/t2556_2/C.scala new file mode 100644 index 0000000000..0ab13e3757 --- /dev/null +++ b/test/files/buildmanager/t2556_2/C.scala @@ -0,0 +1,4 @@ +class C extends B { + def x(s: String) = s+"5" +} + diff --git a/test/files/buildmanager/t2556_2/t2556_2.changes/A2.scala b/test/files/buildmanager/t2556_2/t2556_2.changes/A2.scala new file mode 100644 index 0000000000..4ac1045e13 --- /dev/null +++ b/test/files/buildmanager/t2556_2/t2556_2.changes/A2.scala @@ -0,0 +1,4 @@ +class A { + def x(i: String) = i+"3" +} + diff --git a/test/files/buildmanager/t2556_2/t2556_2.check b/test/files/buildmanager/t2556_2/t2556_2.check new file mode 100644 index 0000000000..a4d6724b11 --- /dev/null +++ b/test/files/buildmanager/t2556_2/t2556_2.check @@ -0,0 +1,13 @@ +builder > A.scala B.scala C.scala +compiling Set(A.scala, B.scala, C.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(Changed(Definition(A.x))[method x changed from (i: Int)java.lang.String to (i: java.lang.String)java.lang.String flags: <method>])) +invalidate B.scala because inherited method changed [Changed(Definition(A.x))[method x changed from (i: Int)java.lang.String to (i: java.lang.String)java.lang.String flags: <method>]] +invalidate C.scala because inherited method changed [Changed(Definition(A.x))[method x changed from (i: Int)java.lang.String to (i: java.lang.String)java.lang.String flags: <method>]] +compiling Set(B.scala, C.scala) +C.scala:2: error: overriding method x in class A of type (i: String)java.lang.String; + method x needs `override' modifier + def x(s: String) = s+"5" + ^ diff --git a/test/files/buildmanager/t2556_2/t2556_2.test b/test/files/buildmanager/t2556_2/t2556_2.test new file mode 100644 index 0000000000..9f31bb6409 --- /dev/null +++ b/test/files/buildmanager/t2556_2/t2556_2.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala C.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2556_3/A.scala b/test/files/buildmanager/t2556_3/A.scala new file mode 100644 index 0000000000..089a05f493 --- /dev/null +++ b/test/files/buildmanager/t2556_3/A.scala @@ -0,0 +1,5 @@ +class A { + def x = 3 +} +class B extends A + diff --git a/test/files/buildmanager/t2556_3/B.scala b/test/files/buildmanager/t2556_3/B.scala new file mode 100644 index 0000000000..0ec5ae4b55 --- /dev/null +++ b/test/files/buildmanager/t2556_3/B.scala @@ -0,0 +1,5 @@ +object E { + def main(args: Array[String]) = + println( (new C).x ) +} + diff --git a/test/files/buildmanager/t2556_3/C.scala b/test/files/buildmanager/t2556_3/C.scala new file mode 100644 index 0000000000..403df8455e --- /dev/null +++ b/test/files/buildmanager/t2556_3/C.scala @@ -0,0 +1,2 @@ +class C extends B + diff --git a/test/files/buildmanager/t2556_3/t2556_3.changes/A2.scala b/test/files/buildmanager/t2556_3/t2556_3.changes/A2.scala new file mode 100644 index 0000000000..21cb2779f9 --- /dev/null +++ b/test/files/buildmanager/t2556_3/t2556_3.changes/A2.scala @@ -0,0 +1,5 @@ +class A { + def x = 3 +} +class B + diff --git a/test/files/buildmanager/t2556_3/t2556_3.check b/test/files/buildmanager/t2556_3/t2556_3.check new file mode 100644 index 0000000000..af0c63eebc --- /dev/null +++ b/test/files/buildmanager/t2556_3/t2556_3.check @@ -0,0 +1,18 @@ +builder > A.scala B.scala C.scala +compiling Set(A.scala, B.scala, C.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(), class B -> List(Changed(Class(B))[List((A,java.lang.Object), (ScalaObject,ScalaObject))])) +invalidate C.scala because parents have changed [Changed(Class(B))[List((A,java.lang.Object), (ScalaObject,ScalaObject))]] +invalidate B.scala because it references invalid (no longer inherited) definition [ParentChanged(Class(C))] +compiling Set(B.scala, C.scala) +B.scala:3: error: type mismatch; + found : C + required: ?{val x: ?} +Note that implicit conversions are not applicable because they are ambiguous: + both method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A] + and method any2Ensuring in object Predef of type [A](x: A)Ensuring[A] + are possible conversion functions from C to ?{val x: ?} + println( (new C).x ) + ^ diff --git a/test/files/buildmanager/t2556_3/t2556_3.test b/test/files/buildmanager/t2556_3/t2556_3.test new file mode 100644 index 0000000000..9f31bb6409 --- /dev/null +++ b/test/files/buildmanager/t2556_3/t2556_3.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala C.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2557/A.scala b/test/files/buildmanager/t2557/A.scala new file mode 100644 index 0000000000..3be55f19a6 --- /dev/null +++ b/test/files/buildmanager/t2557/A.scala @@ -0,0 +1,4 @@ +trait A { + def x = 3 +} + diff --git a/test/files/buildmanager/t2557/B.scala b/test/files/buildmanager/t2557/B.scala new file mode 100644 index 0000000000..ea86a90079 --- /dev/null +++ b/test/files/buildmanager/t2557/B.scala @@ -0,0 +1,4 @@ +trait B extends A { + override def x = super.x * 2 +} + diff --git a/test/files/buildmanager/t2557/C.scala b/test/files/buildmanager/t2557/C.scala new file mode 100644 index 0000000000..dd575ac38d --- /dev/null +++ b/test/files/buildmanager/t2557/C.scala @@ -0,0 +1,3 @@ +trait C extends A { + override def x = super.x + 5 +} diff --git a/test/files/buildmanager/t2557/D.scala b/test/files/buildmanager/t2557/D.scala new file mode 100644 index 0000000000..4e662a80ce --- /dev/null +++ b/test/files/buildmanager/t2557/D.scala @@ -0,0 +1 @@ +trait D extends C with B diff --git a/test/files/buildmanager/t2557/E.scala b/test/files/buildmanager/t2557/E.scala new file mode 100644 index 0000000000..2aee552675 --- /dev/null +++ b/test/files/buildmanager/t2557/E.scala @@ -0,0 +1 @@ +trait E extends D diff --git a/test/files/buildmanager/t2557/F.scala b/test/files/buildmanager/t2557/F.scala new file mode 100644 index 0000000000..e1996704e7 --- /dev/null +++ b/test/files/buildmanager/t2557/F.scala @@ -0,0 +1,4 @@ +object F extends E { + def main(args: Array[String]) = + println(x) +} diff --git a/test/files/buildmanager/t2557/t2557.changes/D2.scala b/test/files/buildmanager/t2557/t2557.changes/D2.scala new file mode 100644 index 0000000000..67295f8e6d --- /dev/null +++ b/test/files/buildmanager/t2557/t2557.changes/D2.scala @@ -0,0 +1,2 @@ +trait D extends B with C + diff --git a/test/files/buildmanager/t2557/t2557.check b/test/files/buildmanager/t2557/t2557.check new file mode 100644 index 0000000000..f51e801017 --- /dev/null +++ b/test/files/buildmanager/t2557/t2557.check @@ -0,0 +1,10 @@ +builder > A.scala B.scala C.scala D.scala E.scala F.scala +compiling Set(A.scala, B.scala, C.scala, D.scala, E.scala, F.scala) +Changes: Map() +builder > D.scala +compiling Set(D.scala) +Changes: Map(trait D -> List(Changed(Class(D))[List((java.lang.Object,java.lang.Object), (C,B), (B,C))])) +invalidate E.scala because parents have changed [Changed(Class(D))[List((java.lang.Object,java.lang.Object), (C,B), (B,C))]] +invalidate F.scala because parents have changed [Changed(Class(D))[List((java.lang.Object,java.lang.Object), (C,B), (B,C))]] +compiling Set(E.scala, F.scala) +Changes: Map(object F -> List(), trait E -> List()) diff --git a/test/files/buildmanager/t2557/t2557.test b/test/files/buildmanager/t2557/t2557.test new file mode 100644 index 0000000000..6b0103092f --- /dev/null +++ b/test/files/buildmanager/t2557/t2557.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala C.scala D.scala E.scala F.scala +>>update D.scala=>D2.scala +>>compile D.scala diff --git a/test/files/buildmanager/t2559/A.scala b/test/files/buildmanager/t2559/A.scala new file mode 100644 index 0000000000..fb4f6e3545 --- /dev/null +++ b/test/files/buildmanager/t2559/A.scala @@ -0,0 +1,5 @@ +sealed trait A +class B extends A +class C extends A +//class E extends A + diff --git a/test/files/buildmanager/t2559/D.scala b/test/files/buildmanager/t2559/D.scala new file mode 100644 index 0000000000..4b8422db04 --- /dev/null +++ b/test/files/buildmanager/t2559/D.scala @@ -0,0 +1,8 @@ +object D { + def x(a: A) = + a match { + case _: B => () + case _: C => () + } +} + diff --git a/test/files/buildmanager/t2559/t2559.changes/A2.scala b/test/files/buildmanager/t2559/t2559.changes/A2.scala new file mode 100644 index 0000000000..8e90594e2c --- /dev/null +++ b/test/files/buildmanager/t2559/t2559.changes/A2.scala @@ -0,0 +1,5 @@ +sealed trait A +class B extends A +class C extends A +class E extends A + diff --git a/test/files/buildmanager/t2559/t2559.check b/test/files/buildmanager/t2559/t2559.check new file mode 100644 index 0000000000..752278fbe8 --- /dev/null +++ b/test/files/buildmanager/t2559/t2559.check @@ -0,0 +1,14 @@ +builder > A.scala D.scala +compiling Set(A.scala, D.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class B -> List(), class C -> List(), class E -> List(Changed(Class(A))[class E extends a sealed trait A]), trait A -> List()) +invalidate D.scala because it references changed class [Changed(Class(A))[class E extends a sealed trait A]] +compiling Set(D.scala) +D.scala:3: warning: match is not exhaustive! +missing combination E + + a match { + ^ +Changes: Map(object D -> List()) diff --git a/test/files/buildmanager/t2559/t2559.test b/test/files/buildmanager/t2559/t2559.test new file mode 100644 index 0000000000..b787c5b39f --- /dev/null +++ b/test/files/buildmanager/t2559/t2559.test @@ -0,0 +1,3 @@ +>>compile A.scala D.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2562/A.scala b/test/files/buildmanager/t2562/A.scala new file mode 100644 index 0000000000..2208585eed --- /dev/null +++ b/test/files/buildmanager/t2562/A.scala @@ -0,0 +1,7 @@ +object A +{ + def x0 = B.x0 + def x1 = B.x1 + def x2 = B.x2 + def x3 = 3 +} diff --git a/test/files/buildmanager/t2562/B.scala b/test/files/buildmanager/t2562/B.scala new file mode 100644 index 0000000000..6f658954e1 --- /dev/null +++ b/test/files/buildmanager/t2562/B.scala @@ -0,0 +1,8 @@ +object B +{ + def x0 = A.x1 + def x1 = A.x2 + def x2 = A.x3 +} + + diff --git a/test/files/buildmanager/t2562/t2562.changes/A2.scala b/test/files/buildmanager/t2562/t2562.changes/A2.scala new file mode 100644 index 0000000000..743609eb18 --- /dev/null +++ b/test/files/buildmanager/t2562/t2562.changes/A2.scala @@ -0,0 +1,8 @@ +object A +{ + def x0 = B.x0 + def x1 = B.x1 + def x2 = B.x2 + def x3 = "3" +} + diff --git a/test/files/buildmanager/t2562/t2562.check b/test/files/buildmanager/t2562/t2562.check new file mode 100644 index 0000000000..813d2735e1 --- /dev/null +++ b/test/files/buildmanager/t2562/t2562.check @@ -0,0 +1,12 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(object A -> List(Changed(Definition(A.x3))[method x3 changed from ()Int to ()java.lang.String flags: <method>])) +invalidate B.scala because it references changed definition [Changed(Definition(A.x3))[method x3 changed from ()Int to ()java.lang.String flags: <method>]] +compiling Set(B.scala) +Changes: Map(object B -> List(Changed(Definition(B.x2))[method x2 changed from ()Int to ()java.lang.String flags: <method>])) +invalidate A.scala because it references changed definition [Changed(Definition(B.x2))[method x2 changed from ()Int to ()java.lang.String flags: <method>]] +compiling Set(A.scala, B.scala) +Changes: Map(object A -> List(Changed(Definition(A.x0))[method x0 changed from ()Int to ()java.lang.String flags: <method>], Changed(Definition(A.x1))[method x1 changed from ()Int to ()java.lang.String flags: <method>], Changed(Definition(A.x2))[method x2 changed from ()Int to ()java.lang.String flags: <method>]), object B -> List(Changed(Definition(B.x0))[method x0 changed from ()Int to ()java.lang.String flags: <method>], Changed(Definition(B.x1))[method x1 changed from ()Int to ()java.lang.String flags: <method>])) diff --git a/test/files/buildmanager/t2562/t2562.test b/test/files/buildmanager/t2562/t2562.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2562/t2562.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2649/A.scala b/test/files/buildmanager/t2649/A.scala new file mode 100644 index 0000000000..86cc3f2c15 --- /dev/null +++ b/test/files/buildmanager/t2649/A.scala @@ -0,0 +1,3 @@ +object A { + def x(zz: Int, yy: Int) = yy - zz +} diff --git a/test/files/buildmanager/t2649/B.scala b/test/files/buildmanager/t2649/B.scala new file mode 100644 index 0000000000..26c89518cb --- /dev/null +++ b/test/files/buildmanager/t2649/B.scala @@ -0,0 +1,4 @@ +object B { + def main(args: Array[String]): Unit = + println( A.x(zz = 3, yy = 4) ) +} diff --git a/test/files/buildmanager/t2649/t2649.changes/A2.scala b/test/files/buildmanager/t2649/t2649.changes/A2.scala new file mode 100644 index 0000000000..9a6309fca3 --- /dev/null +++ b/test/files/buildmanager/t2649/t2649.changes/A2.scala @@ -0,0 +1,4 @@ +object A { + def x(yy: Int, zz: Int) = yy - zz +} + diff --git a/test/files/buildmanager/t2649/t2649.check b/test/files/buildmanager/t2649/t2649.check new file mode 100644 index 0000000000..5b698ec03f --- /dev/null +++ b/test/files/buildmanager/t2649/t2649.check @@ -0,0 +1,9 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(object A -> List(Changed(Definition(A.x))[method x changed from (zz: Int,yy: Int)Int to (yy: Int,zz: Int)Int flags: <method>])) +invalidate B.scala because it references changed definition [Changed(Definition(A.x))[method x changed from (zz: Int,yy: Int)Int to (yy: Int,zz: Int)Int flags: <method>]] +compiling Set(B.scala) +Changes: Map(object B -> List()) diff --git a/test/files/buildmanager/t2649/t2649.test b/test/files/buildmanager/t2649/t2649.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2649/t2649.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2650_1/A.scala b/test/files/buildmanager/t2650_1/A.scala new file mode 100644 index 0000000000..74714a3c47 --- /dev/null +++ b/test/files/buildmanager/t2650_1/A.scala @@ -0,0 +1,4 @@ +trait A { + type S[_] +} + diff --git a/test/files/buildmanager/t2650_1/B.scala b/test/files/buildmanager/t2650_1/B.scala new file mode 100644 index 0000000000..80f0e30259 --- /dev/null +++ b/test/files/buildmanager/t2650_1/B.scala @@ -0,0 +1,3 @@ +trait B extends A { + type F = S[Int] +} diff --git a/test/files/buildmanager/t2650_1/t2650_1.changes/A2.scala b/test/files/buildmanager/t2650_1/t2650_1.changes/A2.scala new file mode 100644 index 0000000000..2b8ead4ff1 --- /dev/null +++ b/test/files/buildmanager/t2650_1/t2650_1.changes/A2.scala @@ -0,0 +1,3 @@ +trait A { + type S +} diff --git a/test/files/buildmanager/t2650_1/t2650_1.check b/test/files/buildmanager/t2650_1/t2650_1.check new file mode 100644 index 0000000000..ecddb33620 --- /dev/null +++ b/test/files/buildmanager/t2650_1/t2650_1.check @@ -0,0 +1,11 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(trait A -> List(Changed(Definition(A.S))[type S changed from A.this.S[_] to A.this.S flags: <deferred>])) +invalidate B.scala because inherited method changed [Changed(Definition(A.S))[type S changed from A.this.S[_] to A.this.S flags: <deferred>]] +compiling Set(B.scala) +B.scala:2: error: B.this.S does not take type parameters + type F = S[Int] + ^ diff --git a/test/files/buildmanager/t2650_1/t2650_1.test b/test/files/buildmanager/t2650_1/t2650_1.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2650_1/t2650_1.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2650_2/A.scala b/test/files/buildmanager/t2650_2/A.scala new file mode 100644 index 0000000000..bcea634485 --- /dev/null +++ b/test/files/buildmanager/t2650_2/A.scala @@ -0,0 +1,3 @@ +trait A { + type S = Int +} diff --git a/test/files/buildmanager/t2650_2/B.scala b/test/files/buildmanager/t2650_2/B.scala new file mode 100644 index 0000000000..22a3a9a48e --- /dev/null +++ b/test/files/buildmanager/t2650_2/B.scala @@ -0,0 +1,4 @@ +trait B extends A { + def x: S + def y: Int = x +} diff --git a/test/files/buildmanager/t2650_2/t2650_2.changes/A2.scala b/test/files/buildmanager/t2650_2/t2650_2.changes/A2.scala new file mode 100644 index 0000000000..8274c1b62d --- /dev/null +++ b/test/files/buildmanager/t2650_2/t2650_2.changes/A2.scala @@ -0,0 +1,4 @@ +trait A { + type S = Long +} + diff --git a/test/files/buildmanager/t2650_2/t2650_2.check b/test/files/buildmanager/t2650_2/t2650_2.check new file mode 100644 index 0000000000..7ab72fb619 --- /dev/null +++ b/test/files/buildmanager/t2650_2/t2650_2.check @@ -0,0 +1,13 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(trait A -> List(Changed(Definition(A.S))[type S changed from A.this.S to A.this.S flags: ])) +invalidate B.scala because inherited method changed [Changed(Definition(A.S))[type S changed from A.this.S to A.this.S flags: ]] +compiling Set(B.scala) +B.scala:3: error: type mismatch; + found : B.this.S + required: Int + def y: Int = x + ^ diff --git a/test/files/buildmanager/t2650_2/t2650_2.test b/test/files/buildmanager/t2650_2/t2650_2.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2650_2/t2650_2.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2650_3/A.scala b/test/files/buildmanager/t2650_3/A.scala new file mode 100644 index 0000000000..cd13843eb9 --- /dev/null +++ b/test/files/buildmanager/t2650_3/A.scala @@ -0,0 +1,4 @@ +trait A { + type T = Int + def x: T +} diff --git a/test/files/buildmanager/t2650_3/B.scala b/test/files/buildmanager/t2650_3/B.scala new file mode 100644 index 0000000000..46a8cf270a --- /dev/null +++ b/test/files/buildmanager/t2650_3/B.scala @@ -0,0 +1,3 @@ +object B { + def x(a: A): Int = a.x +} diff --git a/test/files/buildmanager/t2650_3/t2650_3.changes/A2.scala b/test/files/buildmanager/t2650_3/t2650_3.changes/A2.scala new file mode 100644 index 0000000000..e5667b2539 --- /dev/null +++ b/test/files/buildmanager/t2650_3/t2650_3.changes/A2.scala @@ -0,0 +1,4 @@ +trait A { + type T = Long + def x: T +} diff --git a/test/files/buildmanager/t2650_3/t2650_3.check b/test/files/buildmanager/t2650_3/t2650_3.check new file mode 100644 index 0000000000..27be2f5ae8 --- /dev/null +++ b/test/files/buildmanager/t2650_3/t2650_3.check @@ -0,0 +1,13 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(trait A -> List(Changed(Definition(A.T))[type T changed from A.this.T to A.this.T flags: ])) +invalidate B.scala because it references changed definition [Changed(Definition(A.T))[type T changed from A.this.T to A.this.T flags: ]] +compiling Set(B.scala) +B.scala:2: error: type mismatch; + found : a.T + required: Int + def x(a: A): Int = a.x + ^ diff --git a/test/files/buildmanager/t2650_3/t2650_3.test b/test/files/buildmanager/t2650_3/t2650_3.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2650_3/t2650_3.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2650_4/A.scala b/test/files/buildmanager/t2650_4/A.scala new file mode 100644 index 0000000000..b9a519eb48 --- /dev/null +++ b/test/files/buildmanager/t2650_4/A.scala @@ -0,0 +1,5 @@ +trait A { + type T = Int + type T2 = T + def x: T2 +} diff --git a/test/files/buildmanager/t2650_4/B.scala b/test/files/buildmanager/t2650_4/B.scala new file mode 100644 index 0000000000..46a8cf270a --- /dev/null +++ b/test/files/buildmanager/t2650_4/B.scala @@ -0,0 +1,3 @@ +object B { + def x(a: A): Int = a.x +} diff --git a/test/files/buildmanager/t2650_4/t2650_4.changes/A2.scala b/test/files/buildmanager/t2650_4/t2650_4.changes/A2.scala new file mode 100644 index 0000000000..0220e7b7bc --- /dev/null +++ b/test/files/buildmanager/t2650_4/t2650_4.changes/A2.scala @@ -0,0 +1,5 @@ +trait A { + type T = Long + type T2 = T + def x: T2 +} diff --git a/test/files/buildmanager/t2650_4/t2650_4.check b/test/files/buildmanager/t2650_4/t2650_4.check new file mode 100644 index 0000000000..ba092d013f --- /dev/null +++ b/test/files/buildmanager/t2650_4/t2650_4.check @@ -0,0 +1,13 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(trait A -> List(Changed(Definition(A.T))[type T changed from A.this.T to A.this.T flags: ])) +invalidate B.scala because it references changed definition [Changed(Definition(A.T))[type T changed from A.this.T to A.this.T flags: ]] +compiling Set(B.scala) +B.scala:2: error: type mismatch; + found : a.T2 + required: Int + def x(a: A): Int = a.x + ^ diff --git a/test/files/buildmanager/t2650_4/t2650_4.test b/test/files/buildmanager/t2650_4/t2650_4.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2650_4/t2650_4.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2651_2/A.scala b/test/files/buildmanager/t2651_2/A.scala new file mode 100644 index 0000000000..d712f6febe --- /dev/null +++ b/test/files/buildmanager/t2651_2/A.scala @@ -0,0 +1 @@ +trait A[T] diff --git a/test/files/buildmanager/t2651_2/t2651_2.changes/A2.scala b/test/files/buildmanager/t2651_2/t2651_2.changes/A2.scala new file mode 100644 index 0000000000..7fb573e077 --- /dev/null +++ b/test/files/buildmanager/t2651_2/t2651_2.changes/A2.scala @@ -0,0 +1 @@ +trait A[S] diff --git a/test/files/buildmanager/t2651_2/t2651_2.check b/test/files/buildmanager/t2651_2/t2651_2.check new file mode 100644 index 0000000000..dd789b7565 --- /dev/null +++ b/test/files/buildmanager/t2651_2/t2651_2.check @@ -0,0 +1,6 @@ +builder > A.scala +compiling Set(A.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(trait A -> List()) diff --git a/test/files/buildmanager/t2651_2/t2651_2.test b/test/files/buildmanager/t2651_2/t2651_2.test new file mode 100644 index 0000000000..d0614473ce --- /dev/null +++ b/test/files/buildmanager/t2651_2/t2651_2.test @@ -0,0 +1,3 @@ +>>compile A.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2651_3/A.scala b/test/files/buildmanager/t2651_3/A.scala new file mode 100644 index 0000000000..14f9e4662f --- /dev/null +++ b/test/files/buildmanager/t2651_3/A.scala @@ -0,0 +1,3 @@ +trait A[T, S] { + def x: T +} diff --git a/test/files/buildmanager/t2651_3/t2651_3.changes/A2.scala b/test/files/buildmanager/t2651_3/t2651_3.changes/A2.scala new file mode 100644 index 0000000000..51bf27d1fa --- /dev/null +++ b/test/files/buildmanager/t2651_3/t2651_3.changes/A2.scala @@ -0,0 +1,3 @@ +trait A[T, S] { + def x: S +} diff --git a/test/files/buildmanager/t2651_3/t2651_3.check b/test/files/buildmanager/t2651_3/t2651_3.check new file mode 100644 index 0000000000..d4bac196e9 --- /dev/null +++ b/test/files/buildmanager/t2651_3/t2651_3.check @@ -0,0 +1,6 @@ +builder > A.scala +compiling Set(A.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(trait A -> List(Changed(Definition(A.x))[method x changed from ()T to ()S flags: <deferred> <method>])) diff --git a/test/files/buildmanager/t2651_3/t2651_3.test b/test/files/buildmanager/t2651_3/t2651_3.test new file mode 100644 index 0000000000..d0614473ce --- /dev/null +++ b/test/files/buildmanager/t2651_3/t2651_3.test @@ -0,0 +1,3 @@ +>>compile A.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2651_4/A.scala b/test/files/buildmanager/t2651_4/A.scala new file mode 100644 index 0000000000..63f2a1643e --- /dev/null +++ b/test/files/buildmanager/t2651_4/A.scala @@ -0,0 +1,5 @@ +trait A[T, S] { + def x: T + def y(a: T) + def z[B <: T] +} diff --git a/test/files/buildmanager/t2651_4/B.scala b/test/files/buildmanager/t2651_4/B.scala new file mode 100644 index 0000000000..b33dbde676 --- /dev/null +++ b/test/files/buildmanager/t2651_4/B.scala @@ -0,0 +1,3 @@ +trait B extends A[Int, String] { + def x = 3 +} diff --git a/test/files/buildmanager/t2651_4/t2651_4.changes/A2.scala b/test/files/buildmanager/t2651_4/t2651_4.changes/A2.scala new file mode 100644 index 0000000000..f155129d13 --- /dev/null +++ b/test/files/buildmanager/t2651_4/t2651_4.changes/A2.scala @@ -0,0 +1,5 @@ +trait A[S, T] { + def x: T + def y(a: T) + def z[B <: T] +} diff --git a/test/files/buildmanager/t2651_4/t2651_4.check b/test/files/buildmanager/t2651_4/t2651_4.check new file mode 100644 index 0000000000..c4ce382b5f --- /dev/null +++ b/test/files/buildmanager/t2651_4/t2651_4.check @@ -0,0 +1,13 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(trait A -> List(Changed(Definition(A.x))[method x changed from ()T to ()T flags: <deferred> <method>], Changed(Definition(A.y))[method y changed from (a: T)Unit to (a: T)Unit flags: <deferred> <method>], Changed(Definition(A.z))[method z changed from [B <: T]()Unit to [B <: T]()Unit flags: <deferred> <method>])) +invalidate B.scala because inherited method changed [Changed(Definition(A.x))[method x changed from ()T to ()T flags: <deferred> <method>]] +compiling Set(B.scala) +B.scala:2: error: type mismatch; + found : Int(3) + required: String + def x = 3 + ^ diff --git a/test/files/buildmanager/t2651_4/t2651_4.test b/test/files/buildmanager/t2651_4/t2651_4.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2651_4/t2651_4.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2652/A.scala b/test/files/buildmanager/t2652/A.scala new file mode 100644 index 0000000000..a62506e890 --- /dev/null +++ b/test/files/buildmanager/t2652/A.scala @@ -0,0 +1,3 @@ +class A { + def x[T](t: T) = t +} diff --git a/test/files/buildmanager/t2652/B.scala b/test/files/buildmanager/t2652/B.scala new file mode 100644 index 0000000000..86d08f0d3d --- /dev/null +++ b/test/files/buildmanager/t2652/B.scala @@ -0,0 +1,4 @@ +object B { + val y = (new A).x(3) +} + diff --git a/test/files/buildmanager/t2652/t2652.changes/A2.scala b/test/files/buildmanager/t2652/t2652.changes/A2.scala new file mode 100644 index 0000000000..29135c0e94 --- /dev/null +++ b/test/files/buildmanager/t2652/t2652.changes/A2.scala @@ -0,0 +1,4 @@ +class A { + def x[@specialized T](t: T) = t +} + diff --git a/test/files/buildmanager/t2652/t2652.check b/test/files/buildmanager/t2652/t2652.check new file mode 100644 index 0000000000..77a27a727f --- /dev/null +++ b/test/files/buildmanager/t2652/t2652.check @@ -0,0 +1,9 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(Changed(Definition(A.x))[method x changed from [T](t: T)T to [T](t: T)T flags: <method>])) +invalidate B.scala because it references changed definition [Changed(Definition(A.x))[method x changed from [T](t: T)T to [T](t: T)T flags: <method>]] +compiling Set(B.scala) +Changes: Map(object B -> List()) diff --git a/test/files/buildmanager/t2652/t2652.test b/test/files/buildmanager/t2652/t2652.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2652/t2652.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2653/A.scala b/test/files/buildmanager/t2653/A.scala new file mode 100644 index 0000000000..fb17a158c7 --- /dev/null +++ b/test/files/buildmanager/t2653/A.scala @@ -0,0 +1,2 @@ +class A[+T] + diff --git a/test/files/buildmanager/t2653/B.scala b/test/files/buildmanager/t2653/B.scala new file mode 100644 index 0000000000..8f55a88e05 --- /dev/null +++ b/test/files/buildmanager/t2653/B.scala @@ -0,0 +1,3 @@ +object B { + val a: A[Any] = new A[Int] +} diff --git a/test/files/buildmanager/t2653/t2653.changes/A2.scala b/test/files/buildmanager/t2653/t2653.changes/A2.scala new file mode 100644 index 0000000000..51d13cce6e --- /dev/null +++ b/test/files/buildmanager/t2653/t2653.changes/A2.scala @@ -0,0 +1,2 @@ +class A[T] + diff --git a/test/files/buildmanager/t2653/t2653.check b/test/files/buildmanager/t2653/t2653.check new file mode 100644 index 0000000000..0d40601962 --- /dev/null +++ b/test/files/buildmanager/t2653/t2653.check @@ -0,0 +1,13 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(Changed(Class(A))[ tparams: List((type T,type T))], Changed(Definition(A.<init>))[constructor A changed from ()A[T] to ()A[T] flags: <method>])) +invalidate B.scala because it references changed class [Changed(Class(A))[ tparams: List((type T,type T))]] +compiling Set(B.scala) +B.scala:2: error: type mismatch; + found : A[Int] + required: A[Any] + val a: A[Any] = new A[Int] + ^ diff --git a/test/files/buildmanager/t2653/t2653.test b/test/files/buildmanager/t2653/t2653.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2653/t2653.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2654/A.scala b/test/files/buildmanager/t2654/A.scala new file mode 100644 index 0000000000..75f396d039 --- /dev/null +++ b/test/files/buildmanager/t2654/A.scala @@ -0,0 +1,2 @@ +class A + diff --git a/test/files/buildmanager/t2654/B.scala b/test/files/buildmanager/t2654/B.scala new file mode 100644 index 0000000000..a18aec3dbe --- /dev/null +++ b/test/files/buildmanager/t2654/B.scala @@ -0,0 +1 @@ +class B extends A diff --git a/test/files/buildmanager/t2654/t2654.changes/A2.scala b/test/files/buildmanager/t2654/t2654.changes/A2.scala new file mode 100644 index 0000000000..c302edbd85 --- /dev/null +++ b/test/files/buildmanager/t2654/t2654.changes/A2.scala @@ -0,0 +1,4 @@ +class A { + private def x = 5 +} + diff --git a/test/files/buildmanager/t2654/t2654.check b/test/files/buildmanager/t2654/t2654.check new file mode 100644 index 0000000000..68f6e8efc0 --- /dev/null +++ b/test/files/buildmanager/t2654/t2654.check @@ -0,0 +1,6 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List()) diff --git a/test/files/buildmanager/t2654/t2654.test b/test/files/buildmanager/t2654/t2654.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2654/t2654.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2655/A.scala b/test/files/buildmanager/t2655/A.scala new file mode 100644 index 0000000000..b2c54ac47d --- /dev/null +++ b/test/files/buildmanager/t2655/A.scala @@ -0,0 +1,4 @@ +object A { + def x(i: => String) = () +} + diff --git a/test/files/buildmanager/t2655/B.scala b/test/files/buildmanager/t2655/B.scala new file mode 100644 index 0000000000..6c1918c0fb --- /dev/null +++ b/test/files/buildmanager/t2655/B.scala @@ -0,0 +1,3 @@ +object B { + val x = A.x("3") +} diff --git a/test/files/buildmanager/t2655/t2655.changes/A2.scala b/test/files/buildmanager/t2655/t2655.changes/A2.scala new file mode 100644 index 0000000000..0d6a7c69bb --- /dev/null +++ b/test/files/buildmanager/t2655/t2655.changes/A2.scala @@ -0,0 +1,4 @@ +object A { + def x(i: Function0[String]) = () +} + diff --git a/test/files/buildmanager/t2655/t2655.check b/test/files/buildmanager/t2655/t2655.check new file mode 100644 index 0000000000..a4a071ed70 --- /dev/null +++ b/test/files/buildmanager/t2655/t2655.check @@ -0,0 +1,13 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(object A -> List(Changed(Definition(A.x))[method x changed from (i: Function0)Unit to (i: Function0)Unit flags: <method>])) +invalidate B.scala because it references changed definition [Changed(Definition(A.x))[method x changed from (i: Function0)Unit to (i: Function0)Unit flags: <method>]] +compiling Set(B.scala) +B.scala:2: error: type mismatch; + found : java.lang.String("3") + required: () => String + val x = A.x("3") + ^ diff --git a/test/files/buildmanager/t2655/t2655.test b/test/files/buildmanager/t2655/t2655.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2655/t2655.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2657/A.scala b/test/files/buildmanager/t2657/A.scala new file mode 100644 index 0000000000..2a6c62d29c --- /dev/null +++ b/test/files/buildmanager/t2657/A.scala @@ -0,0 +1,3 @@ +class A { + implicit def y(i: Int): String = i.toString +} diff --git a/test/files/buildmanager/t2657/B.scala b/test/files/buildmanager/t2657/B.scala new file mode 100644 index 0000000000..77869890db --- /dev/null +++ b/test/files/buildmanager/t2657/B.scala @@ -0,0 +1,4 @@ +object B extends A { + val x: String = 3 +} + diff --git a/test/files/buildmanager/t2657/t2657.changes/A2.scala b/test/files/buildmanager/t2657/t2657.changes/A2.scala new file mode 100644 index 0000000000..7dc99d425e --- /dev/null +++ b/test/files/buildmanager/t2657/t2657.changes/A2.scala @@ -0,0 +1,3 @@ +class A { + def y(i: Int): String = i.toString +} diff --git a/test/files/buildmanager/t2657/t2657.check b/test/files/buildmanager/t2657/t2657.check new file mode 100644 index 0000000000..9713f66024 --- /dev/null +++ b/test/files/buildmanager/t2657/t2657.check @@ -0,0 +1,13 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(Changed(Definition(A.y))[method y changed from (i: Int)java.lang.String to (i: Int)java.lang.String flags: implicit <method>])) +invalidate B.scala because inherited method changed [Changed(Definition(A.y))[method y changed from (i: Int)java.lang.String to (i: Int)java.lang.String flags: implicit <method>]] +compiling Set(B.scala) +B.scala:2: error: type mismatch; + found : Int(3) + required: String + val x: String = 3 + ^ diff --git a/test/files/buildmanager/t2657/t2657.test b/test/files/buildmanager/t2657/t2657.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2657/t2657.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2789/A.scala b/test/files/buildmanager/t2789/A.scala new file mode 100644 index 0000000000..08d5bc840c --- /dev/null +++ b/test/files/buildmanager/t2789/A.scala @@ -0,0 +1,5 @@ +class A { + implicit def e: E = new E + def x(i: Int)(implicit y: E): String = "" +} +class E diff --git a/test/files/buildmanager/t2789/B.scala b/test/files/buildmanager/t2789/B.scala new file mode 100644 index 0000000000..dcefbeec1b --- /dev/null +++ b/test/files/buildmanager/t2789/B.scala @@ -0,0 +1,3 @@ +object B extends A { + val y = x(3) +} diff --git a/test/files/buildmanager/t2789/t2789.changes/A2.scala b/test/files/buildmanager/t2789/t2789.changes/A2.scala new file mode 100644 index 0000000000..4ba3814e71 --- /dev/null +++ b/test/files/buildmanager/t2789/t2789.changes/A2.scala @@ -0,0 +1,5 @@ +class A { + def e: E = new E + def x(i: Int)(implicit y: E): String = "" +} +class E diff --git a/test/files/buildmanager/t2789/t2789.check b/test/files/buildmanager/t2789/t2789.check new file mode 100644 index 0000000000..78c5119355 --- /dev/null +++ b/test/files/buildmanager/t2789/t2789.check @@ -0,0 +1,11 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(class A -> List(Changed(Definition(A.e))[method e changed from ()E to ()E flags: implicit <method>]), class E -> List()) +invalidate B.scala because inherited method changed [Changed(Definition(A.e))[method e changed from ()E to ()E flags: implicit <method>]] +compiling Set(B.scala) +B.scala:2: error: could not find implicit value for parameter y: E + val y = x(3) + ^ diff --git a/test/files/buildmanager/t2789/t2789.test b/test/files/buildmanager/t2789/t2789.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2789/t2789.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t2790/A.scala b/test/files/buildmanager/t2790/A.scala new file mode 100644 index 0000000000..6e9c1a90db --- /dev/null +++ b/test/files/buildmanager/t2790/A.scala @@ -0,0 +1,5 @@ +object A { + def x(f: String, g: Int): Int = g + def x(f: Int, g: Int = 3): Int = g +} + diff --git a/test/files/buildmanager/t2790/B.scala b/test/files/buildmanager/t2790/B.scala new file mode 100644 index 0000000000..441055ca12 --- /dev/null +++ b/test/files/buildmanager/t2790/B.scala @@ -0,0 +1,4 @@ +object B { + val y = A.x(5) +} + diff --git a/test/files/buildmanager/t2790/t2790.changes/A2.scala b/test/files/buildmanager/t2790/t2790.changes/A2.scala new file mode 100644 index 0000000000..704ef4e96e --- /dev/null +++ b/test/files/buildmanager/t2790/t2790.changes/A2.scala @@ -0,0 +1,4 @@ +object A { + def x(f: String, g: Int = 3): Int = g + def x(f: Int, g: Int): Int = g +} diff --git a/test/files/buildmanager/t2790/t2790.check b/test/files/buildmanager/t2790/t2790.check new file mode 100644 index 0000000000..065956765a --- /dev/null +++ b/test/files/buildmanager/t2790/t2790.check @@ -0,0 +1,14 @@ +builder > A.scala B.scala +compiling Set(A.scala, B.scala) +Changes: Map() +builder > A.scala +compiling Set(A.scala) +Changes: Map(object A -> List(Added(Definition(A.x)), Changed(Definition(A.x))[value x changed from (f: java.lang.String,g: Int)Int to (f: java.lang.String,g: Int)Int <and> (f: Int,g: Int)Int flags: <method>])) +invalidate B.scala because it references changed definition [Changed(Definition(A.x))[value x changed from (f: java.lang.String,g: Int)Int to (f: java.lang.String,g: Int)Int <and> (f: Int,g: Int)Int flags: <method>]] +compiling Set(B.scala) +B.scala:2: error: type mismatch; + found : Int(5) + required: String +Error occured in an application involving default arguments. + val y = A.x(5) + ^ diff --git a/test/files/buildmanager/t2790/t2790.test b/test/files/buildmanager/t2790/t2790.test new file mode 100644 index 0000000000..6f3bd03361 --- /dev/null +++ b/test/files/buildmanager/t2790/t2790.test @@ -0,0 +1,3 @@ +>>compile A.scala B.scala +>>update A.scala=>A2.scala +>>compile A.scala diff --git a/test/files/buildmanager/t3045/A.java b/test/files/buildmanager/t3045/A.java new file mode 100644 index 0000000000..d1acb00cd6 --- /dev/null +++ b/test/files/buildmanager/t3045/A.java @@ -0,0 +1,7 @@ +public interface A { + public class C implements A {} +} + +class B { + static class C {} +} diff --git a/test/files/buildmanager/t3045/t3045.check b/test/files/buildmanager/t3045/t3045.check new file mode 100644 index 0000000000..5e4e71e045 --- /dev/null +++ b/test/files/buildmanager/t3045/t3045.check @@ -0,0 +1,3 @@ +builder > A.java +compiling Set(A.java) +Changes: Map() diff --git a/test/files/buildmanager/t3045/t3045.test b/test/files/buildmanager/t3045/t3045.test new file mode 100644 index 0000000000..6cf7e35543 --- /dev/null +++ b/test/files/buildmanager/t3045/t3045.test @@ -0,0 +1 @@ +>>compile A.java diff --git a/test/files/buildmanager/t3054/bar/Bar.java b/test/files/buildmanager/t3054/bar/Bar.java new file mode 100644 index 0000000000..e1b056d4e5 --- /dev/null +++ b/test/files/buildmanager/t3054/bar/Bar.java @@ -0,0 +1,7 @@ +package bar; +import foo.Foo$; + + +public class Bar { + void bar() { Foo$.MODULE$.foo(); } +} diff --git a/test/files/buildmanager/t3054/foo/Foo.scala b/test/files/buildmanager/t3054/foo/Foo.scala new file mode 100644 index 0000000000..c4838b9958 --- /dev/null +++ b/test/files/buildmanager/t3054/foo/Foo.scala @@ -0,0 +1,5 @@ +package foo + +class Foo { + def foo = println("foo") +} diff --git a/test/files/buildmanager/t3054/t3054.check b/test/files/buildmanager/t3054/t3054.check new file mode 100644 index 0000000000..97cca8862e --- /dev/null +++ b/test/files/buildmanager/t3054/t3054.check @@ -0,0 +1,3 @@ +builder > bar/Bar.java foo/Foo.scala +compiling Set(bar/Bar.java, foo/Foo.scala) +Changes: Map() diff --git a/test/files/buildmanager/t3054/t3054.test b/test/files/buildmanager/t3054/t3054.test new file mode 100644 index 0000000000..903df24b13 --- /dev/null +++ b/test/files/buildmanager/t3054/t3054.test @@ -0,0 +1 @@ +>>compile bar/Bar.java foo/Foo.scala diff --git a/test/files/buildmanager/t3133/A.java b/test/files/buildmanager/t3133/A.java new file mode 100644 index 0000000000..9cf4d96bd4 --- /dev/null +++ b/test/files/buildmanager/t3133/A.java @@ -0,0 +1,7 @@ +public class A { + class Foo {} + + public A(Foo a) {} + + private void bar(Foo z) {} +} diff --git a/test/files/buildmanager/t3133/t3133.check b/test/files/buildmanager/t3133/t3133.check new file mode 100644 index 0000000000..5e4e71e045 --- /dev/null +++ b/test/files/buildmanager/t3133/t3133.check @@ -0,0 +1,3 @@ +builder > A.java +compiling Set(A.java) +Changes: Map() diff --git a/test/files/buildmanager/t3133/t3133.test b/test/files/buildmanager/t3133/t3133.test new file mode 100644 index 0000000000..6cf7e35543 --- /dev/null +++ b/test/files/buildmanager/t3133/t3133.test @@ -0,0 +1 @@ +>>compile A.java diff --git a/test/files/files.iml b/test/files/files.iml deleted file mode 100644 index ac78e33f39..0000000000 --- a/test/files/files.iml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module relativePaths="true" type="JAVA_MODULE" version="4"> - <component name="FacetManager"> - <facet type="Scala" name="Scala"> - <configuration /> - </facet> - </component> - <component name="NewModuleRootManager" inherit-compiler-output="true"> - <exclude-output /> - <content url="file://$MODULE_DIR$" /> - <orderEntry type="library" name="lib1" level="project" /> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" name="lib" level="project" /> - </component> -</module> - diff --git a/test/files/jvm/actor-exceptions.check b/test/files/jvm/actor-exceptions.check index 021ccea1f1..bd44b968cc 100644 --- a/test/files/jvm/actor-exceptions.check +++ b/test/files/jvm/actor-exceptions.check @@ -1,11 +1,3 @@ -problem -received A -problem -received A -problem -received A -problem -received A -problem -received last A -slave exited because of java.lang.Exception: unhandled +Uncaught exception in Slave +Message: A +MyOtherException diff --git a/test/files/jvm/actor-exceptions.scala b/test/files/jvm/actor-exceptions.scala index ccec84c56c..77bf05c048 100644 --- a/test/files/jvm/actor-exceptions.scala +++ b/test/files/jvm/actor-exceptions.scala @@ -2,7 +2,13 @@ import scala.actors.{Actor, Exit} import Actor._ -case class MyException(text: String) extends Exception +case class MyException(text: String) extends Exception { + override def fillInStackTrace() = this +} + +case class MyOtherException(text: String) extends Exception { + override def fillInStackTrace() = this +} object Master extends Actor { trapExit = true @@ -11,14 +17,15 @@ object Master extends Actor { Slave.start() for (i <- 0 until 10) Slave ! A react { - case Exit(from, reason) => println("slave exited because of "+reason) + case Exit(from, reason) => } } } object Slave extends Actor { + override def toString = "Slave" override def exceptionHandler: PartialFunction[Exception, Unit] = { - case MyException(text) => println(text) + case MyException(text) => } def act() { var cnt = 0 @@ -27,11 +34,8 @@ object Slave extends Actor { case A => cnt += 1 if (cnt % 2 != 0) throw MyException("problem") - if (cnt < 10) - println("received A") - else { - println("received last A") - throw new Exception("unhandled") + if (cnt == 10) { + throw new MyOtherException("unhandled") } } } diff --git a/test/files/jvm/actor-executor.check b/test/files/jvm/actor-executor.check new file mode 100644 index 0000000000..bdbdb5c6a2 --- /dev/null +++ b/test/files/jvm/actor-executor.check @@ -0,0 +1,20 @@ +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK diff --git a/test/files/jvm/actor-executor.scala b/test/files/jvm/actor-executor.scala new file mode 100644 index 0000000000..435c666fff --- /dev/null +++ b/test/files/jvm/actor-executor.scala @@ -0,0 +1,65 @@ +import java.util.concurrent.Executors +import scala.actors.{Actor, SchedulerAdapter} +import Actor._ + +trait AdaptedActor extends Actor { + override def scheduler = + Test.scheduler +} + +object One extends AdaptedActor { + def act() { + Two.start() + var i = 0 + loopWhile (i < 10000) { + i += 1 + Two ! 'MsgForTwo + react { + case 'MsgForOne => + if (i % 1000 == 0) + println("One: OK") + if (i == 10000) + Test.executor.shutdown() + } + } + } +} + +object Two extends AdaptedActor { + def act() { + var i = 0 + loopWhile (i < 10000) { + i += 1 + react { + case 'MsgForTwo => + if (i % 1000 == 0) + println("Two: OK") + One ! 'MsgForOne + } + } + } +} + +object Test { + val executor = + Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) + + val scheduler = + new SchedulerAdapter { + def execute(block: => Unit) { + val task = new Runnable { + def run() { block } + } + try { + executor.execute(task) + } catch { + case ree: java.util.concurrent.RejectedExecutionException => + task.run() + } + } + } + + def main(args: Array[String]) { + One.start() + } +} diff --git a/test/files/jvm/actor-executor2.check b/test/files/jvm/actor-executor2.check new file mode 100644 index 0000000000..da78f45836 --- /dev/null +++ b/test/files/jvm/actor-executor2.check @@ -0,0 +1,21 @@ +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +One exited diff --git a/test/files/jvm/actor-executor2.scala b/test/files/jvm/actor-executor2.scala new file mode 100644 index 0000000000..9e99e167aa --- /dev/null +++ b/test/files/jvm/actor-executor2.scala @@ -0,0 +1,67 @@ +import scala.actors.{Actor, SchedulerAdapter, Exit} +import Actor._ +import java.util.concurrent.Executors + +object One extends AdaptedActor { + def act() { + Two.start() + var i = 0 + loopWhile (i < Test.NUM_MSG) { + i += 1 + Two ! 'MsgForTwo + react { + case 'MsgForOne => + if (i % (Test.NUM_MSG/10) == 0) + println("One: OK") + } + } + } +} + +object Two extends AdaptedActor { + def act() { + var i = 0 + loopWhile (i < Test.NUM_MSG) { + i += 1 + react { + case 'MsgForTwo => + if (i % (Test.NUM_MSG/10) == 0) + println("Two: OK") + One ! 'MsgForOne + } + } + } +} + +trait AdaptedActor extends Actor { + override def scheduler = + Test.scheduler +} + +object Test { + val NUM_MSG = 100000 + + val executor = + Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) + + val scheduler = + new SchedulerAdapter { + def execute(block: => Unit) { + executor.execute(new Runnable { + def run() { block } + }) + } + } + + def main(args: Array[String]) { + self.trapExit = true + link(One) + One.start() + + receive { + case Exit(from, reason) => + println("One exited") + Test.executor.shutdown() + } + } +} diff --git a/test/files/jvm/actor-executor3.check b/test/files/jvm/actor-executor3.check new file mode 100644 index 0000000000..bdbdb5c6a2 --- /dev/null +++ b/test/files/jvm/actor-executor3.check @@ -0,0 +1,20 @@ +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK diff --git a/test/files/jvm/actor-executor3.scala b/test/files/jvm/actor-executor3.scala new file mode 100644 index 0000000000..bf060b8ac5 --- /dev/null +++ b/test/files/jvm/actor-executor3.scala @@ -0,0 +1,52 @@ +import scala.actors.Actor +import scala.actors.scheduler.ExecutorScheduler +import java.util.concurrent.Executors + +object One extends AdaptedActor { + def act() { + Two.start() + var i = 0 + loopWhile (i < Test.NUM_MSG) { + i += 1 + Two ! 'MsgForTwo + react { + case 'MsgForOne => + if (i % (Test.NUM_MSG/10) == 0) + println("One: OK") + } + } + } +} + +object Two extends AdaptedActor { + def act() { + var i = 0 + loopWhile (i < Test.NUM_MSG) { + i += 1 + react { + case 'MsgForTwo => + if (i % (Test.NUM_MSG/10) == 0) + println("Two: OK") + One ! 'MsgForOne + } + } + } +} + +trait AdaptedActor extends Actor { + override def scheduler = + Test.scheduler +} + +object Test { + val NUM_MSG = 100000 + + val executor = + Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) + + val scheduler = ExecutorScheduler(executor) + + def main(args: Array[String]) { + One.start() + } +} diff --git a/test/files/jvm/actor-getstate.check b/test/files/jvm/actor-getstate.check new file mode 100644 index 0000000000..2c94e48371 --- /dev/null +++ b/test/files/jvm/actor-getstate.check @@ -0,0 +1,2 @@ +OK +OK diff --git a/test/files/jvm/actor-getstate.scala b/test/files/jvm/actor-getstate.scala new file mode 100644 index 0000000000..a6e15a8721 --- /dev/null +++ b/test/files/jvm/actor-getstate.scala @@ -0,0 +1,85 @@ +import scala.actors.{Reactor, Actor, TIMEOUT} +import Actor._ + +object Test { + + def assert(cond: => Boolean, hint: String) { + if (!cond) + println("FAIL ["+hint+"]") + } + + def expectActorState(a: Reactor[T] forSome { type T }, s: Actor.State.Value) { + var done = false + var i = 0 + while (!done) { + i = i + 1 + if (i == 10) { // only wait for 2 seconds total + println("FAIL ["+a+": expected "+s+"]") + done = true + } + + Thread.sleep(200) + if (a.getState == s) // success + done = true + } + } + + def main(args: Array[String]) { + actor { + val a = new Reactor[Any] { + def act() { + assert(getState == Actor.State.Runnable, "runnable1") + react { + case 'go => + println("OK") + } + } + } + expectActorState(a, Actor.State.New) + + a.start() + expectActorState(a, Actor.State.Suspended) + + a ! 'go + expectActorState(a, Actor.State.Terminated) + + val b = new Actor { + def act() { + assert(getState == Actor.State.Runnable, "runnable2: "+getState) + react { + case 'go => + reactWithin(100000) { + case TIMEOUT => + case 'go => + receive { + case 'go => + } + receiveWithin(100000) { + case TIMEOUT => + case 'go => + println("OK") + } + } + } + } + } + expectActorState(b, Actor.State.New) + + b.start() + expectActorState(b, Actor.State.Suspended) + + b ! 'go + expectActorState(b, Actor.State.TimedSuspended) + + b ! 'go + expectActorState(b, Actor.State.Blocked) + + b ! 'go + expectActorState(b, Actor.State.TimedBlocked) + + b ! 'go + expectActorState(b, Actor.State.Terminated) + } + } + +} diff --git a/test/files/jvm/actor-link-getstate.check b/test/files/jvm/actor-link-getstate.check new file mode 100644 index 0000000000..45967222e6 --- /dev/null +++ b/test/files/jvm/actor-link-getstate.check @@ -0,0 +1,5 @@ +Done +Uncaught exception in Master +Message: 'done +MyException: Master crashed +Terminated diff --git a/test/files/jvm/actor-link-getstate.scala b/test/files/jvm/actor-link-getstate.scala new file mode 100644 index 0000000000..ec01757883 --- /dev/null +++ b/test/files/jvm/actor-link-getstate.scala @@ -0,0 +1,47 @@ +import scala.actors.{Actor, Exit} +import scala.actors.Actor._ + +case class MyException(text: String) extends Exception(text) { + override def fillInStackTrace() = this +} + +object Slave extends Actor { + def act() { + loop { + react { + case 'doWork => + Console.err.println("Done") + reply('done) + } + } + } +} + +object Master extends Actor { + override def toString = "Master" + def act() { + link(Slave) + Slave ! 'doWork + react { + case 'done => + throw new MyException("Master crashed") + } + } +} + +object Test { + + def main(args: Array[String]) { + actor { + self.trapExit = true + link(Slave) + Slave.start() + Master.start() + react { + case Exit(from, reason) if (from == Slave) => + Console.err.println(Slave.getState) + } + } + } + +} diff --git a/test/files/jvm/actor-receivewithin.scala b/test/files/jvm/actor-receivewithin.scala index c6818cf211..a5c87c2722 100644 --- a/test/files/jvm/actor-receivewithin.scala +++ b/test/files/jvm/actor-receivewithin.scala @@ -29,6 +29,7 @@ object A extends Actor { } } B ! 'next + receive { case 'done => } cnt = 0 while (cnt < 501) { cnt += 1 @@ -56,6 +57,7 @@ object B extends Actor { for (_ <- 1 to 500) { A ! 'msg2 } + A ! 'done } } } diff --git a/test/files/jvm/actor-uncaught-exception.check b/test/files/jvm/actor-uncaught-exception.check new file mode 100644 index 0000000000..3e669779df --- /dev/null +++ b/test/files/jvm/actor-uncaught-exception.check @@ -0,0 +1,5 @@ +Uncaught exception in StartError +MyException: I don't want to run! +Uncaught exception in MessageError +Message: 'ping +MyException: No message for me! diff --git a/test/files/jvm/actor-uncaught-exception.scala b/test/files/jvm/actor-uncaught-exception.scala new file mode 100644 index 0000000000..9f64be26e1 --- /dev/null +++ b/test/files/jvm/actor-uncaught-exception.scala @@ -0,0 +1,46 @@ +import scala.actors.{Actor, Exit} + +class MyException(msg: String) extends Exception(msg) { + override def fillInStackTrace() = this +} + +object Test { + + case object StartError extends Actor { + def act() { + throw new MyException("I don't want to run!") + } + } + + case object MessageError extends Actor { + def act() { + react { + case _ => throw new MyException("No message for me!") + } + } + } + + case object Supervisor extends Actor { + def act() { + trapExit = true + link(StartError) + link(MessageError) + StartError.start() + MessageError.start() + + Actor.loop { + react { + case Exit(actor, reason) => + if (actor == StartError) + MessageError ! 'ping + else + exit() + } + } + } + } + + def main(args: Array[String]) { + Supervisor.start() + } +} diff --git a/test/files/jvm/deprecation.cmds b/test/files/jvm/deprecation.cmds new file mode 100644 index 0000000000..4c0f73c58b --- /dev/null +++ b/test/files/jvm/deprecation.cmds @@ -0,0 +1,3 @@ +javac Defs.java +scalac Test_1.scala +javac Use_2.java diff --git a/test/files/jvm/future-alarm.check b/test/files/jvm/future-alarm.check new file mode 100644 index 0000000000..01a87d1c4c --- /dev/null +++ b/test/files/jvm/future-alarm.check @@ -0,0 +1,20 @@ +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK +OK diff --git a/test/files/jvm/future-alarm.scala b/test/files/jvm/future-alarm.scala new file mode 100644 index 0000000000..0dda492741 --- /dev/null +++ b/test/files/jvm/future-alarm.scala @@ -0,0 +1,16 @@ +import scala.actors.Futures + +object Test { + def main(args: Array[String]) { + for (i <- 1 to 100000) { + Futures.alarm(0) + if (i % 10000 == 0) + println("OK") + } + for (_ <- 1 to 10) { + val ft = Futures.alarm(100) + ft() + println("OK") + } + } +} diff --git a/test/files/lib/genericNest.jar.desired.sha1 b/test/files/jvm/genericNest/genericNest.jar.desired.sha1 index e9321262f2..e9321262f2 100644 --- a/test/files/lib/genericNest.jar.desired.sha1 +++ b/test/files/jvm/genericNest/genericNest.jar.desired.sha1 diff --git a/test/files/jvm/genericNest.scala b/test/files/jvm/genericNest/genericNest.scala index c1b0210117..c1b0210117 100644 --- a/test/files/jvm/genericNest.scala +++ b/test/files/jvm/genericNest/genericNest.scala diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala index 51e3909ef3..d0d2226de6 100644 --- a/test/files/jvm/inner.scala +++ b/test/files/jvm/inner.scala @@ -53,8 +53,8 @@ class A { } object Scalatest { - private val outputdir = System.getProperty("scalatest.output", "inner-jvm.obj") - private val scalalib = System.getProperty("scalatest.lib", "") + private val outputdir = System.getProperty("partest.output", "inner.obj") + private val scalalib = System.getProperty("partest.lib", "") private val classpath = outputdir + File.pathSeparator + scalalib private val javabin = { val jhome = new File(System.getProperty("java.home")) diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index 6c89318470..b74ba1be0a 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -19,7 +19,7 @@ scala> defined type alias anotherint scala> four: anotherint = 4 -scala> <console>:5: error: type mismatch; +scala> <console>:6: error: type mismatch; found : java.lang.String("hello") required: anotherint val bogus: anotherint = "hello" @@ -169,7 +169,7 @@ scala> res4: Array[_] = Array(2) scala> res5: Array[java.lang.String] = Array(abc, abc) -scala> res6: scala.collection.mutable.GenericArray[_] = GenericArray(1, 2) +scala> res6: scala.collection.mutable.ArraySeq[_] = ArraySeq(1, 2) scala> res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2)) @@ -217,9 +217,9 @@ scala> defined class Exp defined class Fact defined class Term -scala> | | <console>:15: warning: match is not exhaustive! -missing combination Term +scala> | | <console>:16: warning: match is not exhaustive! missing combination Exp +missing combination Term def f(e: Exp) = e match { // non-exhaustive warning here ^ @@ -229,7 +229,7 @@ scala> scala> plusOne: (x: Int)Int res0: Int = 6 -res0: java.lang.String = after reset -<console>:5: error: not found: value plusOne +res1: java.lang.String = after reset +<console>:6: error: not found: value plusOne plusOne(5) // should be undefined now ^ diff --git a/test/files/lib/annotations.jar.desired.sha1 b/test/files/jvm/lib/annotations.jar.desired.sha1 index 2b4292d796..2b4292d796 100644 --- a/test/files/lib/annotations.jar.desired.sha1 +++ b/test/files/jvm/lib/annotations.jar.desired.sha1 diff --git a/test/files/lib/nest.jar.desired.sha1 b/test/files/jvm/lib/nest.jar.desired.sha1 index 674ca79a5b..674ca79a5b 100644 --- a/test/files/lib/nest.jar.desired.sha1 +++ b/test/files/jvm/lib/nest.jar.desired.sha1 diff --git a/test/files/lib/methvsfield.jar.desired.sha1 b/test/files/jvm/methvsfield/methvsfield.jar.desired.sha1 index 8c01532b88..8c01532b88 100644 --- a/test/files/lib/methvsfield.jar.desired.sha1 +++ b/test/files/jvm/methvsfield/methvsfield.jar.desired.sha1 diff --git a/test/files/jvm/methvsfield.java b/test/files/jvm/methvsfield/methvsfield.java index dadc98669a..dadc98669a 100644 --- a/test/files/jvm/methvsfield.java +++ b/test/files/jvm/methvsfield/methvsfield.java diff --git a/test/files/jvm/methvsfield.scala b/test/files/jvm/methvsfield/methvsfield.scala index e9795ec6a8..e9795ec6a8 100644 --- a/test/files/jvm/methvsfield.scala +++ b/test/files/jvm/methvsfield/methvsfield.scala diff --git a/test/files/jvm/nest.java b/test/files/jvm/nest/nest.java index 3f6f0bebbd..3f6f0bebbd 100644 --- a/test/files/jvm/nest.java +++ b/test/files/jvm/nest/nest.java diff --git a/test/files/jvm/nest.scala b/test/files/jvm/nest/nest.scala index 3ab62484fa..3ab62484fa 100644 --- a/test/files/jvm/nest.scala +++ b/test/files/jvm/nest/nest.scala diff --git a/test/files/lib/enums.jar.desired.sha1 b/test/files/jvm/outerEnum/enums.jar.desired.sha1 index 46cd8e92cf..46cd8e92cf 100644 --- a/test/files/lib/enums.jar.desired.sha1 +++ b/test/files/jvm/outerEnum/enums.jar.desired.sha1 diff --git a/test/files/jvm/outerEnum.scala b/test/files/jvm/outerEnum/outerEnum.scala index 18794b7dbe..18794b7dbe 100644 --- a/test/files/jvm/outerEnum.scala +++ b/test/files/jvm/outerEnum/outerEnum.scala diff --git a/test/files/jvm/reactor-exceptionOnSend.scala b/test/files/jvm/reactor-exceptionOnSend.scala index 3684943b9b..c89aab334b 100644 --- a/test/files/jvm/reactor-exceptionOnSend.scala +++ b/test/files/jvm/reactor-exceptionOnSend.scala @@ -3,7 +3,7 @@ import scala.actors.Actor._ case class MyException(text: String) extends Exception(text) -object A extends Reactor { +object A extends Reactor[Any] { override def exceptionHandler = { case MyException(text) => println("receiver handles exception") @@ -29,7 +29,7 @@ object A extends Reactor { } } -object B extends Reactor { +object B extends Reactor[Any] { def act() { A.start() A ! 'hello diff --git a/test/files/jvm/reactor-producer-consumer.scala b/test/files/jvm/reactor-producer-consumer.scala index 946e1561ce..0d33043fc6 100644 --- a/test/files/jvm/reactor-producer-consumer.scala +++ b/test/files/jvm/reactor-producer-consumer.scala @@ -2,10 +2,10 @@ import scala.actors.Reactor object Test { case class Stop() - case class Get(from: Reactor) + case class Get(from: Reactor[Any]) case class Put(x: Int) - class UnboundedBuffer extends Reactor { + class UnboundedBuffer extends Reactor[Any] { def act() { react { case Stop() => @@ -20,7 +20,7 @@ object Test { } } - class Producer(buf: UnboundedBuffer, n: Int, delay: Long, parent: Reactor) extends Reactor { + class Producer(buf: UnboundedBuffer, n: Int, delay: Long, parent: Reactor[Any]) extends Reactor[Any] { def act() { var i = 0 while (i < n) { @@ -32,7 +32,7 @@ object Test { } } - class Consumer(buf: UnboundedBuffer, n: Int, delay: Long, parent: Reactor) extends Reactor { + class Consumer(buf: UnboundedBuffer, n: Int, delay: Long, parent: Reactor[Any]) extends Reactor[Any] { val step = n / 10 var i = 0 def act() { @@ -53,7 +53,7 @@ object Test { } def main(args: Array[String]) { - val parent = new Reactor { + val parent = new Reactor[Any] { def act() { val buffer = new UnboundedBuffer buffer.start() diff --git a/test/files/jvm/reactor.scala b/test/files/jvm/reactor.scala index 8985f90569..12d5c7c221 100644 --- a/test/files/jvm/reactor.scala +++ b/test/files/jvm/reactor.scala @@ -1,13 +1,12 @@ import scala.actors.Reactor -import scala.actors.Actor._ -case class Ping(from: Reactor) +case class Ping(from: Reactor[Any]) case object Pong case object Stop /** - * Ping pong example for OutputChannelActor. + * Ping pong example for Reactor. * * @author Philipp Haller */ @@ -20,7 +19,7 @@ object Test { } } -class PingActor(count: Int, pong: Reactor) extends Reactor { +class PingActor(count: Int, pong: Reactor[Any]) extends Reactor[Any] { def act() { var pingsLeft = count - 1 pong ! Ping(this) @@ -42,7 +41,7 @@ class PingActor(count: Int, pong: Reactor) extends Reactor { } } -class PongActor extends Reactor { +class PongActor extends Reactor[Any] { def act() { var pongCount = 0 loop { diff --git a/test/files/jvm/replyablereactor.scala b/test/files/jvm/replyablereactor.scala index 368d172e3f..896a0bf440 100644 --- a/test/files/jvm/replyablereactor.scala +++ b/test/files/jvm/replyablereactor.scala @@ -1,5 +1,4 @@ -import scala.actors._ -import scala.actors.Actor._ +import scala.actors.ReplyReactor class MyActor extends ReplyReactor { def act() { @@ -19,7 +18,7 @@ object Test { val a = new MyActor a.start() - val b = new Reactor { + val b = new ReplyReactor { def act() { react { case r: MyActor => diff --git a/test/files/jvm/replyablereactor2.scala b/test/files/jvm/replyablereactor2.scala index 22622274dd..57b7cfe201 100644 --- a/test/files/jvm/replyablereactor2.scala +++ b/test/files/jvm/replyablereactor2.scala @@ -19,7 +19,7 @@ object Test { val a = new MyActor a.start() - val b = new Reactor { + val b = new Reactor[Any] { def act() { react { case r: MyActor => diff --git a/test/files/jvm/replyablereactor3.scala b/test/files/jvm/replyablereactor3.scala index 676ffe98e6..b33db811e2 100644 --- a/test/files/jvm/replyablereactor3.scala +++ b/test/files/jvm/replyablereactor3.scala @@ -19,7 +19,7 @@ object Test { val a = new MyActor a.start() - val b = new Reactor { + val b = new Reactor[Any] { def act() { react { case r: MyActor => diff --git a/test/files/jvm/replyablereactor4.scala b/test/files/jvm/replyablereactor4.scala index d61fb64287..dc24f5e88d 100644 --- a/test/files/jvm/replyablereactor4.scala +++ b/test/files/jvm/replyablereactor4.scala @@ -19,7 +19,7 @@ object Test { val a = new MyActor a.start() - val b = new Reactor { + val b = new Reactor[Any] { def act() { react { case r: MyActor => diff --git a/test/files/jvm/replyreactor.scala b/test/files/jvm/replyreactor.scala index 0f452dbc7b..fb915cf3f9 100644 --- a/test/files/jvm/replyreactor.scala +++ b/test/files/jvm/replyreactor.scala @@ -1,4 +1,4 @@ -import scala.actors.{Reactor, ReplyReactor} +import scala.actors.ReplyReactor object Test { def main(args: Array[String]) { @@ -12,10 +12,10 @@ object Test { } a.start() - val b = new Reactor { + val b = new ReplyReactor { def act() { react { - case r: Reactor => + case r: ReplyReactor => r ! 'hello react { case any => diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index 2b0ad3888b..3f095cb51e 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -33,9 +33,9 @@ x10 eq y10: true, y10 eq x10: true x10 equals y10: true, y10 equals x10: true x9 eq x10: false, x10 eq x9: false -x9 equals x10: true, x10 equals x9: true +x9 equals x10: false, x10 equals x9: false x9 eq y10: false, y10 eq x9: false -x9 equals y10: true, y10 equals x9: true +x9 equals y10: false, y10 equals x9: false f1 = <na> _f1 = <na> @@ -77,12 +77,12 @@ x = BitSet(2, 3) y = BitSet(2, 3) x equals y: true, y equals x: true -x = Map(2 -> B, 1 -> A, 3 -> C) +x = Map(1 -> A, 2 -> B, 3 -> C) y = Map(1 -> A, 2 -> B, 3 -> C) x equals y: true, y equals x: true x = Set(1, 2) -y = Set(2, 1) +y = Set(1, 2) x equals y: true, y equals x: true x = List((buffers,20), (layers,2), (title,3)) diff --git a/test/files/jvm/t1652.check b/test/files/jvm/t1652.check deleted file mode 100644 index dfa480ce6e..0000000000 --- a/test/files/jvm/t1652.check +++ /dev/null @@ -1,2 +0,0 @@ -OK1 -OK2 diff --git a/test/files/jvm/t2470.cmds b/test/files/jvm/t2470.cmds new file mode 100644 index 0000000000..b4ef0f4aeb --- /dev/null +++ b/test/files/jvm/t2470.cmds @@ -0,0 +1,3 @@ +javac Action.java Task.java +scalac Test_1.scala +scalac Read_Classfile_2.scala diff --git a/test/files/jvm/t2827.check b/test/files/jvm/t2827.check new file mode 100644 index 0000000000..c318e01ae5 --- /dev/null +++ b/test/files/jvm/t2827.check @@ -0,0 +1,3 @@ +Larry +Curly +Moe diff --git a/test/files/jvm/t2827.scala b/test/files/jvm/t2827.scala new file mode 100644 index 0000000000..d89e68516b --- /dev/null +++ b/test/files/jvm/t2827.scala @@ -0,0 +1,14 @@ +object Stooges extends Enumeration { + type Stooge = Value + val Larry, Curly, Moe = Value + def nextStooge(v:Stooges.Stooge):Stooges.Stooge = + Stooges((v.id+1) % Stooges.maxId) +} + +object Test { + def main(args: Array[String]) { + println(Stooges.Larry) + println(Stooges.Curly) + println(Stooges.Moe) + } +} diff --git a/test/files/jvm/t3003.check b/test/files/jvm/t3003.check new file mode 100644 index 0000000000..c69e389d13 --- /dev/null +++ b/test/files/jvm/t3003.check @@ -0,0 +1 @@ +List(List(@Annot(optionType=class java.lang.String))) diff --git a/test/files/jvm/t3003.cmds b/test/files/jvm/t3003.cmds new file mode 100644 index 0000000000..c00396627c --- /dev/null +++ b/test/files/jvm/t3003.cmds @@ -0,0 +1,2 @@ +javac Annot.java +scalac Test_1.scala diff --git a/test/files/jvm/t3003/Annot.java b/test/files/jvm/t3003/Annot.java new file mode 100644 index 0000000000..1d5f206fd7 --- /dev/null +++ b/test/files/jvm/t3003/Annot.java @@ -0,0 +1,4 @@ +@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) +public @interface Annot { + Class<?> optionType(); +} diff --git a/test/files/jvm/t3003/Test_1.scala b/test/files/jvm/t3003/Test_1.scala new file mode 100644 index 0000000000..ec7f220c94 --- /dev/null +++ b/test/files/jvm/t3003/Test_1.scala @@ -0,0 +1,8 @@ +class C { + @Annot(optionType=classOf[String]) val k = 0 +} +object Test { + def main(args: Array[String]) { + println(classOf[C].getDeclaredFields.toList.sortBy(f => f.getName).map(f => f.getAnnotations.toList)) + } +} diff --git a/test/files/jvm/t3102.check b/test/files/jvm/t3102.check new file mode 100644 index 0000000000..d705e0b20e --- /dev/null +++ b/test/files/jvm/t3102.check @@ -0,0 +1,2 @@ +42 +OK diff --git a/test/files/jvm/t3102.scala b/test/files/jvm/t3102.scala new file mode 100644 index 0000000000..ea3e720eca --- /dev/null +++ b/test/files/jvm/t3102.scala @@ -0,0 +1,26 @@ +import scala.actors.{Actor, TIMEOUT} +import Actor._ + +object Test { + def main(args: Array[String]) { + val a = actor { + react { + case 'hello => + reply(42) + } + } + + val b = actor { + self.trapExit = true + val ft = a !! 'hello + println(ft()) + // no message should be left over in mailbox + reactWithin(0) { + case TIMEOUT => + println("OK") + case any => + println(any) + } + } + } +} diff --git a/test/files/jvm/unittest_io.scala b/test/files/jvm/unittest_io.scala index 0cf1165ec8..80d33d8433 100644 --- a/test/files/jvm/unittest_io.scala +++ b/test/files/jvm/unittest_io.scala @@ -16,7 +16,7 @@ it is split on several lines. isn't it? """) def runTest() = assertEquals("wrong number of lines",src.getLines("\n").toList.length,5) // five new lines in there - //for(val line <- src.getLines) { + //for (line <- src.getLines) { // Console.print(line) //} } diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala index e305f516d7..56e1c4ef96 100644 --- a/test/files/jvm/xml01.scala +++ b/test/files/jvm/xml01.scala @@ -25,20 +25,18 @@ object Test extends Application with Assert { override def text = "" } - assertSameElements(List(3), List(3)) - println("equality") - assertEquals(c, parsedxml11) - assertEquals(parsedxml1, parsedxml11) - assertSameElements(List(parsedxml1), List(parsedxml11)) - assertSameElements(Array(parsedxml1).toList, List(parsedxml11)) + assertEqualsXML(c, parsedxml11) + assertEqualsXML(parsedxml1, parsedxml11) + assertSameElementsXML(List(parsedxml1), List(parsedxml11)) + assertSameElementsXML(Array(parsedxml1).toList, List(parsedxml11)) val x2 = "<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>"; val i = new InputSource(new StringReader(x2)) val x2p = XML.load(i) - assertEquals(x2p, Elem(null, "book" , e, sc, + assertEqualsXML(x2p, Elem(null, "book" , e, sc, Elem(null, "author", e, sc,Text("Peter Buneman")), Elem(null, "author", e, sc,Text("Dan Suciu")), Elem(null, "title" , e, sc,Text("Data on ze web")))); @@ -51,9 +49,9 @@ object Test extends Application with Assert { println("xpath \\") - assertSameElements(parsedxml1 \ "_" , List(Elem(null,"world", e, sc))) + assertSameElementsXML(parsedxml1 \ "_" , List(Elem(null,"world", e, sc))) - assertSameElements(parsedxml1 \ "world", List(Elem(null,"world", e, sc))) + assertSameElementsXML(parsedxml1 \ "world", List(Elem(null,"world", e, sc))) /* Console.println( parsedxml2 \ "_" ); @@ -63,7 +61,7 @@ object Test extends Application with Assert { }; */ - assertSameElements( + assertSameElementsXML( parsedxml2 \ "_" , List( @@ -77,7 +75,7 @@ object Test extends Application with Assert { ); assertEquals( (parsedxml2 \ "author").length, 0 ); - assertSameElements( + assertSameElementsXML( parsedxml2 \ "book", List( @@ -91,7 +89,7 @@ object Test extends Application with Assert { ) ); - assertSameElements( + assertSameElementsXML( parsedxml2 \ "_" \ "_", @@ -104,7 +102,7 @@ object Test extends Application with Assert { ) ); - assertSameElements( + assertSameElementsXML( parsedxml2 \ "_" \ "author", @@ -116,11 +114,11 @@ object Test extends Application with Assert { ); - assertSameElements( (parsedxml2 \ "_" \ "_" \ "author"), List() ); + assertSameElementsXML( (parsedxml2 \ "_" \ "_" \ "author"), List() ); Console.println("xpath \\\\ DESCENDANTS"); - assertSameElements( + assertSameElementsXML( parsedxml2 \\ "author", @@ -133,7 +131,7 @@ object Test extends Application with Assert { ); - assertSameElements( + assertSameElementsXML( parsedxml2 \\ "title", @@ -144,10 +142,10 @@ object Test extends Application with Assert { println( - (parsedxml2 \\ "book" ){ n:Node => n \ "title" == "Data on ze web" } + (parsedxml2 \\ "book" ){ n:Node => (n \ "title") xml_== "Data on ze web" } ); - assertEquals( + assertEqualsXML( (new NodeSeq { val theSeq = List( parsedxml2 ) }) \\ "_", @@ -191,13 +189,13 @@ object Test extends Application with Assert { val zz1 = <xml:group><a/><b/><c/></xml:group> - assertTrue(zx1 == zz1) + assertTrue(zx1 xml_== zz1) assertTrue(zz1.length == 3) // unparsed - val uup = <xml:unparsed>&<<>""^%@$!#</xml:unparsed> - assertTrue(uup == "&<<>\"\"^%@$!#") + // val uup = <xml:unparsed>&<<>""^%@$!#</xml:unparsed> + // assertTrue(uup == "&<<>\"\"^%@$!#") // test unicode escapes backslash u println("attribute value normalization") diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala index 0cbeb27ce2..11f77cc90f 100644 --- a/test/files/jvm/xml02.scala +++ b/test/files/jvm/xml02.scala @@ -18,10 +18,10 @@ object Test extends TestConsoleMain { object XmlEx extends TestCase("attributes") with Assert { override def runTest = { - assertTrue("@one", ax \ "@foo" == "bar") // uses NodeSeq.view! - assertTrue("@two", ax \ "@foo" == xml.Text("bar")) // dto. - assertTrue("@three", bx \ "@foo" == "bar&x") // dto. - assertTrue ("@four", (bx \ "@foo") sameElements List(xml.Text("bar&x"))) + assertTrue("@one", (ax \ "@foo") xml_== "bar") // uses NodeSeq.view! + assertTrue("@two", (ax \ "@foo") xml_== xml.Text("bar")) // dto. + assertTrue("@three", (bx \ "@foo") xml_== "bar&x") // dto. + assertTrue ("@four", (bx \ "@foo") xml_sameElements List(xml.Text("bar&x"))) assertEquals("@five", "<hello foo=\"bar&x\"></hello>", bx.toString) } } @@ -29,8 +29,8 @@ object Test extends TestConsoleMain { object XmlEy extends TestCase("attributes with namespace") with Assert { override def runTest = { val z = ax \ "@{the namespace from outer space}foo" - assertTrue("@six", ax \ "@{the namespace from outer space}foo" == "baz") - assertTrue("@eight", cx \ "@{the namespace from outer space}foo" == "baz") + assertTrue("@six", (ax \ "@{the namespace from outer space}foo") xml_== "baz") + assertTrue("@eight", (cx \ "@{the namespace from outer space}foo") xml_== "baz") try { ax \ "@" @@ -58,8 +58,8 @@ object Test extends TestConsoleMain { override def runTest = { assertTrue(<hello/> match { case <hello/> => true; case _ => false; }) assertTrue(<x:ga xmlns:x="z"/> match { case <x:ga/> => true; case _ => false; }); - assertTrue(Utility.trim(cx) match { case n @ <hello>crazy text world</hello> if n \ "@foo" == "bar" => true; }) - assertTrue(Utility.trim(cx) match { case n @ <z:hello>crazy text world</z:hello> if n \ "@foo" == "bar" => true; }) + assertTrue(Utility.trim(cx) match { case n @ <hello>crazy text world</hello> if (n \ "@foo") xml_== "bar" => true; }) + assertTrue(Utility.trim(cx) match { case n @ <z:hello>crazy text world</z:hello> if (n \ "@foo") xml_== "bar" => true; }) } } diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala index 46faf283dc..6e711a0f86 100644 --- a/test/files/jvm/xmlstuff.scala +++ b/test/files/jvm/xmlstuff.scala @@ -64,9 +64,9 @@ passed ok Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!") }; val pelems_2 = new NodeSeq { val theSeq = List(Text("38!"),Text("58!")) }; - assertSameElements(pelems_1, pelems_2) + assertSameElementsXML(pelems_1, pelems_2) - assertEquals(p \\ "@bazValue", Text("8")) + assertEqualsXML(p \\ "@bazValue", Text("8")) val books = <bks> @@ -97,7 +97,7 @@ passed ok println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( for (t <- books \\ "title"; r <- reviews \\ "entry" - if r \ "title" == t) yield + if (r \ "title") xml_== t) yield <result> { t } { r \ "remarks" } @@ -139,7 +139,7 @@ val addrBook = println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( for (t <- addrBook \\ "entry"; r <- phoneBook \\ "entry" - if t \ "name" == r \ "name") yield + if (t \ "name") xml_== (r \ "name")) yield <result> { t.child } { r \ "phone" } diff --git a/test/files/neg/bug1279a.check b/test/files/neg/bug1279a.check deleted file mode 100644 index edfd1fe871..0000000000 --- a/test/files/neg/bug1279a.check +++ /dev/null @@ -1,6 +0,0 @@ -bug1279a.scala:34: error: type mismatch; - found : first.selfType - required: M{type T <: this.T} - def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl(first.next)) - ^ -one error found diff --git a/test/files/neg/bug1878.check b/test/files/neg/bug1878.check index 5484d675af..f760781fa0 100644 --- a/test/files/neg/bug1878.check +++ b/test/files/neg/bug1878.check @@ -1,10 +1,15 @@ bug1878.scala:3: error: _* may only come last val err1 = "" match { case Seq(f @ _*, ',') => f } ^ +bug1878.scala:3: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: java.lang.String + val err1 = "" match { case Seq(f @ _*, ',') => f } + ^ bug1878.scala:9: error: _* may only come last val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) ^ bug1878.scala:13: error: _* may only come last case <p> { _* } </p> => ^ -three errors found +four errors found diff --git a/test/files/neg/bug2148.check b/test/files/neg/bug2148.check new file mode 100644 index 0000000000..22be424c39 --- /dev/null +++ b/test/files/neg/bug2148.check @@ -0,0 +1,4 @@ +bug2148.scala:9: error: type A is not a stable prefix + val b = new A with A#A1 + ^ +one error found diff --git a/test/files/neg/bug2148.scala b/test/files/neg/bug2148.scala new file mode 100644 index 0000000000..25788be84a --- /dev/null +++ b/test/files/neg/bug2148.scala @@ -0,0 +1,10 @@ +class A { + var i = 0 + trait A1 extends A { + i += 1 + } +} + +object Bob { + val b = new A with A#A1 +}
\ No newline at end of file diff --git a/test/files/neg/bug3123.check b/test/files/neg/bug3123.check new file mode 100644 index 0000000000..8f5319c9a3 --- /dev/null +++ b/test/files/neg/bug3123.check @@ -0,0 +1,4 @@ +bug3123.scala:3: error: object Int is not a value + t match { case Int => true } + ^ +one error found diff --git a/test/files/neg/bug3123.scala b/test/files/neg/bug3123.scala new file mode 100644 index 0000000000..667a1da918 --- /dev/null +++ b/test/files/neg/bug3123.scala @@ -0,0 +1,5 @@ +object NotAValue { + def test[T](t : T) { + t match { case Int => true } + } +} diff --git a/test/files/neg/bug414.check b/test/files/neg/bug414.check index c0f039ad26..ec23e26337 100644 --- a/test/files/neg/bug414.check +++ b/test/files/neg/bug414.check @@ -1,7 +1,3 @@ -bug414.scala:1: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. -case class Empty[a] extends IntMap[a]; - ^ bug414.scala:5: error: pattern type is incompatible with expected type; found : object Empty required: IntMap[a] @@ -12,5 +8,4 @@ bug414.scala:7: error: type mismatch; required: a case _ => ^ -one warning found two errors found diff --git a/test/files/neg/bug961.check b/test/files/neg/bug961.check index 8b407d1d0c..439ed98675 100644 --- a/test/files/neg/bug961.check +++ b/test/files/neg/bug961.check @@ -1,9 +1,4 @@ -bug961.scala:4: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. - private case class B_inner extends A - ^ bug961.scala:11: error: Temp.this.B of type object Temp.B does not take parameters B() match { ^ -one warning found one error found diff --git a/test/files/neg/bug961.scala b/test/files/neg/bug961.scala index 15309b96b4..088bddd7ee 100644 --- a/test/files/neg/bug961.scala +++ b/test/files/neg/bug961.scala @@ -1,7 +1,7 @@ -object Temp{ +object Temp { abstract class A - object B{ - private case class B_inner extends A + object B { + private case class B_inner() extends A def apply: A = B_inner() def unapply(a: A) = a match { case B_inner() => true diff --git a/test/files/neg/migration28.check b/test/files/neg/migration28.check new file mode 100644 index 0000000000..9e042a0f0b --- /dev/null +++ b/test/files/neg/migration28.check @@ -0,0 +1,9 @@ +migration28.scala:5: error: method ++= in class Stack has changed semantics: +Stack ++= now pushes arguments on the stack from left to right. + s ++= List(1,2,3) + ^ +migration28.scala:7: error: method foreach in class Stack has changed semantics: +Stack iterator and foreach now traverse in FIFO order. + s foreach (_ => ()) + ^ +two errors found diff --git a/test/files/neg/migration28.flags b/test/files/neg/migration28.flags new file mode 100644 index 0000000000..f7025d0226 --- /dev/null +++ b/test/files/neg/migration28.flags @@ -0,0 +1 @@ +-Yfatal-warnings -Xmigration diff --git a/test/files/neg/migration28.scala b/test/files/neg/migration28.scala new file mode 100644 index 0000000000..090b32d690 --- /dev/null +++ b/test/files/neg/migration28.scala @@ -0,0 +1,12 @@ +object Test { + import scala.collection.mutable._ + + val s = new Stack[Int] + s ++= List(1,2,3) + s map (_ + 1) + s foreach (_ => ()) + + def main(args: Array[String]): Unit = { + + } +} diff --git a/test/files/neg/multi-array.flags b/test/files/neg/multi-array.flags new file mode 100644 index 0000000000..c36e713ab8 --- /dev/null +++ b/test/files/neg/multi-array.flags @@ -0,0 +1 @@ +-deprecation
\ No newline at end of file diff --git a/test/files/neg/patmat-type-check.check b/test/files/neg/patmat-type-check.check new file mode 100644 index 0000000000..ab638b616d --- /dev/null +++ b/test/files/neg/patmat-type-check.check @@ -0,0 +1,21 @@ +patmat-type-check.scala:18: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: java.lang.String + def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail + ^ +patmat-type-check.scala:19: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: Array[Char] + def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail + ^ +patmat-type-check.scala:23: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: Test.Bop2 + def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail + ^ +patmat-type-check.scala:27: error: scrutinee is incompatible with pattern type; + found : Seq[A] + required: Test.Bop3[T] + def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true } // fail + ^ +four errors found diff --git a/test/files/neg/patmat-type-check.scala b/test/files/neg/patmat-type-check.scala new file mode 100644 index 0000000000..c6c689b256 --- /dev/null +++ b/test/files/neg/patmat-type-check.scala @@ -0,0 +1,28 @@ +object Test +{ + def s1 = "bob".toList match { case Seq('b', 'o', 'b') => true } // list ok + + // not final, allowed + class Bop + def s2(x: Bop) = x match { case Seq('b', 'o', 'b') => true } + + // covariance, allowed + final class Bop4[+T] + def s3[T](x: Bop4[T]) = x match { case Seq('b', 'o', 'b') => true } + + // contravariance, allowed + final class Bop5[T, U, -V] + def s4[T1, T2](x: Bop5[_, T1, T2]) = x match { case Seq('b', 'o', 'b') => true } + + // String and Array are final/invariant, disallowed + def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail + def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail + + // final, no type parameters, should be disallowed + final class Bop2 + def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail + + // final, invariant type parameter, should be disallowed + final class Bop3[T] + def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true } // fail +} diff --git a/test/files/neg/patmatexhaust.check b/test/files/neg/patmatexhaust.check index 1c46b6c9e5..ca769300c0 100644 --- a/test/files/neg/patmatexhaust.check +++ b/test/files/neg/patmatexhaust.check @@ -15,8 +15,8 @@ missing combination Qult Qult def ma3(x:Mult) = (x,x) match { // not exhaustive ^ patmatexhaust.scala:49: warning: match is not exhaustive! -missing combination Gu missing combination Gp +missing combination Gu def ma4(x:Deep) = x match { // missing cases: Gu, Gp ^ diff --git a/test/files/neg/t0528neg.scala b/test/files/neg/t0528neg.scala index 911745b763..30d20c95b1 100644 --- a/test/files/neg/t0528neg.scala +++ b/test/files/neg/t0528neg.scala @@ -3,7 +3,7 @@ trait Sequ[+A] { } class RichStr extends Sequ[Char] { - // override to a primitve array + // override to a primitive array def toArray: Array[Char] = new Array[Char](10) } diff --git a/test/files/neg/t0851.check b/test/files/neg/t0851.check deleted file mode 100644 index 61d2a98632..0000000000 --- a/test/files/neg/t0851.check +++ /dev/null @@ -1,9 +0,0 @@ -t0851.scala:14: error: not enough arguments for method apply: (v1: Int,v2: String)java.lang.String in trait Function2. -Unspecified value parameter v2. - println(f(1)) - ^ -t0851.scala:22: error: not enough arguments for method apply: (v1: Int,v2: String)java.lang.String in trait Function2. -Unspecified value parameter v2. - println(fn(1)) - ^ -two errors found diff --git a/test/files/neg/t0851.scala b/test/files/neg/t0851.scala deleted file mode 100644 index b28be2c697..0000000000 --- a/test/files/neg/t0851.scala +++ /dev/null @@ -1,25 +0,0 @@ -package test - -// This gives now type errors about missing parameters, which seems OK to me. -// The tests just make sure it does not crash - -object test1 { - case class Foo[T,T2](f : (T,T2) => String) extends (((T,T2)) => String){ - def apply(t : T) = (s:T2) => f(t,s) - def apply(p : (T,T2)) = f(p._1,p._2) - } - implicit def g[T](f : (T,String) => String) = Foo(f) - def main(args : Array[String]) : Unit = { - val f = (x:Int,s:String) => s + x - println(f(1)) - () - } -} -object Main { - def main(args : Array[String]) { - val fn = (a : Int, str : String) => "a: " + a + ", str: " + str - implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null) - println(fn(1)) - () - } -} diff --git a/test/files/neg/t2179.check b/test/files/neg/t2179.check index e454e117b5..aa94fabe1f 100644 --- a/test/files/neg/t2179.check +++ b/test/files/neg/t2179.check @@ -1,9 +1,9 @@ -t2179.scala:2: error: inferred type arguments [scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]{def sameElements[B >: Any](that: Iterable[B]): Boolean}]; def reverse: scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}; def dropRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def takeRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def slice(start: Int,end: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def take(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def drop(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}}] do not conform to method reduceLeft's type parameter bounds [B >: List[Double]] +t2179.scala:2: error: inferred type arguments [scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}}] do not conform to method reduceLeft's type parameter bounds [B >: List[Double]] (Nil:List[List[Double]]).reduceLeft((_: Any, _: Any) => Nil.indices.map(_ => 0d)) ^ t2179.scala:2: error: type mismatch; found : (Any, Any) => scala.collection.immutable.IndexedSeq[Double] - required: (scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]{def sameElements[B >: Any](that: Iterable[B]): Boolean}]; def reverse: scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}; def dropRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def takeRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def slice(start: Int,end: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def take(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def drop(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}}, List[Double]) => scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]{def sameElements[B >: Any](that: Iterable[B]): Boolean}]; def reverse: scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}; def dropRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def takeRight(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def slice(start: Int,end: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def take(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}; def drop(n: Int): scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]}} + required: (scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}}, List[Double]) => scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}} (Nil:List[List[Double]]).reduceLeft((_: Any, _: Any) => Nil.indices.map(_ => 0d)) ^ two errors found diff --git a/test/files/neg/t2386.check b/test/files/neg/t2386.check new file mode 100644 index 0000000000..2caa46c731 --- /dev/null +++ b/test/files/neg/t2386.check @@ -0,0 +1,4 @@ +t2386.scala:2: error: could not find implicit value for evidence parameter of type scala.reflect.ClassManifest[Array[_ >: java.lang.String with Int]] + val a = Array(Array(1, 2), Array("a","b")) + ^ +one error found diff --git a/test/files/neg/t2386.scala b/test/files/neg/t2386.scala new file mode 100644 index 0000000000..56146cc5c3 --- /dev/null +++ b/test/files/neg/t2386.scala @@ -0,0 +1,3 @@ +object Test { + val a = Array(Array(1, 2), Array("a","b")) +} diff --git a/test/files/neg/t2918.check b/test/files/neg/t2918.check new file mode 100644 index 0000000000..e67f24ec57 --- /dev/null +++ b/test/files/neg/t2918.check @@ -0,0 +1,7 @@ +t2918.scala:2: error: cyclic aliasing or subtyping involving type A + def g[X, A[X] <: A[X]](x: A[X]) = x + ^ +t2918.scala:2: error: A does not take type parameters + def g[X, A[X] <: A[X]](x: A[X]) = x + ^ +two errors found diff --git a/test/files/neg/t2918.scala b/test/files/neg/t2918.scala new file mode 100755 index 0000000000..ff2be39ae0 --- /dev/null +++ b/test/files/neg/t2918.scala @@ -0,0 +1,3 @@ +object Test { + def g[X, A[X] <: A[X]](x: A[X]) = x +} diff --git a/test/files/neg/t3006.check b/test/files/neg/t3006.check new file mode 100644 index 0000000000..9a90d32b28 --- /dev/null +++ b/test/files/neg/t3006.check @@ -0,0 +1,6 @@ +t3006.scala:8: error: type mismatch; + found : java.lang.String("H") + required: Int + println(A(3) + "H") + ^ +one error found diff --git a/test/files/neg/t3006.scala b/test/files/neg/t3006.scala new file mode 100755 index 0000000000..f476c1717d --- /dev/null +++ b/test/files/neg/t3006.scala @@ -0,0 +1,10 @@ +object Test extends Application { + case class A(x: Int); + + class Foo(a: A) { println("Foo created!"); def +(x: Int) = new A(this.a.x + x); } + + implicit def aToFoo(x: A) = new Foo(x); + + println(A(3) + "H") + +} diff --git a/test/files/neg/t3015.check b/test/files/neg/t3015.check new file mode 100644 index 0000000000..32809b0669 --- /dev/null +++ b/test/files/neg/t3015.check @@ -0,0 +1,11 @@ +t3015.scala:7: error: scrutinee is incompatible with pattern type; + found : _$1 where type _$1 + required: java.lang.String + val b(foo) = "foo" + ^ +t3015.scala:7: error: type mismatch; + found : _$1(in value foo) where type _$1(in value foo) <: java.lang.String + required: (some other)_$1(in value foo) where type (some other)_$1(in value foo) + val b(foo) = "foo" + ^ +two errors found diff --git a/test/files/neg/t3015.scala b/test/files/neg/t3015.scala new file mode 100644 index 0000000000..0bd53e7a03 --- /dev/null +++ b/test/files/neg/t3015.scala @@ -0,0 +1,8 @@ +class UnApp[P] { + def unapply(a: P): Option[P] = Some(a) +} + +object Test extends Application { + val b: UnApp[_] = new UnApp[String] + val b(foo) = "foo" +} diff --git a/test/files/neg/t3115.check b/test/files/neg/t3115.check new file mode 100644 index 0000000000..04f64eec3f --- /dev/null +++ b/test/files/neg/t3115.check @@ -0,0 +1,10 @@ +t3115.scala:6: error: object Math in object sc is deprecated: + println(sc.Math) + ^ +t3115.scala:7: error: object Math in package scala is deprecated: use scala.math package instead + println(scala.Math) + ^ +t3115.scala:8: error: object Math in package scala is deprecated: use scala.math package instead + scala.Math.Pi + ^ +three errors found diff --git a/test/files/neg/t3115.flags b/test/files/neg/t3115.flags new file mode 100644 index 0000000000..bf8f88334b --- /dev/null +++ b/test/files/neg/t3115.flags @@ -0,0 +1 @@ +-deprecation -Yfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t3115.scala b/test/files/neg/t3115.scala new file mode 100755 index 0000000000..4aeeb4063e --- /dev/null +++ b/test/files/neg/t3115.scala @@ -0,0 +1,9 @@ +object sc { + @deprecated("") object Math +} + +object Test { + println(sc.Math) + println(scala.Math) + scala.Math.Pi +} diff --git a/test/files/neg/t3118.check b/test/files/neg/t3118.check new file mode 100644 index 0000000000..da00f1c330 --- /dev/null +++ b/test/files/neg/t3118.check @@ -0,0 +1,7 @@ +t3118.scala:6: error: value C is not a member of O1 + println(x.C()) // should not be accessible + ^ +t3118.scala:7: error: type C is not a member of O1 + println(new x.C) // is correctly not accessible + ^ +two errors found diff --git a/test/files/neg/t3118.scala b/test/files/neg/t3118.scala new file mode 100644 index 0000000000..9be24c1ed4 --- /dev/null +++ b/test/files/neg/t3118.scala @@ -0,0 +1,8 @@ +class O1 { + private[this] case class C() + + val x = new O1 + + println(x.C()) // should not be accessible + println(new x.C) // is correctly not accessible +} diff --git a/test/files/neg/t3222.check b/test/files/neg/t3222.check new file mode 100644 index 0000000000..6170827cc9 --- /dev/null +++ b/test/files/neg/t3222.check @@ -0,0 +1,13 @@ +t3222.scala:1: error: not found: type B +@throws(classOf[B]) + ^ +t3222.scala:4: error: not found: type D + def foo(@throws(classOf[D]) x: Int) {} + ^ +t3222.scala:3: error: not found: type C + @throws(classOf[C]) + ^ +t3222.scala:6: error: not found: type E + @throws(classOf[E]) + ^ +four errors found diff --git a/test/files/neg/t3222.scala b/test/files/neg/t3222.scala new file mode 100644 index 0000000000..448292e8a7 --- /dev/null +++ b/test/files/neg/t3222.scala @@ -0,0 +1,9 @@ +@throws(classOf[B]) +class ExceptionTest { + @throws(classOf[C]) + def foo(@throws(classOf[D]) x: Int) {} + + @throws(classOf[E]) + type t = String +} + diff --git a/test/files/neg/unit2anyref.check b/test/files/neg/unit2anyref.check index 7af4564ffb..2616fd35f9 100644 --- a/test/files/neg/unit2anyref.check +++ b/test/files/neg/unit2anyref.check @@ -1,10 +1,8 @@ unit2anyref.scala:2: error: type mismatch; found : Unit required: AnyRef -Note that implicit conversions are not applicable because they are ambiguous: - both method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd - and method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A] - are possible conversion functions from Unit to AnyRef +Note: primitive types are not implicitly converted to AnyRef. +You can safely force boxing by casting x.asInstanceOf[AnyRef]. val x: AnyRef = () // this should not succeed. ^ one error found diff --git a/test/files/pos/annotations.scala b/test/files/pos/annotations.scala index d1bd6ba264..0819379d86 100644 --- a/test/files/pos/annotations.scala +++ b/test/files/pos/annotations.scala @@ -1,4 +1,5 @@ class ann(i: Int) extends Annotation +class cfann(x: String) extends ClassfileAnnotation // annotations on abstract types abstract class C1[@serializable @cloneable +T, U, V[_]] @@ -35,6 +36,10 @@ object Test { // annotation on annotation constructor @(ann @ann(100))(200) def foo() = 300 + + // #2984 + private final val NAMESPACE = "/info" + @cfann(x = NAMESPACE + "/index") def index = "success" } // test forward references to getters / setters @@ -84,3 +89,22 @@ trait BeanF { def isG(): Boolean def setG(nb: Boolean): Unit } + + +class Ann3(arr: Array[String]) extends ClassfileAnnotation +class Ann4(i: Int) extends ClassfileAnnotation +class Ann5(value: Class[_]) extends ClassfileAnnotation + +object Test3 { + final val i = 1083 + final val cls = classOf[String] +} + +class Test4 { + @Ann3(arr = Array("dlkfj", "DSF")) + @Ann4(i = 2908) + @Ann4(i = Test3.i) + @Ann5(value = classOf[Int]) + @Ann5(Test3.cls) + def foo {} +} diff --git a/test/files/pos/bug0646.scala b/test/files/pos/bug0646.scala index 64214f65b1..a56e857223 100644 --- a/test/files/pos/bug0646.scala +++ b/test/files/pos/bug0646.scala @@ -10,7 +10,7 @@ object xfor { </bks>; new NodeSeq { val theSeq = books.child } match { - case t @ <title>Blabla</title> => t + case t @ Seq(<title>Blabla</title>) => t } //val n: NodeSeq = new NodeSeq { val theSeq = books.child } diff --git a/test/files/pos/bug2310.scala b/test/files/pos/bug2310.scala new file mode 100644 index 0000000000..68912b4961 --- /dev/null +++ b/test/files/pos/bug2310.scala @@ -0,0 +1,38 @@ +import scala.Stream._ + +object consistencyError { + /* this gives an error: + Consistency problem compiling (virtual file)! + Trying to call method body%1(List(scala.collection.immutable.Stream[A])) with arguments (List(tp2, temp6, temp5)) + case (l #:: ls, rs) => None + ^ + scala.tools.nsc.symtab.Types$TypeError: too many arguments for method body%1: (val rs: scala.collection.immutable.Stream[A])None.type + + two errors found + vss(0) = + args = List(tp2, temp6, temp5) + vss(1) = value rs, value ls, value l + args = List(tp2, temp6, temp5) + targets(0) = FinalState(,scala.None) + targets(1) = FinalState(,scala.None) + labels(1) = method body%1 + labels(0) = method body%0 + bx = 1 + label.tpe = (val rs: scala.collection.immutable.Stream[A])None.type + */ + def crash[A](lefts: Stream[A], rights: Stream[A]) = (lefts, rights) match { + case (Stream.Empty, Stream.Empty) => None + case (l #:: ls, rs) => None + } + + // These work + // def works1[A](lefts: Stream[A]) = lefts match { + // case Stream.Empty => None + // case l #:: ls => None + // } + // + // def works2[A](lefts: Stream[A], rights: Stream[A]) = (lefts, rights) match { + // case (Stream.Empty, Stream.Empty) => None + // case (ls, rs) => None + // } +} diff --git a/test/files/pos/bug3097.flags b/test/files/pos/bug3097.flags new file mode 100644 index 0000000000..570b15929d --- /dev/null +++ b/test/files/pos/bug3097.flags @@ -0,0 +1 @@ +-unchecked -Yfatal-warnings diff --git a/test/files/pos/bug3097.scala b/test/files/pos/bug3097.scala new file mode 100644 index 0000000000..a034b960f7 --- /dev/null +++ b/test/files/pos/bug3097.scala @@ -0,0 +1,31 @@ +package seal + +sealed trait ISimpleValue + +sealed trait IListValue extends ISimpleValue { + def items: List[IAtomicValue[_]] +} +sealed trait IAtomicValue[O] extends ISimpleValue { + def data: O +} + +sealed trait IAbstractDoubleValue[O] extends IAtomicValue[O] { } +sealed trait IDoubleValue extends IAbstractDoubleValue[Double] + +case class ListValue(val items: List[IAtomicValue[_]]) extends IListValue +class DoubleValue(val data: Double) extends IDoubleValue { + def asDouble = data +} + +object Test { + /** + * @param args the command line arguments + */ + def main(args: Array[String]): Unit = { + val v: ISimpleValue = new DoubleValue(1) + v match { + case m: IListValue => println("list") + case a: IAtomicValue[_] => println("atomic") + } + } +} diff --git a/test/files/pos/bug3136.scala b/test/files/pos/bug3136.scala new file mode 100644 index 0000000000..33d42c2f3c --- /dev/null +++ b/test/files/pos/bug3136.scala @@ -0,0 +1,19 @@ +class Type +class Symbol +case class PolyType(tps: List[Symbol], res: Type) extends Type +class OtherType extends Type + +// case class NullaryMethodType(tp: Type) extends Type + +object NullaryMethodType { + def apply(resTpe: Type): Type = PolyType(List(), resTpe) + def unapply(tp: Type): Option[(Type)] = None +} + +object Test { + def TEST(tp: Type): String = + tp match { + case PolyType(ps1, PolyType(ps2, res @ PolyType(a, b))) => "1"+tp // couldn't find a simpler version that still crashes + case NullaryMethodType(meh) => "2"+meh + } +} diff --git a/test/files/pos/bug3175.scala b/test/files/pos/bug3175.scala new file mode 100644 index 0000000000..89bbf8b5fc --- /dev/null +++ b/test/files/pos/bug3175.scala @@ -0,0 +1,7 @@ +object Test { + def f(g:{val update:Unit}) = g.update + + def main(args: Array[String]): Unit = { + + } +} diff --git a/test/files/pos/bug432.scala b/test/files/pos/bug432.scala index 8e3097ac9d..087fd70aba 100644 --- a/test/files/pos/bug432.scala +++ b/test/files/pos/bug432.scala @@ -1,2 +1,2 @@ -case class Tata +case class Tata() object Tata diff --git a/test/files/pos/bug715.cmds b/test/files/pos/bug715.cmds new file mode 100644 index 0000000000..2836967fca --- /dev/null +++ b/test/files/pos/bug715.cmds @@ -0,0 +1,2 @@ +scalac meredith_1.scala +scalac runner_2.scala diff --git a/test/files/pos/manifest1.scala b/test/files/pos/manifest1.scala index 4d3b3bfa48..8901aa7437 100644 --- a/test/files/pos/manifest1.scala +++ b/test/files/pos/manifest1.scala @@ -13,8 +13,9 @@ object Test { abstract class C { type T = String; val x: T } val c = new C { val x = "abc" } foo(c.x) - abstract class D { type T; val x: T } - val d: D = new D { type T = String; val x = "x" } + abstract class D { type T; implicit val m: Manifest[T]; val x: T } + val stringm = implicitly[Manifest[String]] + val d: D = new D { type T = String; val m = stringm; val x = "x" } + import d.m foo(d.x) - } diff --git a/test/files/pos/scan.scala b/test/files/pos/scan.scala new file mode 100644 index 0000000000..47e0a7d976 --- /dev/null +++ b/test/files/pos/scan.scala @@ -0,0 +1,23 @@ + + + + +object Test { + + def main(args: Array[String]) { + val lst = List(1, 2, 3, 4, 5) + + assert(lst.scanLeft(0)(_ + _) == List(0, 1, 3, 6, 10, 15)) + assert(lst.scanRight(0)(_ + _) == List(15, 14, 12, 9, 5, 0)) + + val emp = List[Int]() + assert(emp.scanLeft(0)(_ + _) == List(0)) + assert(emp.scanRight(0)(_ + _) == List(0)) + + val stream = Stream(1, 2, 3, 4, 5) + assert(stream.scanLeft(0)(_ + _) == Stream(0, 1, 3, 6, 10, 15)) + + assert(Stream.from(1).scanLeft(0)(_ + _).take(5) == Stream(0, 1, 3, 6, 10)) + } + +}
\ No newline at end of file diff --git a/test/files/pos/spec-List.scala b/test/files/pos/spec-List.scala index ad864abd7c..c5bc3aa5fd 100644 --- a/test/files/pos/spec-List.scala +++ b/test/files/pos/spec-List.scala @@ -23,10 +23,10 @@ import annotation.tailrec * @author Martin Odersky and others * @version 2.8 */ -sealed abstract class List[@specialized +A] extends LinearSeq[A] +sealed trait List[@specialized +A] extends LinearSeq[A] with Product with GenericTraversableTemplate[A, List] - with LinearSeqLike[A, List[A]] { + with LinearSeqOptimized[A, List[A]] { override def companion: GenericCompanion[List] = List import scala.collection.{Iterable, Traversable, Seq} @@ -144,18 +144,12 @@ sealed abstract class List[@specialized +A] extends LinearSeq[A] /** Create a new list which contains all elements of this list * followed by all elements of Traversable `that' */ - override def ++[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[List[A], B, That]): That = { + override def ++[B >: A, That](xs: TraversableOnce[B])(implicit bf: CanBuildFrom[List[A], B, That]): That = { val b = bf(this) - if (b.isInstanceOf[ListBuffer[_]]) (this ::: that.toList).asInstanceOf[That] - else super.++(that) + if (b.isInstanceOf[ListBuffer[_]]) (this ::: xs.toList).asInstanceOf[That] + else super.++(xs) } - /** Create a new list which contains all elements of this list - * followed by all elements of Iterator `that' - */ - override def ++[B >: A, That](that: Iterator[B])(implicit bf: CanBuildFrom[List[A], B, That]): That = - this ++ that.toList - /** Overrides the method in Iterable for efficiency. * * @return the list itself @@ -654,7 +648,7 @@ object List extends SeqFactory[List] { * * @param arr the array to convert * @param start the first index to consider - * @param len the lenght of the range to convert + * @param len the length of the range to convert * @return a list that contains the same elements than <code>arr</code> * in the same order */ diff --git a/test/files/pos/spec-arrays.scala b/test/files/pos/spec-arrays.scala index c1f253a39d..96c75dd8de 100644 --- a/test/files/pos/spec-arrays.scala +++ b/test/files/pos/spec-arrays.scala @@ -30,7 +30,7 @@ final class IntArray(arr: Array[Int]) extends AbsArray[Int] { def length: Int = arr.length } -final class GenericArray[T](arr: Array[T]) extends AbsArray[T] { +final class ArraySeq[T](arr: Array[T]) extends AbsArray[T] { def apply(idx: Int): T = arr(idx) def update(idx: Int, elem: T) = arr(idx) = elem def length: Int = arr.length @@ -96,7 +96,7 @@ class ScalaSpec2Test extends Test { } class ScalaWrapTest extends Test { - val arr: AbsArray[Int] = new GenericArray(new Array[Int](1000)) + val arr: AbsArray[Int] = new ArraySeq(new Array[Int](1000)) def sum(): Int = { var acc = 0 @@ -116,7 +116,7 @@ class ScalaWrapTest extends Test { } class ScalaGenTest extends Test { - val arr: AbsArray[Integer] = new GenericArray(new Array[Integer](1000)) + val arr: AbsArray[Integer] = new ArraySeq(new Array[Integer](1000)) for (i <- 0 until arr.length) arr(i) = new Integer(0) def sum(): Int = { diff --git a/test/files/pos/spec-partially.flags b/test/files/pos/spec-partially.flags new file mode 100644 index 0000000000..973517e1c9 --- /dev/null +++ b/test/files/pos/spec-partially.flags @@ -0,0 +1 @@ +-Yspecialize diff --git a/test/files/pos/spec-partially.scala b/test/files/pos/spec-partially.scala new file mode 100644 index 0000000000..90778e42a8 --- /dev/null +++ b/test/files/pos/spec-partially.scala @@ -0,0 +1,5 @@ +/** Test case for partially specialized classes. see #2880. */ + +class Arc[State, @specialized T](label: T, to: State) + + diff --git a/test/files/pos/super.cmds b/test/files/pos/super.cmds new file mode 100644 index 0000000000..8f3f8a4172 --- /dev/null +++ b/test/files/pos/super.cmds @@ -0,0 +1,2 @@ +javac Super_1.java +scalac Super_2.scala diff --git a/test/files/pos/switchUnbox.flags b/test/files/pos/switchUnbox.flags index ec1ad20e3a..cdf5f84ede 100644 --- a/test/files/pos/switchUnbox.flags +++ b/test/files/pos/switchUnbox.flags @@ -1 +1 @@ --Xsqueeze:on +-Ysqueeze:on diff --git a/test/pending/pos/t0816.scala b/test/files/pos/t0816.scala index 44282ea872..0128a0ad72 100644 --- a/test/pending/pos/t0816.scala +++ b/test/files/pos/t0816.scala @@ -1,6 +1,6 @@ abstract class Atest(val data: String) -case class Btest(override val data: String, val b: boolean) extends Atest(data) +case class Btest(override val data: String, val b: Boolean) extends Atest(data) case class Ctest(override val data: String) extends Btest(data, true) diff --git a/test/files/pos/t0971.java b/test/files/pos/t0971.java deleted file mode 100644 index 160dc2c5af..0000000000 --- a/test/files/pos/t0971.java +++ /dev/null @@ -1,4 +0,0 @@ -class A { - int y = 1, z; - static Object x = new java.util.HashMap<Object , Object > () ; -} diff --git a/test/files/pos/t0999.scala b/test/files/pos/t0999.scala deleted file mode 100644 index c384820af1..0000000000 --- a/test/files/pos/t0999.scala +++ /dev/null @@ -1,5 +0,0 @@ -object A { - val d: Double = Math.sqrt(5 match { - case x: Double => x - }) -} diff --git a/test/files/pos/t1029.cmds b/test/files/pos/t1029.cmds new file mode 100644 index 0000000000..06b863dc03 --- /dev/null +++ b/test/files/pos/t1029.cmds @@ -0,0 +1,2 @@ +scalac Test_1.scala +scalac Test_2.scala diff --git a/test/pending/pos/t1035.scala b/test/files/pos/t1035.scala index a280a415d2..a280a415d2 100644 --- a/test/pending/pos/t1035.scala +++ b/test/files/pos/t1035.scala diff --git a/test/files/pos/t1164.scala b/test/files/pos/t1164.scala index b238bf54d9..ca780c9a26 100644 --- a/test/files/pos/t1164.scala +++ b/test/files/pos/t1164.scala @@ -12,7 +12,7 @@ object test { def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }} - // Try the same thing as above but use function as arguemnt to Bar + // Try the same thing as above but use function as argument to Bar // constructor type FunIntToA [a] = (Int) => a diff --git a/test/files/pos/t1380.flags b/test/files/pos/t1380.flags deleted file mode 100644 index f0b0ef7f51..0000000000 --- a/test/files/pos/t1380.flags +++ /dev/null @@ -1 +0,0 @@ --cp pending/pos/t1380/gnujaxp.jar diff --git a/test/files/pos/t1751.cmds b/test/files/pos/t1751.cmds new file mode 100644 index 0000000000..d4a4898ffd --- /dev/null +++ b/test/files/pos/t1751.cmds @@ -0,0 +1,3 @@ +javac SuiteClasses.java +scalac A2_1.scala +scalac A1_2.scala diff --git a/test/files/pos/t1756.scala b/test/files/pos/t1756.scala index 4f7202114c..d5d3ddc624 100755 --- a/test/files/pos/t1756.scala +++ b/test/files/pos/t1756.scala @@ -15,7 +15,7 @@ expected type from x+, because the lhs x is still typed as a Poly[A]. This means that the argument of the implicit conversion is typechecked with expected type A with Poly[A]. And no solution is found. -To solve this, I added a fallback scheme similar to implicit arguents: +To solve this, I added a fallback scheme similar to implicit arguments: When an implicit view that adds a method matching given arguments and result type fails, try again without the result type. */ diff --git a/test/files/pos/t1782.cmds b/test/files/pos/t1782.cmds new file mode 100644 index 0000000000..61f3d3788e --- /dev/null +++ b/test/files/pos/t1782.cmds @@ -0,0 +1,2 @@ +javac Ann.java Days.java ImplementedBy.java +scalac Test_1.scala diff --git a/test/pending/pos/t1836/J.java b/test/files/pos/t1836/J.java index a009a59e21..a009a59e21 100644 --- a/test/pending/pos/t1836/J.java +++ b/test/files/pos/t1836/J.java diff --git a/test/pending/pos/t1836/S.scala b/test/files/pos/t1836/S.scala index 88ce1063e9..88ce1063e9 100644 --- a/test/pending/pos/t1836/S.scala +++ b/test/files/pos/t1836/S.scala diff --git a/test/files/pos/t1942.cmds b/test/files/pos/t1942.cmds new file mode 100644 index 0000000000..c14311042a --- /dev/null +++ b/test/files/pos/t1942.cmds @@ -0,0 +1,2 @@ +scalac A_1.scala +scalac Test_2.scala diff --git a/test/pending/pos/t1996.scala b/test/files/pos/t1996.scala index 2730128196..2730128196 100644 --- a/test/pending/pos/t1996.scala +++ b/test/files/pos/t1996.scala diff --git a/test/files/pos/t2421c.scala b/test/files/pos/t2421c.scala new file mode 100644 index 0000000000..755e6a39f0 --- /dev/null +++ b/test/files/pos/t2421c.scala @@ -0,0 +1,17 @@ +object Test { + class A + class B + class C + class F[X] + + def f(implicit aa: F[A]) = println(aa) + + implicit def a : F[A] = new F[A]() + + // generalised from t2421b to verify we check enough + class G[X] + implicit def g[X] = new G[X]() + implicit def b[X <: B](implicit mx: G[X]) = new F[X]() + + f +}
\ No newline at end of file diff --git a/test/files/pos/t2433/A.java b/test/files/pos/t2433/A.java new file mode 100755 index 0000000000..340690c402 --- /dev/null +++ b/test/files/pos/t2433/A.java @@ -0,0 +1,4 @@ +class A223 extends B223.Inner { + static class Inner {} + void foo() {} +}
\ No newline at end of file diff --git a/test/files/pos/t2433/B.java b/test/files/pos/t2433/B.java new file mode 100755 index 0000000000..151dd71ca1 --- /dev/null +++ b/test/files/pos/t2433/B.java @@ -0,0 +1,4 @@ +class B223 { + static class Inner {} + void m(A223.Inner x) {} +}
\ No newline at end of file diff --git a/test/files/pos/t2433/Test.scala b/test/files/pos/t2433/Test.scala new file mode 100755 index 0000000000..02fd89b646 --- /dev/null +++ b/test/files/pos/t2433/Test.scala @@ -0,0 +1,3 @@ +object Test { + (new A223).foo() +} diff --git a/test/files/pos/t2464.cmds b/test/files/pos/t2464.cmds new file mode 100644 index 0000000000..ca733ef23d --- /dev/null +++ b/test/files/pos/t2464.cmds @@ -0,0 +1,3 @@ +javac JavaOne.java +scalac ScalaOne_1.scala +scalac t2464_2.scala diff --git a/test/pending/pos/t2610.scala b/test/files/pos/t2610.scala index 8dd4cde66e..8dd4cde66e 100644 --- a/test/pending/pos/t2610.scala +++ b/test/files/pos/t2610.scala diff --git a/test/pending/pos/t2660.scala b/test/files/pos/t2660.scala index b1908b201b..b1908b201b 100644 --- a/test/pending/pos/t2660.scala +++ b/test/files/pos/t2660.scala diff --git a/test/pending/pos/t2691.scala b/test/files/pos/t2691.scala index ba2e52f1fe..ba2e52f1fe 100644 --- a/test/pending/pos/t2691.scala +++ b/test/files/pos/t2691.scala diff --git a/test/files/pos/t2726.cmds b/test/files/pos/t2726.cmds new file mode 100644 index 0000000000..5fcb18bfbb --- /dev/null +++ b/test/files/pos/t2726.cmds @@ -0,0 +1,2 @@ +scalac SQLBuilder_1.scala +scalac test_2.scala diff --git a/test/files/pos/t2741/2741-1.scala b/test/files/pos/t2741/2741-1.scala new file mode 100644 index 0000000000..91c120ec1b --- /dev/null +++ b/test/files/pos/t2741/2741-1.scala @@ -0,0 +1,13 @@ +sealed trait Kleisli[M[_], A, B] + +trait PartialApplyKA[T[_[_], _, _], M[_], A] { + type Apply[B] = T[M, A, B] +} + +trait MA[M[_], A] + +trait MAs { + val a: MA[PartialApplyKA[Kleisli, List, String]#Apply, Int] = null +} + +object Scalaz extends MAs diff --git a/test/files/pos/t2741/2741-2.scala b/test/files/pos/t2741/2741-2.scala new file mode 100644 index 0000000000..41f6a64260 --- /dev/null +++ b/test/files/pos/t2741/2741-2.scala @@ -0,0 +1,5 @@ +// object Test compiles jointly, but not separately. +object Test { + import Scalaz._ + Scalaz.a +}
\ No newline at end of file diff --git a/test/files/pos/t2795.scala b/test/files/pos/t2795.scala index c355a10c54..a4e1b7db83 100644 --- a/test/files/pos/t2795.scala +++ b/test/files/pos/t2795.scala @@ -5,6 +5,7 @@ trait Element[T] { trait Config { type T <: Element[T] + implicit val m: ClassManifest[T] // XXX Following works fine: // type T <: Element[_] } diff --git a/test/files/pos/t2797.scala b/test/files/pos/t2797.scala new file mode 100644 index 0000000000..4323664e91 --- /dev/null +++ b/test/files/pos/t2797.scala @@ -0,0 +1,9 @@ +class MyVector[A] { + def map[B](f: A => B): MyVector[B] = error("") +} + +object Test { + def unzip[B, C](_this: MyVector[(B, C)]): (MyVector[B], MyVector[C]) = { + (_this.map{ bc => bc._1 }, _this.map{ bc => bc._2 }) + } +}
\ No newline at end of file diff --git a/test/files/pos/t2867.scala b/test/files/pos/t2867.scala deleted file mode 100644 index 0434a380b9..0000000000 --- a/test/files/pos/t2867.scala +++ /dev/null @@ -1 +0,0 @@ -case class A(l: List[_]*) diff --git a/test/files/pos/t2868.cmds b/test/files/pos/t2868.cmds new file mode 100644 index 0000000000..ed8124a9e0 --- /dev/null +++ b/test/files/pos/t2868.cmds @@ -0,0 +1,3 @@ +javac Jann.java Nest.java +scalac pick_1.scala +scalac test_2.scala diff --git a/test/files/pos/t2868/Jann.java b/test/files/pos/t2868/Jann.java new file mode 100644 index 0000000000..f5b68de7b0 --- /dev/null +++ b/test/files/pos/t2868/Jann.java @@ -0,0 +1,5 @@ +public @interface Jann { + public String str(); + public Nest inn(); + public int[] arr(); +} diff --git a/test/files/pos/t2868/Nest.java b/test/files/pos/t2868/Nest.java new file mode 100644 index 0000000000..53652291ad --- /dev/null +++ b/test/files/pos/t2868/Nest.java @@ -0,0 +1,3 @@ +public @interface Nest { + public int value(); +} diff --git a/test/files/pos/t2868/pick_1.scala b/test/files/pos/t2868/pick_1.scala new file mode 100644 index 0000000000..e91728ec2f --- /dev/null +++ b/test/files/pos/t2868/pick_1.scala @@ -0,0 +1,7 @@ +class ann(s: String) extends StaticAnnotation +class pick { + final val s = "bang!" + @ann("bang!") def foo = 1 + @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def bar = 2 + @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def baz = 3 +} diff --git a/test/files/pos/t2868/test_2.scala b/test/files/pos/t2868/test_2.scala new file mode 100644 index 0000000000..f11ef0fae2 --- /dev/null +++ b/test/files/pos/t2868/test_2.scala @@ -0,0 +1,6 @@ +class test { + val l = (new pick).s + val u = (new pick).foo + val c = (new pick).bar + val k = (new pick).baz +} diff --git a/test/files/pos/t2913.scala b/test/files/pos/t2913.scala new file mode 100755 index 0000000000..11d8b92053 --- /dev/null +++ b/test/files/pos/t2913.scala @@ -0,0 +1,53 @@ +class A { + def foo(a: Int) = 0 +} + +class RichA { + def foo(a: String) = 0 + def foo(a: String, b: String) = 0 + def foo() = 0 +} + +object Test { + + implicit def AToRichA(a: A) = new RichA + + val a = new A + a.foo() + a.foo(1) + + a.foo("") // Without implicits, a type error regarding invalid argument types is generated at `""`. This is + // the same position as an argument, so the 'second try' typing with an Implicit View is tried, + // and AToRichA(a).foo("") is found. + // + // My reading of the spec "7.3 Views" is that `a.foo` denotes a member of `a`, so the view should + // not be triggered. + // + // But perhaps the implementation was changed to solve See https://lampsvn.epfl.ch/trac/scala/ticket/1756 + + a.foo("a", "b") // Without implicits, a type error regarding invalid arity is generated at `foo(<error>"", "")`. + // Typers#tryTypedApply:3274 only checks if the error is as the same position as `foo`, `"a"`, or `"b"`. + // None of these po +} + +// t0851 is essentially the same: +object test1 { + case class Foo[T,T2](f : (T,T2) => String) extends (((T,T2)) => String){ + def apply(t : T) = (s:T2) => f(t,s) + def apply(p : (T,T2)) = f(p._1,p._2) + } + implicit def g[T](f : (T,String) => String) = Foo(f) + def main(args : Array[String]) : Unit = { + val f = (x:Int,s:String) => s + x + println(f(1)) + () + } +} +object Main { + def main(args : Array[String]) { + val fn = (a : Int, str : String) => "a: " + a + ", str: " + str + implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null) + println(fn(1)) + () + } +} diff --git a/test/files/pos/t294.cmds b/test/files/pos/t294.cmds new file mode 100644 index 0000000000..62c9a5a068 --- /dev/null +++ b/test/files/pos/t294.cmds @@ -0,0 +1,3 @@ +javac Ann.java Ann2.java +scalac Test_1.scala +scalac Test_2.scala diff --git a/test/files/pos/t2940/Cycle.java b/test/files/pos/t2940/Cycle.java new file mode 100644 index 0000000000..eef6c23b5e --- /dev/null +++ b/test/files/pos/t2940/Cycle.java @@ -0,0 +1,3 @@ +public interface Cycle<T extends Cycle<?>> { + void doStuff(); +}
\ No newline at end of file diff --git a/test/files/pos/t2940/Error.scala b/test/files/pos/t2940/Error.scala new file mode 100644 index 0000000000..bf5a6bd0df --- /dev/null +++ b/test/files/pos/t2940/Error.scala @@ -0,0 +1,12 @@ +abstract class Error { + val c: Cycle[_] +} + +object Test { + trait Quux[T] extends Cycle[Quux[T]] + val x = new Quux[Int] { def doStuff() { } } + + def main(args: Array[String]): Unit = { + + } +} diff --git a/test/files/pos/t2956/BeanDefinitionVisitor.java b/test/files/pos/t2956/BeanDefinitionVisitor.java new file mode 100644 index 0000000000..2ff5daa253 --- /dev/null +++ b/test/files/pos/t2956/BeanDefinitionVisitor.java @@ -0,0 +1,6 @@ +import java.util.Map; +public class BeanDefinitionVisitor { + @SuppressWarnings("unchecked") + protected void visitMap(Map<?, ?> mapVal) { + } +} diff --git a/test/files/pos/t2956/t2956.scala b/test/files/pos/t2956/t2956.scala new file mode 100755 index 0000000000..eb6e817465 --- /dev/null +++ b/test/files/pos/t2956/t2956.scala @@ -0,0 +1,7 @@ +import scala.collection.JavaConversions._ + +class Outer { + protected class Inner extends BeanDefinitionVisitor { + protected def visitMap(mapVal: Map[_, _]): Unit = () + } +}
\ No newline at end of file diff --git a/test/files/pos/t2994a.scala b/test/files/pos/t2994a.scala new file mode 100644 index 0000000000..cb4a389e2f --- /dev/null +++ b/test/files/pos/t2994a.scala @@ -0,0 +1,27 @@ +object Naturals { + trait NAT { + type a[s[_ <: NAT] <: NAT, z <: NAT] <: NAT + type v = a[SUCC, ZERO] + } + final class ZERO extends NAT { + type a[s[_ <: NAT] <: NAT, z <: NAT] = z + } + final class SUCC[n <: NAT] extends NAT { + type a[s[_ <: NAT] <: NAT, z <: NAT] = s[n#a[s, z]] + } + type _0 = ZERO + type _1 = SUCC[_0] + type _2 = SUCC[_1] + type _3 = SUCC[_2] + type _4 = SUCC[_3] + type _5 = SUCC[_4] + type _6 = SUCC[_5] + + + // crashes scala-2.8.0 beta1 + trait MUL[n <: NAT, m <: NAT] extends NAT { + trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } + type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] + } + +}
\ No newline at end of file diff --git a/test/files/pos/t2994b.scala b/test/files/pos/t2994b.scala new file mode 100644 index 0000000000..c9d9cc812b --- /dev/null +++ b/test/files/pos/t2994b.scala @@ -0,0 +1,7 @@ +object Test { + trait Bar[X[_]] + trait Baz[S[_] <: Bar[S]] { + type Apply[T] + } + trait Foo[V[_] <: Bar[V]] extends Bar[Baz[V]#Apply] +}
\ No newline at end of file diff --git a/test/files/pos/t3037.scala b/test/files/pos/t3037.scala new file mode 100644 index 0000000000..b71ffe0418 --- /dev/null +++ b/test/files/pos/t3037.scala @@ -0,0 +1,13 @@ +package test + +object A { + println(("a" match { + case "a" => 1 + case _ => "a" + }).asInstanceOf[Object]) + def foo[T](x: T) = x + var x: Int = 1 + var y: Long = 1L + x = foo(x) + y = foo(y) +} diff --git a/test/files/pos/t3071.scala b/test/files/pos/t3071.scala new file mode 100644 index 0000000000..7e14432941 --- /dev/null +++ b/test/files/pos/t3071.scala @@ -0,0 +1,7 @@ +class A (val i: Int) { + def copy (i: Int = this.i): A = new A(i) +} + +class B (val j: Int) extends A(1) { + override def copy (j: Int = this.j): B = new B(j) +} diff --git a/test/files/pos/t3076/C2.scala b/test/files/pos/t3076/C2.scala new file mode 100644 index 0000000000..d08f9ee81d --- /dev/null +++ b/test/files/pos/t3076/C2.scala @@ -0,0 +1,4 @@ +class C2 { + def m1() { new T { } } + def m2() { new T { } } +} diff --git a/test/files/pos/t3076/T.scala b/test/files/pos/t3076/T.scala new file mode 100644 index 0000000000..b710a29343 --- /dev/null +++ b/test/files/pos/t3076/T.scala @@ -0,0 +1,2 @@ +trait T { private val z = new C1 } +private class C1 diff --git a/test/files/pos/t3079.scala b/test/files/pos/t3079.scala new file mode 100644 index 0000000000..fa732ea516 --- /dev/null +++ b/test/files/pos/t3079.scala @@ -0,0 +1,17 @@ +sealed trait Identity[A] { + val value: A +} + +trait Coerce[A, B] { + def unwrap: (A => B) +} + +object Coerce { + def IdentityCoerce[B] = new Coerce[Identity[B], B] { + // java.lang.Error: A in trait Identity cannot be instantiated from ?x$1.type + def unwrap = _.value + + // Providing the type of _ works around the problem. + //def unwrap = (_: Identity[B]).value + } +}
\ No newline at end of file diff --git a/test/files/pos/t3152.scala b/test/files/pos/t3152.scala new file mode 100644 index 0000000000..a20428dbee --- /dev/null +++ b/test/files/pos/t3152.scala @@ -0,0 +1,20 @@ +trait Applicative[M[_]] + +sealed trait MA[M[_], A] { + def sequence[N[_], B](implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = error("stub") + // def sequence3[N[_], B]()(implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = error("stub") +} + +object test { + implicit def ListMA[A](l: List[A]): MA[List, A] = error("stub") + implicit val ao: Applicative[Option] = error("stub") + + /* This compiles OK: + (Nil: List[Option[Int]]).sequence3(): Option[List[Int]] + */ + + // BUG: error: immutable is not an enclosing class + // !!! No line number is reported with the error + (Nil: List[Option[Int]]).sequence: Option[List[Int]] + (List[Option[Int]]()).sequence: Option[List[Int]] +}
\ No newline at end of file diff --git a/test/pending/pos/t425.scala b/test/files/pos/t425.scala index e50c50ac35..e50c50ac35 100644 --- a/test/pending/pos/t425.scala +++ b/test/files/pos/t425.scala diff --git a/test/files/positions/Unsupported2.scala b/test/files/positions/Unsupported2.scala new file mode 100644 index 0000000000..e21df5ef0e --- /dev/null +++ b/test/files/positions/Unsupported2.scala @@ -0,0 +1,5 @@ +object Unsupported2 { + for (k <- 0 until xs.xize) + for(i = 0 until (xs.size)) { + } +} diff --git a/test/files/res/bug687.check b/test/files/res/bug687.check index ee9520d1ea..353101c38b 100644 --- a/test/files/res/bug687.check +++ b/test/files/res/bug687.check @@ -1,11 +1,10 @@ - nsc> -nsc> bug687/QueryB.scala:3: error: name clash between defined and inherited member: +nsc> +bug687/QueryB.scala:3: error: name clash between defined and inherited member: method equals:(o: java.lang.Object)Boolean and method equals:(x$1: Any)Boolean in class Any have same type after erasure: (o: java.lang.Object)Boolean override def equals(o : Object) = false; ^ - nsc> nsc> diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala index 27551b735b..c016d41a90 100644 --- a/test/files/run/Course-2002-13.scala +++ b/test/files/run/Course-2002-13.scala @@ -66,7 +66,7 @@ object Terms { override def toString() = a + (if (ts.isEmpty) "" else ts.mkString("(", ",", ")")); def map(s: Subst): Term = Con(a, ts map (t => t map s)); - def tyvars = (ts flatMap (t => t.tyvars)).removeDuplicates; + def tyvars = (ts flatMap (t => t.tyvars)).distinct; } private var count = 0; @@ -113,7 +113,7 @@ object Programs { case class Clause(lhs: Term, rhs: List[Term]) { def tyvars = - (lhs.tyvars ::: (rhs flatMap (t => t.tyvars))).removeDuplicates; + (lhs.tyvars ::: (rhs flatMap (t => t.tyvars))).distinct; def newInstance = { var s: Subst = List(); for (val a <- tyvars) { s = Binding(a, newVar(a)) :: s } diff --git a/test/files/run/ReplacementMatching.scala b/test/files/run/ReplacementMatching.scala new file mode 100644 index 0000000000..05040d98a3 --- /dev/null +++ b/test/files/run/ReplacementMatching.scala @@ -0,0 +1,47 @@ + + + +import util.matching._ + + + + +object Test { + + def main(args: Array[String]) { + replacementMatching + groupsMatching + } + + def replacementMatching { + val regex = """\$\{(.+?)\}""".r + val replaced = regex.replaceAllIn("Replacing: ${main}. And another method: ${foo}.", + (m: util.matching.Regex.Match) => { + val identifier = m.group(1) + identifier + }) + assert(replaced == "Replacing: main. And another method: foo.") + + val regex3 = """\$\{(.+?)\}""".r + val replaced3 = regex3.replaceSomeIn("Replacing: ${main}. And another: ${foo}.", (m: util.matching.Regex.Match) => { + val id = m.group(1) + if (id.startsWith("m")) Some(id) else None + }) + assert(replaced3 == "Replacing: main. And another: ${foo}.") + } + + def groupsMatching { + val Date = """(\d+)/(\d+)/(\d+)""".r + for (Regex.Groups(a, b, c) <- Date findFirstMatchIn "1/1/2001 marks the start of the millenium. 31/12/2000 doesn't.") { + assert(a == "1") + assert(b == "1") + assert(c == "2001") + } + for (Regex.Groups(a, b, c) <- (Date findAllIn "1/1/2001 marks the start of the millenium. 31/12/2000 doesn't.").matchData) { + assert(a == "1" || a == "31") + assert(b == "1" || b == "12") + assert(c == "2001" || c == "2000") + } + } + +} diff --git a/test/files/run/arraycopy.scala b/test/files/run/arraycopy.scala new file mode 100644 index 0000000000..bb06200dc7 --- /dev/null +++ b/test/files/run/arraycopy.scala @@ -0,0 +1,31 @@ + + +object Test { + def main(args: Array[String]) { + val a = new Array[Int](10) + val b = new Array[Any](10) + for (i <- 0 until 10) b(i) = i + + Array.copy(b, 3, a, 3, 7) + assert(a.toSeq == List(0, 0, 0, 3, 4, 5, 6, 7, 8, 9)) + } +} + + + + + + + + + + + + + + + + + + + diff --git a/test/files/run/arybufgrow.scala b/test/files/run/arybufgrow.scala index 4dccd962f2..9e18435243 100644 --- a/test/files/run/arybufgrow.scala +++ b/test/files/run/arybufgrow.scala @@ -2,8 +2,8 @@ import scala.collection.mutable._; object Test extends Application { val buf = new ArrayBuffer[String]; - for(val i <- List.range(0,1000)) { - buf + "hello"; + for (i <- List.range(0,1000)) { + buf += "hello"; } Console.println("1000 = " + buf.length); diff --git a/test/files/run/bigDecimalCache.scala b/test/files/run/bigDecimalCache.scala new file mode 100644 index 0000000000..c0c709a50f --- /dev/null +++ b/test/files/run/bigDecimalCache.scala @@ -0,0 +1,9 @@ +object Test { + def main(args: Array[String]): Unit = { + val bd5a = BigDecimal(5) + val mc = java.math.MathContext.DECIMAL32 + val bd5b = BigDecimal(5,mc) + + assert(bd5b.mc == mc) + } +} diff --git a/test/files/run/bug1074.check b/test/files/run/bug1074.check index ecff8510ed..ccf1cb1551 100644 --- a/test/files/run/bug1074.check +++ b/test/files/run/bug1074.check @@ -1,3 +1,3 @@ -q0 = Set(kl, jk, cd, fg, a, ef, gh, de, hj, b, lm, mn) +q0 = Set(kl, jk, cd, fg, ef, gh, a, de, hj, b, lm, mn) q1 = Set() 0 q2 = Set() 0 diff --git a/test/files/run/bug3126.scala b/test/files/run/bug3126.scala new file mode 100644 index 0000000000..36322bf896 --- /dev/null +++ b/test/files/run/bug3126.scala @@ -0,0 +1,9 @@ +object Test { + case class C(x: Int) + val v: Some[Int] = null + + def main(args: Array[String]): Unit = { + try C.unapply(null) catch { case _: MatchError => } + try v match { case Some(1) => } catch { case _: MatchError => } + } +} diff --git a/test/files/run/bug3175.check b/test/files/run/bug3175.check new file mode 100644 index 0000000000..12246140f4 --- /dev/null +++ b/test/files/run/bug3175.check @@ -0,0 +1,11 @@ +10 +15 +3 +3 +3 +5 +5 +5 +100 +jabooboo +hi mom diff --git a/test/files/run/bug3175.scala b/test/files/run/bug3175.scala new file mode 100644 index 0000000000..78660d4085 --- /dev/null +++ b/test/files/run/bug3175.scala @@ -0,0 +1,55 @@ +/** A bit down the road this test will examine + * the bytecode. + */ +object Test { + def len(x:{ def length: Int }) = x.length + def f1(x:{ def apply(x: Int): Long }) = x(0) + def f2(x:{ def apply(x: Int): Byte }) = x(0) + def f3(x:{ def apply(x: Int): String }) = x(0).length + + def f4(x:{ def update(x: Int, y: Long): Unit }, y: Long) = x(0) = y + def f5(x:{ def update(x: Int, y: Byte): Unit }, y: Byte) = x(0) = y + def f6(x:{ def update(x: Int, y: String): Unit }, y: String) = x(0) = y + + def f7(x: { def length: Any }) = x.length + + def f8(x: { def apply(x: Int): Any }) = x(0) + def f9(x: { def apply(x: Int): Int }) = x(0) + def f10(x: { def apply(x: Int): Long }) = x(0) + + // update has some interesting special cases + def f11(x:{ def update(x: Int, y: Long): Any }, y: Long) = x(0) = y + def f12(x:{ def update(x: Int, y: String): AnyVal }, y: String) = x(0) = y + def f13(x:{ def update(x: Int, y: String): AnyRef }, y: String) = x(0) = y + + // doesn't work yet, see #3197 + // def fclone(x:{ def clone(): AnyRef }) = x.clone() + + def main(args: Array[String]): Unit = { + val longs = Array(5L) + val bytes = Array(5: Byte) + val strs = Array("abcde", "fghjij") + + println(len(Array(1,2,3)) + len(Array(4.0,5.0f)) + len(Array("abc", 5)) + len("bop")) + println(f1(longs) + f2(bytes) + f3(strs)) + + f4(longs, 1) + f5(bytes, 1) + f6(strs, "a") + + println(f1(longs) + f2(bytes) + f3(strs)) + + println(f7(Array(1,2,3))) + println(f7("def")) + + println(f8(Array(5))) + println(f9(Array(5))) + println(f10(Array(5))) + + f11(longs, 100L) + f12(strs, "jabooboo") + println(longs(0)) + println(strs(0)) + f13(new { def update(x: Int, y: String): List[Int] = { println("hi mom") ; Nil } }, "irrelevant") + } +} diff --git a/test/files/run/bug594.scala b/test/files/run/bug594.scala index 0c3be3d5de..f923a3cd2a 100644 --- a/test/files/run/bug594.scala +++ b/test/files/run/bug594.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { val array = Array("one", "two", "three") val firstTwo: Array[String] = array.slice(0,2) - for(val x <- firstTwo) + for (x <- firstTwo) Console.println(x) } } diff --git a/test/files/run/bug751.scala b/test/files/run/bug751.scala new file mode 100644 index 0000000000..294d3af5c2 --- /dev/null +++ b/test/files/run/bug751.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + val map = Map(1 -> "a", 2 -> "b", 3 -> "c") + assert(map.filterKeys(_ % 2 == 0).isInstanceOf[scala.collection.immutable.Map[_,_]]) + } +} diff --git a/test/files/run/bytecodecs.scala b/test/files/run/bytecodecs.scala new file mode 100644 index 0000000000..bf8a0f8ed3 --- /dev/null +++ b/test/files/run/bytecodecs.scala @@ -0,0 +1,39 @@ +import scala.reflect.generic.ByteCodecs._ + +object Test { + + def test8to7(xs: Array[Byte]) { + val ys = encode8to7(xs) + decode7to8(ys, ys.length) + assert(ys.take(xs.length).deep == xs.deep, + "test8to7("+xs.deep+") failed, result = "+ys.take(xs.length).deep) + } + + def testAll(xs: Array[Byte]) { + val ys = encode(xs) + decode(ys) + assert(ys.take(xs.length).deep == xs.deep, + "testAll("+xs.deep+") failed, result = "+ys.take(xs.length).deep) + } + + def test(inputs: Array[Byte]*) { + for (input <- inputs) { + test8to7(input) + testAll(input) + } + } + + def main(args: Array[String]) { + test( + Array(1, 2, 3), + Array(1, 2, 3, 4, 5, 6, 7), + Array(1, -2, 0, -3, -5, -6, -7), + Array(1, 3, -1, -128, 0, 0, -128, 1, 2, 3)) + val rand = new scala.util.Random() + for (i <- 1 until 5000) { + var xs = new Array[Byte](i) + rand.nextBytes(xs) + test(xs) + } + } +} diff --git a/test/files/run/caseClassEquality.scala b/test/files/run/caseClassEquality.scala new file mode 100644 index 0000000000..c11d7ad0d1 --- /dev/null +++ b/test/files/run/caseClassEquality.scala @@ -0,0 +1,36 @@ +object Test { + abstract class A1 + case class C1(x: Int) extends A1 + class C2(x: Int) extends C1(x) { + override def productPrefix = "Shazbot!" + } + class C3(x: Int) extends C1(x) { + override def canEqual(other: Any) = other.isInstanceOf[C3] + override def equals(other: Any) = other match { + case ob: C3 => x == ob.x + case _ => false + } + } + + case class CS1(xs: Any*) + class CS2(xs: Seq[_]*) extends CS1(xs: _*) + class CS3(xs: IndexedSeq[Int]*) extends CS2(xs: _*) + + case class H1(x: Int, y: Double) + class H2(x: Double, y: Int) extends H1(y, x) + + def main(args: Array[String]): Unit = { + assert(C1(5) == new C2(5)) + assert(new C2(5) == C1(5)) + assert(C1(5).hashCode == new C2(5).hashCode) + assert(new C2(5).hashCode == C1(5).hashCode) + + assert(C1(5) != new C3(5)) + assert(new C3(5) != C1(5)) + + assert(CS1(List(1d,2d), Seq[Float](3f, 4f)) == new CS3(IndexedSeq(1,2), IndexedSeq(3, 4))) + + assert(H1(5, 10d) == new H2(10d, 5)) + assert(H1(5, 10d).hashCode == new H2(10d, 5).hashCode) + } +} diff --git a/test/files/run/colltest1.check b/test/files/run/colltest1.check index b49d328be4..7377174281 100644 --- a/test/files/run/colltest1.check +++ b/test/files/run/colltest1.check @@ -72,11 +72,11 @@ new test starting with List() 9: List(2, 3, 4, 5, 6, 7, 8, 9, 10) 1 List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) -new test starting with IndexedSeq() -10: IndexedSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) -9: IndexedSeq(2, 3, 4, 5, 6, 7, 8, 9, 10) +new test starting with Vector() +10: Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) +9: Vector(2, 3, 4, 5, 6, 7, 8, 9, 10) 1 -IndexedSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) +Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) new test starting with Vector() 10: Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) 9: Vector(2, 3, 4, 5, 6, 7, 8, 9, 10) @@ -95,15 +95,15 @@ ArrayBuffer(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) true false true -Map(O -> O, W -> W, H -> H, P -> P, G -> G, V -> V, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(O -> O, W -> W, H -> H, P -> P, G -> G, V -> V, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(O -> O, W -> W, H -> H, P -> P, V -> V, G -> G, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(O -> O, W -> W, H -> H, P -> P, V -> V, G -> G, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(O -> O, W -> W, H -> H, P -> P, G -> G, V -> V, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(O -> O, W -> W, H -> H, P -> P, G -> G, V -> V, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(A -> A, B -> B, C -> C, D -> D, E -> E, F -> F, G -> G, H -> H, I -> I, J -> J, K -> K, L -> L, M -> M, N -> N, O -> O, P -> P, Q -> Q, R -> R, S -> S, T -> T, U -> U, V -> V, W -> W, X -> X, Y -> Y, Z -> Z) -Map(A -> A, B -> B, C -> C, D -> D, E -> E, F -> F, G -> G, H -> H, I -> I, J -> J, K -> K, L -> L, M -> M, N -> N, O -> O, P -> P, Q -> Q, R -> R, S -> S, T -> T, U -> U, V -> V, W -> W, X -> X, Y -> Y, Z -> Z) -Map(O -> O, W -> W, H -> H, P -> P, V -> V, G -> G, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(O -> O, W -> W, H -> H, P -> P, V -> V, G -> G, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(O -> O, W -> W, H -> H, P -> P, G -> G, V -> V, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) -Map(O -> O, W -> W, H -> H, P -> P, G -> G, V -> V, I -> I, A -> A, F -> F, U -> U, N -> N, X -> X, Z -> Z, S -> S, D -> D, K -> K, R -> R, C -> C, B -> B, L -> L, Q -> Q, M -> M, J -> J, Y -> Y, T -> T, E -> E) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala index f12c234f74..557282cb8d 100644 --- a/test/files/run/colltest1.scala +++ b/test/files/run/colltest1.scala @@ -80,7 +80,7 @@ object Test extends Application { val tenPlus = ten map (_ + 1) assert((ten zip tenPlus) forall { case (x, y) => x + 1 == y }) val dble = ten flatMap (x => List(x, x)) - assert(dble.removeDuplicates == ten) + assert(dble.distinct == ten) assert(ten.length == 10) assert(ten(0) == 1 && ten(9) == 10) assert((ten lengthCompare 10) == 0 && (ten lengthCompare 1) > 0 && (ten lengthCompare 11) < 0) @@ -122,7 +122,7 @@ object Test extends Application { assert((ten diff (ten filter (_ % 2 == 0))) == (ten filterNot (_ % 2 == 0))) assert((ten intersect ten) == ten) assert((ten intersect List(5)) == List(5)) - assert((ten ++ ten).removeDuplicates == ten) + assert((ten ++ ten).distinct == ten) assert(ten.patch(3, List(4, 5, 6, 7), 4) == ten) assert(ten.patch(0, List(1, 2, 3), 9) == List(1, 2, 3, 10)) assert(empty.padTo(10, 7) == Array.fill(10)(7).toSeq) @@ -170,7 +170,7 @@ object Test extends Application { m += (("D" -> "D"), ("E" -> "E"), ("F" -> "F")) m ++= List(("G" -> "G"), ("H" -> "H"), ("I" -> "I")) m ++= ('J' to 'Z') map (x => (x.toString -> x.toString)) - println(m) + println(m.toList.sorted) assert(!m.isEmpty) assert(m.keySet forall (k => (m get k) == Some(k))) assert(m.keySet forall (k => (m apply k) == k)) @@ -185,7 +185,7 @@ object Test extends Application { assert(mm.isEmpty, mm) def m3 = empty ++ m1 assert(m1 == m3) - println(m3) + println(m3.toList.sorted) val m4 = m3 filterNot { case (k, v) => k != "A" } assert(m4.size == 1, m4) } diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index f18ff6e3c9..cc00a7c46b 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -121,7 +121,7 @@ y: java.lang.String = hello ----- val x = 3 : Int @Annot(e+f+g+h) //should have a graceful error message -<console>:5: error: not found: value e +<console>:6: error: not found: value e val x = 3 : Int @Annot(e+f+g+h) //should have a graceful error message ^ diff --git a/test/files/run/elidable.check b/test/files/run/elidable.check new file mode 100644 index 0000000000..4ce04f0040 --- /dev/null +++ b/test/files/run/elidable.check @@ -0,0 +1 @@ +Good for me, I was not elided. diff --git a/test/files/run/elidable.flags b/test/files/run/elidable.flags new file mode 100644 index 0000000000..93fd3d5317 --- /dev/null +++ b/test/files/run/elidable.flags @@ -0,0 +1 @@ +-Xelide-below 900 diff --git a/test/files/run/elidable.scala b/test/files/run/elidable.scala new file mode 100644 index 0000000000..2a527efc4b --- /dev/null +++ b/test/files/run/elidable.scala @@ -0,0 +1,16 @@ +import annotation._ +import elidable._ + +object Test { + @elidable(FINEST) def f1() = assert(false, "Should have been elided.") + @elidable(INFO) def f2() = assert(false, "Should have been elided.") + @elidable(SEVERE) def f3() = println("Good for me, I was not elided.") + @elidable(INFO) def f4 = assert(false, "Should have been elided (no parens).") + + def main(args: Array[String]): Unit = { + f1() + f2() + f3() + f4 + } +} diff --git a/test/files/run/equality.scala b/test/files/run/equality.scala index 5b9ad207da..6498b232e1 100644 --- a/test/files/run/equality.scala +++ b/test/files/run/equality.scala @@ -1,6 +1,8 @@ // a quickly assembled test of equality. Needs work. object Test { + import scala.runtime.ScalaRunTime.hash + def makeFromInt(x: Int) = List( x.toByte, x.toShort, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x) ) ::: ( diff --git a/test/files/run/hashCodeBoxesRunTime.scala b/test/files/run/hashCodeBoxesRunTime.scala index 3eacacb663..ba1a30f5fb 100644 --- a/test/files/run/hashCodeBoxesRunTime.scala +++ b/test/files/run/hashCodeBoxesRunTime.scala @@ -5,7 +5,7 @@ object Test import java.{ lang => jl } import scala.runtime.BoxesRunTime.{ hashFromNumber, hashFromObject } - def allSame[T](xs: List[T]) = assert(xs.removeDuplicates.size == 1, "failed: " + xs) + def allSame[T](xs: List[T]) = assert(xs.distinct.size == 1, "failed: " + xs) def mkNumbers(x: Int): List[Number] = List(x.toByte, x.toShort, x, x.toLong, x.toFloat, x.toDouble) diff --git a/test/files/run/hashCodeDistribution.scala b/test/files/run/hashCodeDistribution.scala index dbb6e833bd..5be9d1db6d 100644 --- a/test/files/run/hashCodeDistribution.scala +++ b/test/files/run/hashCodeDistribution.scala @@ -8,7 +8,7 @@ object Test { val hashCodes = for (x <- 0 until COUNT; y <- 0 until COUNT) yield C(x,y).hashCode - val uniques = hashCodes.removeDuplicates + val uniques = hashCodes.distinct val collisionRate = (totalCodes - uniques.size) * 1000 / totalCodes assert(collisionRate < 5, "Collision rate too high: %d / 1000".format(collisionRate)) diff --git a/test/files/run/hashhash.scala b/test/files/run/hashhash.scala new file mode 100644 index 0000000000..4a34ab12e0 --- /dev/null +++ b/test/files/run/hashhash.scala @@ -0,0 +1,15 @@ +object Test +{ + class A { val x1 = this.## ; val x2 = super.## } + val myA = new A + assert(myA.x1 == myA.x2) + + def confirmSame(x: Any) = assert(x.## == x.hashCode, "%s.## != %s.hashCode".format(x, x)) + def confirmDifferent(x: Any) = assert(x.## != x.hashCode, "%s.## == %s.hashCode (but should not)".format(x, x)) + + def main(args: Array[String]): Unit = { + /** Just a little sanity check, not to be confused with a unit test. */ + List(5, 5.5f, "abc", new AnyRef, new A, ()) foreach confirmSame + List(5.0f, 1.0d, -(5.0f), (-1.0d)) foreach confirmDifferent + } +} diff --git a/test/files/run/iterators.check b/test/files/run/iterators.check index cd1b79144a..bb139c1610 100644 --- a/test/files/run/iterators.check +++ b/test/files/run/iterators.check @@ -7,7 +7,7 @@ test check_drop was successful test check_foreach was successful test check_forall was successful test check_fromArray was successful -test check_collect was successful +test check_toSeq was successful test check_indexOf was successful test check_findIndexOf was successful diff --git a/test/files/run/iterators.scala b/test/files/run/iterators.scala index 5879d38df3..5f77289343 100644 --- a/test/files/run/iterators.scala +++ b/test/files/run/iterators.scala @@ -83,8 +83,8 @@ object Test { xs0.length + xs1.length + xs2.length + xs3.length + xs4.length } - def check_collect: String = - List(1, 2, 3, 4, 5).iterator.collect.mkString("x") + def check_toSeq: String = + List(1, 2, 3, 4, 5).iterator.toSeq.mkString("x") def check_indexOf: String = { val i = List(1, 2, 3, 4, 5).indexOf(4) @@ -93,8 +93,8 @@ object Test { } def check_findIndexOf: String = { - val i = List(1, 2, 3, 4, 5).findIndexOf { x: Int => x >= 4 } - val j = List(1, 2, 3, 4, 5).findIndexOf { x: Int => x >= 16 } + val i = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 4 } + val j = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 16 } "" + i + "x" + j } @@ -124,7 +124,7 @@ object Test { check_success("check_foreach", check_foreach, 190) check_success("check_forall", check_forall, 0) check_success("check_fromArray",check_fromArray, 14) - check_success("check_collect", check_collect, "1x2x3x4x5") + check_success("check_toSeq", check_toSeq, "1x2x3x4x5") check_success("check_indexOf", check_indexOf, "3x-1") check_success("check_findIndexOf", check_findIndexOf, "3x-1") println() diff --git a/test/files/run/lists.scala b/test/files/run/lists.scala index 695d5a0336..6c9b55961e 100644 --- a/test/files/run/lists.scala +++ b/test/files/run/lists.scala @@ -126,8 +126,8 @@ object Test1 extends TestCase("ctor") with Assert { assertEquals("check_forall", true, b1 & b2) } { - val ys1 = xs1 remove { e => e % 2 != 0 } - val ys2 = xs4 remove { e => e < 5 } + val ys1 = xs1 filterNot { e => e % 2 != 0 } + val ys2 = xs4 filterNot { e => e < 5 } assertEquals("check_remove", 3, ys1.length + ys2.length) } { diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check index 47d09a5083..60c7637e3d 100644 --- a/test/files/run/names-defaults.check +++ b/test/files/run/names-defaults.check @@ -81,6 +81,7 @@ get: 20 get: 20 20 0 +1 dlkfj0dlkfj102 lskf2dkflj2 dlkd5nixda10nixdadklfj1dklfj @@ -119,3 +120,4 @@ klfj1 blublu1 my text List(1, 2) +3 diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 121ddcb3bc..8557047875 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -135,6 +135,10 @@ object Test extends Application { println(bn4()) println(bn4(a = 0)) + class t2929(x: => Int = 1) { + def foo = x + } + println((new t2929()).foo) // constructors val a1 = new A(b = "dlkfj")(d = 102) @@ -252,6 +256,9 @@ object Test extends Application { def test11[T[P]](x: T[T[List[T[X forSome { type X }]]]] = List(1,2)) = x // (cannot call f using the default, List(1,2) doesn't match the param type) + def multinest = { def bar(x: Int = 1) = { def bar(x: Int = 2) = x; bar() + x }; bar() } + println(multinest) + // #2290 def spawn(a: Int, b: => Unit) = { () } @@ -289,6 +296,14 @@ object Test extends Application { class C extends A } + object t3178 { + def foo(x: String) = x + def foo(x: Int) = x + def bar(foo: Int) = foo + bar(foo = 1) + } + + // DEFINITIONS def test1(a: Int, b: String) = println(a +": "+ b) def test2(u: Int, v: Int)(k: String, l: Int) = println(l +": "+ k +", "+ (u + v)) diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check new file mode 100644 index 0000000000..82118f8ece --- /dev/null +++ b/test/files/run/programmatic-main.check @@ -0,0 +1,26 @@ +parser +namer +packageobjects +typer +superaccessors +pickler +refchecks +selectiveanf +liftcode +selectivecps +uncurry +tailcalls +explicitouter +erasure +lazyvals +lambdalift +constructors +flatten +mixin +cleanup +icode +inliner +closelim +dce +jvm +terminal diff --git a/test/files/run/programmatic-main.scala b/test/files/run/programmatic-main.scala new file mode 100644 index 0000000000..9c7d0b7095 --- /dev/null +++ b/test/files/run/programmatic-main.scala @@ -0,0 +1,12 @@ +import scala.tools.nsc._ +import io.Path + +object Test { + val cwd = Option(System.getProperty("partest.cwd")) getOrElse "." + val basedir = Path(cwd).parent / "lib" path + val baseargs = Array("-usejavacp", "-bootclasspath", basedir + "/scala-library.jar", "-cp", basedir + "/scala-compiler.jar") + + def main(args: Array[String]): Unit = { + Main process (baseargs ++ Array("-Xshow-phases")) + } +} diff --git a/test/files/run/range.scala b/test/files/run/range.scala index 65d33a6134..02b48fad7c 100644 --- a/test/files/run/range.scala +++ b/test/files/run/range.scala @@ -44,6 +44,9 @@ object Test { assert(NumericRange.inclusive(1, 10, 1) sameElements (1 to 10)) assert(NumericRange.inclusive(1, 100, 3) sameElements (1 to 100 by 3)) + // #2518 + assert((3L to 7 by 2) sameElements List(3L, 5L, 7L)) + rangeForeach(1 to 10); rangeForeach(1 until 10); rangeForeach(10 to 1 by -1); diff --git a/test/files/run/regularpatmat.check b/test/files/run/regularpatmat.check deleted file mode 100644 index 3417d9a98a..0000000000 --- a/test/files/run/regularpatmat.check +++ /dev/null @@ -1,126 +0,0 @@ -pretest -passed ok -testWR_1 -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testWR_2 -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testWR_3 -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testWR_4 -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testWR_5 -passed ok -passed ok -passed ok -testWR_6 -passed ok -passed ok -testWR_7 -passed ok -testWR_8 -passed ok -testWS -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testWT -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testWV -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testBK -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testBM -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -BN preTest: true -testBN -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testBO -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -testMZ - bugs #132 #133b #180 #195 #196 #398 #406 #441 -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok -passed ok diff --git a/test/files/run/spec-absfun.flags b/test/files/run/spec-absfun.flags new file mode 100644 index 0000000000..3a910a936c --- /dev/null +++ b/test/files/run/spec-absfun.flags @@ -0,0 +1 @@ +-Yspecialize
\ No newline at end of file diff --git a/test/files/run/spec-absfun.scala b/test/files/run/spec-absfun.scala new file mode 100644 index 0000000000..ab16e8febc --- /dev/null +++ b/test/files/run/spec-absfun.scala @@ -0,0 +1,43 @@ + +/** Test inheritance. See #3085. + * Anonymous functions extend AbstractFunction1[SpecializedPair[Int], Unit]. The + * specialized type SpecializedPair$mcI$sp should not leak into the superclass because + * the definition of apply would vary covariantly, and erasure won't consider it an + * override of the abstract apply, leading to an AbstractMethodError at runtime. + */ + +object Test { + + private val Max = 1000 + + def main(args: Array[String]) { + notSpecialized() + specialized() + } + + def notSpecialized() { + val pairs = for { i <- 1 to Max; j <- 1 to i } yield new Pair(i, j) + val time0 = System.nanoTime + pairs foreach { p => p.first * p.second } + val time1 = System.nanoTime +// println(time1 - time0) + } + + def specialized() { + val pairs = for { i <- 1 to Max; j <- 1 to i } yield new SpecializedPair(i, j) + val time0 = System.nanoTime + pairs foreach { p => p.first * p.second } + val time1 = System.nanoTime +// println(time1 - time0) + } +} + +class Pair[A](_first: A, _second: A) { + def first = _first + def second = _second +} + +class SpecializedPair[@specialized("Int") A](_first: A, _second: A) { + def first = _first + def second = _second +} diff --git a/test/files/run/spec-matrix.check b/test/files/run/spec-matrix.check new file mode 100644 index 0000000000..72e8ffc0db --- /dev/null +++ b/test/files/run/spec-matrix.check @@ -0,0 +1 @@ +* diff --git a/test/files/run/spec-matrix.flags b/test/files/run/spec-matrix.flags new file mode 100644 index 0000000000..3a910a936c --- /dev/null +++ b/test/files/run/spec-matrix.flags @@ -0,0 +1 @@ +-Yspecialize
\ No newline at end of file diff --git a/test/files/run/spec-matrix.scala b/test/files/run/spec-matrix.scala new file mode 100644 index 0000000000..212a800672 --- /dev/null +++ b/test/files/run/spec-matrix.scala @@ -0,0 +1,70 @@ +/** Test matrix multiplication with specialization. + */ + +class Matrix[@specialized A: ClassManifest](val rows: Int, val cols: Int) { + private val arr: Array[Array[A]] = new Array[Array[A]](rows, cols) + + def apply(i: Int, j: Int): A = { + if (i < 0 || i >= rows || j < 0 || j >= cols) + throw new NoSuchElementException("Indexes out of bounds: " + (i, j)) + + arr(i)(j) + } + + def update(i: Int, j: Int, e: A) { + arr(i)(j) = e + } + + def rowsIterator: Iterator[Array[A]] = new Iterator[Array[A]] { + var idx = 0; + def hasNext = idx < rows + def next = { + idx += 1 + arr(idx - 1) + } + } +} + +object Test { + def main(args: Array[String]) { + val m = randomMatrix(200, 100) + val n = randomMatrix(100, 200) + + mult(m, n) + println("*") + } + + def randomMatrix(n: Int, m: Int) = { + val r = new util.Random(10) + val x = new Matrix[Int](n, m) + for (i <- 0 until n; j <- 0 until m) + x(i, j) = r.nextInt + x + } + + + def multManifest[@specialized("Int") T](m: Matrix[T], n: Matrix[T])(implicit cm: ClassManifest[T], num: Numeric[T]) { + val p = new Matrix[T](m.rows, n.cols) + import num._ + + for (i <- 0 until m.rows) + for (j <- 0 until n.cols) { + var sum = num.zero + for (k <- 0 until n.rows) + sum += m(i, k) * n(k, j) + p(i, j) = sum + } + } + + def mult(m: Matrix[Int], n: Matrix[Int]) { + val p = new Matrix[Int](m.rows, n.cols) + + for (i <- 0 until m.rows) + for (j <- 0 until n.cols) { + var sum = 0 + for (k <- 0 until n.rows) + sum += m(i, k) * n(k, j) + p(i, j) = sum + } + } +} diff --git a/test/files/run/spec-patmatch.check b/test/files/run/spec-patmatch.check new file mode 100644 index 0000000000..a6679fa1c7 --- /dev/null +++ b/test/files/run/spec-patmatch.check @@ -0,0 +1,19 @@ +bool +byte +short +char +int +long +double +float +default +object instantiations: +bool +byte +short +char +int +long +double +float +default diff --git a/test/files/run/spec-patmatch.flags b/test/files/run/spec-patmatch.flags new file mode 100644 index 0000000000..3a910a936c --- /dev/null +++ b/test/files/run/spec-patmatch.flags @@ -0,0 +1 @@ +-Yspecialize
\ No newline at end of file diff --git a/test/files/run/spec-patmatch.scala b/test/files/run/spec-patmatch.scala new file mode 100644 index 0000000000..92938836d8 --- /dev/null +++ b/test/files/run/spec-patmatch.scala @@ -0,0 +1,52 @@ +class Foo[@specialized A] { + def test(x: A) = println(x match { + case _: Boolean => "bool" + case _: Byte => "byte" + case _: Short => "short" + case _: Char => "char" + case i: Int => "int" + case l: Long => "long" + case d: Double => "double" + case e: Float => "float" + case _ => "default" + }) +} + +object Test { + def test[@specialized A] (x: A) = println(x match { + case _: Boolean => "bool" + case _: Byte => "byte" + case _: Short => "short" + case _: Char => "char" + case i: Int => "int" + case l: Long => "long" + case d: Double => "double" + case e: Float => "float" + case _ => "default" + }) + + def main(args: Array[String]) { + test(true) + test(42.toByte) + test(42.toShort) + test('b') + test(42) + test(42l) + test(42.0) + test(42.0f) + test(new Object) + + println("object instantiations:") + (new Foo).test(true) + (new Foo).test(42.toByte) + (new Foo).test(42.toShort) + (new Foo).test('b') + (new Foo).test(42) + (new Foo).test(42l) + (new Foo).test(42.0) + (new Foo).test(42.0f) + (new Foo).test(new Object) + + } + +} diff --git a/test/files/run/t0017.check b/test/files/run/t0017.check index 86c5fe56a8..3a72142467 100644 --- a/test/files/run/t0017.check +++ b/test/files/run/t0017.check @@ -1 +1 @@ -Array(GenericArray(1, 3), GenericArray(2, 4)) +Array(ArraySeq(1, 3), ArraySeq(2, 4)) diff --git a/test/files/run/t0528.scala b/test/files/run/t0528.scala index 5a4755c947..df6d13a17a 100644 --- a/test/files/run/t0528.scala +++ b/test/files/run/t0528.scala @@ -3,7 +3,7 @@ trait Sequ[A] { } class RichStr extends Sequ[Char] { - // override to a primitve array + // override to a primitive array def toArray: Array[Char] = Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') } diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala index de79b84e75..ce6278cd05 100644 --- a/test/files/run/t1500.scala +++ b/test/files/run/t1500.scala @@ -18,10 +18,10 @@ object Test { def main(args: Array[String]) = { - val tool = new Interpreter(new Settings()) + val settings = new Settings() + settings.classpath.value = System.getProperty("java.class.path") + val tool = new Interpreter(settings) val global = tool.compiler - // when running that compiler, give it a scala-library to the classpath - global.settings.classpath.value = System.getProperty("java.class.path") import global._ import definitions._ diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala index 851daae0bb..f1eb8f287d 100644 --- a/test/files/run/t1501.scala +++ b/test/files/run/t1501.scala @@ -28,12 +28,10 @@ object Test { </code>.text def main(args: Array[String]) = { - - val tool = new Interpreter(new Settings()) + val settings = new Settings() + settings.classpath.value = System.getProperty("java.class.path") + val tool = new Interpreter(settings) val global = tool.compiler - // when running that compiler, give it a scala-library to the classpath - global.settings.classpath.value = System.getProperty("java.class.path") - import global._ import definitions._ diff --git a/test/files/run/t1773.scala b/test/files/run/t1773.scala index 81c6005f86..4a4aaba1f0 100644 --- a/test/files/run/t1773.scala +++ b/test/files/run/t1773.scala @@ -8,5 +8,5 @@ object Test extends Application <a>{ if (true) "" else "I like turtles" }</a> ) - for (x1 <- xs; x2 <- xs) assert (x1 == x2) + for (x1 <- xs; x2 <- xs) assert (x1 xml_== x2) } diff --git a/test/files/run/t2074.scala b/test/files/run/t2074.scala deleted file mode 100644 index 60646be733..0000000000 --- a/test/files/run/t2074.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends Application { - List.range(1,11).view.patch(5, List(100,101), 2) -} diff --git a/test/files/run/t2074_2.check b/test/files/run/t2074_2.check index eb1f072de3..e4fc89b1ce 100644 --- a/test/files/run/t2074_2.check +++ b/test/files/run/t2074_2.check @@ -1,3 +1,3 @@ -IndexedSeqView(1, 2, 3) -IndexedSeqView(1, 2, 3) -IndexedSeqViewZ((1,1), (2,2), (3,3)) +SeqView(1, 2, 3) +SeqView(1, 2, 3) +SeqViewZ(...) diff --git a/test/files/run/t2074_2.scala b/test/files/run/t2074_2.scala index 7d1d8181d8..4624170f89 100644 --- a/test/files/run/t2074_2.scala +++ b/test/files/run/t2074_2.scala @@ -1,12 +1,15 @@ // replaced all occurrences of 'Vector' with 'IndexedSeq' import scala.collection.immutable.IndexedSeq -import scala.collection.IndexedSeqView +import scala.collection.SeqView object Test { - val v = new IndexedSeqView[Int, IndexedSeq[Int]] { + val funWithCCE = List.range(1,11).view.patch(5, List(100,101), 2) + + val v = new SeqView[Int, IndexedSeq[Int]] { def underlying = IndexedSeq(1,2,3) def apply(idx: Int) = underlying(idx) def length = underlying.length + def iterator = underlying.iterator } val w = IndexedSeq(1, 2, 3).view diff --git a/test/files/run/t2212.scala b/test/files/run/t2212.scala new file mode 100644 index 0000000000..b9c0cd776b --- /dev/null +++ b/test/files/run/t2212.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]) { + import collection.mutable._ + val x4 = LinkedList[Int](1) + println(x4) + val y4 = LinkedList[Int](1) + println(y4) + println(x4 equals y4) // or (y4 equals x4) + } +} diff --git a/test/files/run/t2417.check b/test/files/run/t2417.check new file mode 100644 index 0000000000..36c954be24 --- /dev/null +++ b/test/files/run/t2417.check @@ -0,0 +1,12 @@ +testing small Map that doesn't promote to HashMap... + +testing single-threaded HashMap use... + +testing HashMap.size from multiple threads... + +testing small Set that doesn't promote to HashSet... + +testing single-threaded HashSet use... + +testing HashSet.size from multiple threads... + diff --git a/test/files/run/t2417.scala b/test/files/run/t2417.scala new file mode 100644 index 0000000000..31d4c143fa --- /dev/null +++ b/test/files/run/t2417.scala @@ -0,0 +1,77 @@ +// #2417 +object Test { + + def parallel(numThreads: Int)(block: => Unit) { + var failure: Throwable = null + val threads = Array.fromFunction(i => new Thread { + override def run { + try { + block + } catch { + case x => failure = x + } + } + })(numThreads) + for (t <- threads) t.start + for (t <- threads) t.join + if (failure != null) println("FAILURE: " + failure) + } + + def testSet(initialSize: Int, numThreads: Int, passes: Int) { + val orig = Set.empty ++ (1 to initialSize) + parallel(numThreads) { + for (pass <- 0 until passes) { + var s = orig + for (e <- (initialSize to 1 by -1)) { + s -= e + val obs = s.size + if (obs != e - 1) { + throw new Exception("removed e=" + e + ", size was " + obs + ", s=" + s) + } + } + } + } + } + + def testMap(initialSize: Int, numThreads: Int, passes: Int) { + val orig = Map.empty ++ ((1 to initialSize) map ((_,"v"))) + parallel(numThreads) { + for (pass <- 0 until passes) { + var m = orig + for (e <- (initialSize to 1 by -1)) { + m -= e + val obs = m.size + if (obs != e - 1) { + throw new Exception("removed e=" + e + ", size was " + obs + ", m=" + m) + } + } + } + } + } + + def main(args: Array[String]) { + println("testing small Map that doesn't promote to HashMap...") + testMap(4, 2, 1000000) + println() + + println("testing single-threaded HashMap use...") + testMap(5, 1, 1000000) + println() + + println("testing HashMap.size from multiple threads...") + testMap(5, 2, 1000000) + println() + + println("testing small Set that doesn't promote to HashSet...") + testSet(4, 2, 1000000) + println() + + println("testing single-threaded HashSet use...") + testSet(5, 1, 1000000) + println() + + println("testing HashSet.size from multiple threads...") + testSet(5, 2, 1000000) + println() + } +}
\ No newline at end of file diff --git a/test/files/run/t2526.scala b/test/files/run/t2526.scala index 5f6d60546a..53f3059135 100644 --- a/test/files/run/t2526.scala +++ b/test/files/run/t2526.scala @@ -20,9 +20,8 @@ object Test { assertForeach(keys, m.keysIterator) assertForeach(keys, m.keySet) - assertForeach(values, m.valuesIterable.iterator) + assertForeach(values, m.values.iterator) assertForeach(values, m.valuesIterator) - assertForeach(values, m.valuesIterable) assertForeach(entries, m) } @@ -39,7 +38,7 @@ object Test { /* * Checks foreach of `actual` goes over all the elements in `expected` - * We duplicate the method above because there is no common inteface between Traverable and + * We duplicate the method above because there is no common inteface between Traversable and * Iterator and we want to avoid converting between collections to ensure that we test what * we mean to test. */ diff --git a/test/files/run/t2867.scala b/test/files/run/t2867.scala new file mode 100644 index 0000000000..25e55eaecd --- /dev/null +++ b/test/files/run/t2867.scala @@ -0,0 +1,15 @@ +object Test { + case class A(l: List[_]*) + + def main(args: Array[String]): Unit = { + /** Kind of sneaking a slightly different test in here as well as + * testing 2867. How subversive. + */ + val xs1 = List(1, 2, 3) + val xs2 = List(1.0, 2.0, 3.0) + val xs3 = List[Any](1.0f, 2.0f, 3.0f) + val xs4 = List[Byte](1, 2, 3) + + assert(A(List(xs1, xs2)) == A(List(xs3, xs4))) + } +} diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check new file mode 100644 index 0000000000..39ee46a3df --- /dev/null +++ b/test/files/run/t2886.check @@ -0,0 +1 @@ +Function(List(LocalValue(NoSymbol,x,PrefixedType(SingleType(ThisType(Class(scala)),Field(scala.Predef,PrefixedType(ThisType(Class(scala)),Class(scala.Predef)))),TypeField(scala.Predef.String,PrefixedType(ThisType(Class(java.lang)),Class(java.lang.String)))))),Block(List(ValDef(LocalValue(NoSymbol,x$1,NoType),Ident(LocalValue(NoSymbol,x,PrefixedType(SingleType(ThisType(Class(scala)),Field(scala.Predef,PrefixedType(ThisType(Class(scala)),Class(scala.Predef)))),TypeField(scala.Predef.String,PrefixedType(ThisType(Class(java.lang)),Class(java.lang.String))))))), ValDef(LocalValue(NoSymbol,x$2,NoType),Ident(LocalValue(NoSymbol,x,PrefixedType(SingleType(ThisType(Class(scala)),Field(scala.Predef,PrefixedType(ThisType(Class(scala)),Class(scala.Predef)))),TypeField(scala.Predef.String,PrefixedType(ThisType(Class(java.lang)),Class(java.lang.String)))))))),Apply(Select(This(Class(Test)),Method(Test.test,MethodType(List(LocalValue(NoSymbol,name,PrefixedType(SingleType(ThisType(Class(scala)),Field(scala.Predef,PrefixedType(ThisType(Class(scala)),Class(scala.Predef)))),TypeField(scala.Predef.String,PrefixedType(ThisType(Class(java.lang)),Class(java.lang.String))))), LocalValue(NoSymbol,address,PrefixedType(SingleType(ThisType(Class(scala)),Field(scala.Predef,PrefixedType(ThisType(Class(scala)),Class(scala.Predef)))),TypeField(scala.Predef.String,PrefixedType(ThisType(Class(java.lang)),Class(java.lang.String)))))),PrefixedType(ThisType(Class(scala)),Class(scala.Null))))),List(Ident(LocalValue(NoSymbol,x$2,NoType)), Ident(LocalValue(NoSymbol,x$1,NoType))))))
\ No newline at end of file diff --git a/test/files/run/t2886.scala b/test/files/run/t2886.scala new file mode 100644 index 0000000000..eb392f0c58 --- /dev/null +++ b/test/files/run/t2886.scala @@ -0,0 +1,7 @@ +object Test { + def test(name: String, address: String) = null + def main(args: Array[String]) = { + val tree = scala.reflect.Code.lift((x:String) => test(address=x,name=x)).tree + println(tree) + } +} diff --git a/test/files/run/t2946/Parsers.scala b/test/files/run/t2946/Parsers.scala new file mode 100644 index 0000000000..c0961034c4 --- /dev/null +++ b/test/files/run/t2946/Parsers.scala @@ -0,0 +1,4 @@ +class Parser { + def parse(t: Any): Unit = { + } +} diff --git a/test/files/run/t2946/ResponseCommon.scala b/test/files/run/t2946/ResponseCommon.scala new file mode 100644 index 0000000000..fa9d8acccb --- /dev/null +++ b/test/files/run/t2946/ResponseCommon.scala @@ -0,0 +1,14 @@ +trait ResponseCommon extends Parser { + private[this] var paramsParser: Parser = null + def withParamsParser(parser: Parser) = {paramsParser = parser; this} + + class Foo { + println(paramsParser) + } + + override abstract def parse(t: Any): Unit = t match { + case ("params", value: List[_]) => value.foreach {paramsParser.parse(_)} + case _ => super.parse(t) + } +} + diff --git a/test/files/run/t2946/Test.scala b/test/files/run/t2946/Test.scala new file mode 100644 index 0000000000..e9d9896a0e --- /dev/null +++ b/test/files/run/t2946/Test.scala @@ -0,0 +1,7 @@ +class Test extends Parser with ResponseCommon + +object Test { + def main(args: Array[String]) { + new Test + } +} diff --git a/test/files/run/t3026.check b/test/files/run/t3026.check new file mode 100644 index 0000000000..8c29b615fa --- /dev/null +++ b/test/files/run/t3026.check @@ -0,0 +1,2 @@ +RED +YELLOW diff --git a/test/files/run/t3026.scala b/test/files/run/t3026.scala new file mode 100755 index 0000000000..22dde9cc03 --- /dev/null +++ b/test/files/run/t3026.scala @@ -0,0 +1,8 @@ +object Test { + abstract class Colour + case object RED extends Colour + case object YELLOW extends Colour + val items = Array(RED, YELLOW) + + def main(args: Array[String]): Unit = items foreach println +} diff --git a/test/files/run/t3112.check b/test/files/run/t3112.check new file mode 100644 index 0000000000..a95644c82c --- /dev/null +++ b/test/files/run/t3112.check @@ -0,0 +1,4 @@ +Vector() +Vector() +Vector() +Vector()
\ No newline at end of file diff --git a/test/files/run/t3112.scala b/test/files/run/t3112.scala new file mode 100644 index 0000000000..eb8eec6327 --- /dev/null +++ b/test/files/run/t3112.scala @@ -0,0 +1,11 @@ +// #3112 +object Test { + + def main(args: Array[String]): Unit = { + println((Vector() ++ (0 until 32)) take 0) // works + println((Vector() ++ (0 until 33)) take 0) // error + println((Vector() ++ (0 until 32)) takeRight 0) // works + println((Vector() ++ (0 until 33)) takeRight 0) // error + } + +}
\ No newline at end of file diff --git a/test/files/run/t3158.check b/test/files/run/t3158.check new file mode 100644 index 0000000000..ab1cb284d5 --- /dev/null +++ b/test/files/run/t3158.check @@ -0,0 +1 @@ +Array(<function1>) diff --git a/test/files/run/t3158.scala b/test/files/run/t3158.scala new file mode 100644 index 0000000000..c824b62e96 --- /dev/null +++ b/test/files/run/t3158.scala @@ -0,0 +1,9 @@ +object Test { + def main(args: Array[String]) { + println(args.map(_ => foo _).deep) + } + + def foo(xs: String*) { + println(xs) + } +} diff --git a/test/pending/jvm/t1464.check b/test/files/run/t3186.check index c508d5366f..c508d5366f 100644 --- a/test/pending/jvm/t1464.check +++ b/test/files/run/t3186.check diff --git a/test/files/run/t3186.scala b/test/files/run/t3186.scala new file mode 100644 index 0000000000..2534d4a164 --- /dev/null +++ b/test/files/run/t3186.scala @@ -0,0 +1,7 @@ +object Dist1 extends Enumeration { val Mile, Foot, Inch = Value } + +object Dist2 extends Enumeration { val Kilometer, Millimeter, Parsec = Value } + +object Test extends Application { + println(Dist1.Mile == Dist2.Kilometer) +} diff --git a/test/files/run/t3242.check b/test/files/run/t3242.check new file mode 100644 index 0000000000..a145f6df8f --- /dev/null +++ b/test/files/run/t3242.check @@ -0,0 +1,18 @@ + append [num: 200] vec + remove [num: 200] vec + append [num: 400] vec + remove [num: 400] vec + append [num: 600] vec + remove [num: 600] vec + append [num: 800] vec + remove [num: 800] vec +>> comparison done, num: 200 + append [num: 2000] vec + remove [num: 2000] vec + append [num: 4000] vec + remove [num: 4000] vec + append [num: 6000] vec + remove [num: 6000] vec + append [num: 8000] vec + remove [num: 8000] vec +>> comparison done, num: 2000 diff --git a/test/files/run/t3242.scala b/test/files/run/t3242.scala new file mode 100644 index 0000000000..f8defaa5cd --- /dev/null +++ b/test/files/run/t3242.scala @@ -0,0 +1,49 @@ +object Test { + + def benchmarkA(num: Int) { + + type A = Int + + def updateM[M[_]](ms: M[A], update: (M[A], A)=>M[A]): M[A] = { + var is = ms + for (i <- 0 until num) is = update(is, i) + is + } + + // + def vectorAppend: Vector[A] = updateM[Vector](Vector(), (as, a)=>{ + val v = (as :+ a) + //println("==>append: i: "+i1+", v: "+v) + v + }) + // this will crash, Vector bug! + def vectorRemove(vec: Vector[A]): Vector[A] = updateM[Vector](vec, (as, a)=>{ + val v = (as filterNot{ _ == a}) + //val v = (is filter{ _ != i}) + //println("==>remove: i: "+a) + v + }) + + val ct = vectorAppend + println(" append [num: "+num+"] vec") + vectorRemove(ct) + println(" remove [num: "+num+"] vec") + } // BenchmarkA + + def comparison(num: Int): Unit = { + for (i <- 1 until 5) benchmarkA(num*i) + println(">> comparison done, num: "+num); + } + + def main(args: Array[String]): Unit = { + try { + //createBenchmarkA(23).testRun + + comparison(200) // OK + comparison(2000) // this will crach + + } catch { + case e: Exception => e.printStackTrace() + } + } +} diff --git a/test/files/run/t3242b.scala b/test/files/run/t3242b.scala new file mode 100644 index 0000000000..7a296aac15 --- /dev/null +++ b/test/files/run/t3242b.scala @@ -0,0 +1,17 @@ +import scala.collection.immutable._ + +object Test { + + def test(n: Int) = { + var vb = new VectorBuilder[Int] + for (i <- 0 until n) + vb += i + val v = vb.result + assert(v == (0 until n), "not same as (0 until " + n + "): " + v) + } + + def main(args: Array[String]): Unit = { + for (i <- 0 until 2000) + test(i) + } +} diff --git a/test/files/run/treePrint.check b/test/files/run/treePrint.check new file mode 100644 index 0000000000..3360815ac1 --- /dev/null +++ b/test/files/run/treePrint.check @@ -0,0 +1,5 @@ +def foo = { + var q: Boolean = false; + val x = 5; + ((x == 5) || (!q)) || (true) +} diff --git a/test/files/run/treePrint.scala b/test/files/run/treePrint.scala new file mode 100644 index 0000000000..ffe9a392d4 --- /dev/null +++ b/test/files/run/treePrint.scala @@ -0,0 +1,40 @@ +/** Testing compact tree printers. + */ +object Test { + import scala.tools.nsc._ + import java.io.{ OutputStream, BufferedReader, StringReader, PrintWriter, Writer, OutputStreamWriter} + + val code = """ + def foo = { + var q: Boolean = false + val x = if (true) { + if (true) { + if (true) { + 5 + } + else if (true) { + 5 + } else { + 10 + } + } + else 20 + } + else 30 + + (x == 5) || !q || true + } + """ + + class NullOutputStream extends OutputStream { def write(b: Int) { } } + + def main(args: Array[String]) { + val settings = new Settings + settings.classpath.value = System.getProperty("java.class.path") + settings.Ycompacttrees.value = true + + val repl = new Interpreter(settings, new PrintWriter(new NullOutputStream)) + repl.interpret("""def initialize = "Have to interpret something or we get errors." """) + println(repl mkTree code) + } +} diff --git a/test/files/run/unittest_collection.scala b/test/files/run/unittest_collection.scala index 5d7ab97425..d45c23d4b5 100644 --- a/test/files/run/unittest_collection.scala +++ b/test/files/run/unittest_collection.scala @@ -96,7 +96,7 @@ object Test { ) val tr = new TestResult() ts.run(tr) - for(val failure <- tr.failures) { + for (failure <- tr.failures) { Console.println(failure) } } diff --git a/test/files/run/unittest_iterator.scala b/test/files/run/unittest_iterator.scala index 93aaa4a834..28a548160f 100644 --- a/test/files/run/unittest_iterator.scala +++ b/test/files/run/unittest_iterator.scala @@ -33,5 +33,18 @@ object Test assertThat(1, (1 to 8).toList) { it.sliding(8, 8) withPartial false } assertThat(2, List(9, 10, -1, -1, -1)) { it.sliding(5, 8) withPadding -1 } assertThat(1, (1 to 5).toList) { it.sliding(5, 8) withPartial false } + + // make sure it throws past th end + val thrown = try { + val it = List(1,2,3).sliding(2) + it.next + it.next + it.next + false + } + catch { + case _: NoSuchElementException => true + } + assert(thrown) } } diff --git a/test/files/run/vector1.scala b/test/files/run/vector1.scala index 320bef220c..e8785e2b16 100644 --- a/test/files/run/vector1.scala +++ b/test/files/run/vector1.scala @@ -22,7 +22,7 @@ object Test { def vectorForward(label: String, n: Int): Vector[String] = { var a: Vector[String] = Vector.empty for (i <- 0 until n) - a = a.appendBack(label + i) + a = a :+ (label + i) assertVector(a, label, 0, n) } @@ -30,7 +30,7 @@ object Test { def vectorBackward(label: String, n: Int): Vector[String] = { var a: Vector[String] = Vector.empty for (i <- 0 until n) - a = a.appendFront(label + (n-1-i)) + a = (label + (n-1-i)) +: a assertVector(a, label, 0, n) } @@ -92,8 +92,8 @@ object Test { def nextChunkSize = 3 //rand.nextInt(chunkLimit) - def seqBack() = for (i <- 0 until Math.min(nextChunkSize, N-max)) { a = a.appendBack("a"+max); max += 1 } - def seqFront() = for (i <- 0 until Math.min(nextChunkSize, min)) { min -= 1; a = a.appendFront("a"+min) } + def seqBack() = for (i <- 0 until Math.min(nextChunkSize, N-max)) { a = a :+ ("a"+max); max += 1 } + def seqFront() = for (i <- 0 until Math.min(nextChunkSize, min)) { min -= 1; a = ("a"+min) +: a } try { @@ -104,7 +104,7 @@ object Test { } catch { case ex => //println("----------------") - a.debug + //a.debug throw ex } diff --git a/test/files/run/viewtest.check b/test/files/run/viewtest.check index ded3ac0e92..6e0fe81a67 100644 --- a/test/files/run/viewtest.check +++ b/test/files/run/viewtest.check @@ -1,17 +1,11 @@ -SeqViewZ((x,0)) +SeqViewZ(...) ys defined mapping 1 2 -mapping 1 -mapping 2 -mapping 3 -SeqViewMS(3, 4) +SeqViewMS(...) mapping 3 4 -mapping 1 -mapping 2 -mapping 3 -SeqViewM(2, 3, 4) +SeqViewM(...) mapping 1 mapping 2 mapping 3 diff --git a/test/files/run/viewtest.scala b/test/files/run/viewtest.scala index 280ded57cf..833c0101e3 100755 --- a/test/files/run/viewtest.scala +++ b/test/files/run/viewtest.scala @@ -13,7 +13,7 @@ object Test extends Application { println(ys.force) val zs = Array(1, 2, 3).view - val as: IndexedSeqView[Int, Array[Int]] = zs map (_ + 1) + val as: SeqView[Int, Array[Int]] = zs map (_ + 1) val bs: Array[Int] = as.force val cs = zs.reverse cs(0) += 1 diff --git a/test/files/run/withIndex.scala b/test/files/run/withIndex.scala index 3b9c9e84e5..910b1f1f9e 100644 --- a/test/files/run/withIndex.scala +++ b/test/files/run/withIndex.scala @@ -3,7 +3,7 @@ object Test { val ary: Array[String] = Array("a", "b", "c") val lst: List[String] = List("a", "b", "c") val itr: Iterator[String] = lst.iterator - val str: Stream[String] = Stream.fromIterator(lst.iterator) + val str: Stream[String] = lst.iterator.toStream Console.println(ary.zipWithIndex.toList) Console.println(lst.zipWithIndex.toList) diff --git a/test/files/scalacheck/array.scala b/test/files/scalacheck/array.scala index 2febca4447..03c0217180 100644 --- a/test/files/scalacheck/array.scala +++ b/test/files/scalacheck/array.scala @@ -4,36 +4,34 @@ import Gen._ import Arbitrary._ import util._ import Buildable._ +import scala.collection.mutable.ArraySeq object Test extends Properties("Array") { - val myGens: Seq[Gen[Array[_]]] = List( - arbArray[Int], - arbArray[Array[Int]], - arbArray[List[String]], - arbArray[String], - arbArray[Boolean], - arbArray[AnyVal](arbAnyVal) - ) map (_.arbitrary) + /** At this moment the authentic scalacheck Array Builder/Arb bits are commented out. + */ + implicit def arbArray[T](implicit a: Arbitrary[T], m: Manifest[T]): Arbitrary[Array[T]] = + Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray)) + + val arrGen: Gen[Array[_]] = oneOf( + arbitrary[Array[Int]], + arbitrary[Array[Array[Int]]], + arbitrary[Array[List[String]]], + arbitrary[Array[String]], + arbitrary[Array[Boolean]], + arbitrary[Array[AnyVal]] + ) // inspired by #1857 and #2352 - property("eq/ne") = - forAll(oneOf(myGens: _*)) { c1 => - forAll(oneOf(myGens: _*)) { c2 => - (c1 eq c2) || (c1 ne c2) - } - } + property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) => + (c1 eq c2) || (c1 ne c2) + } - def smallInt = choose(1, 10) // inspired by #2299 - property("ofDim") = forAll(smallInt) { i1 => - forAll(smallInt) { i2 => - forAll(smallInt) { i3 => - val arr = Array.ofDim[String](i1, i2, i3) - val flattened = arr flatMap (x => x) flatMap (x => x) - - flattened.length == i1 * i2 * i3 - } - } + def smallInt = choose(1, 10) + property("ofDim") = forAll(smallInt, smallInt, smallInt) { (i1, i2, i3) => + val arr = Array.ofDim[String](i1, i2, i3) + val flattened = arr flatMap (x => x) flatMap (x => x) + flattened.length == i1 * i2 * i3 } } diff --git a/test/files/scalacheck/eqeq.scala b/test/files/scalacheck/eqeq.scala new file mode 100644 index 0000000000..60fe63c207 --- /dev/null +++ b/test/files/scalacheck/eqeq.scala @@ -0,0 +1,37 @@ +import org.scalacheck._ +import Prop._ +import Gen._ + +object Test extends Properties("==") { + def equalObjectsEqualHashcodes(x: Any, y: Any) = (x != y) || (x == y && x.## == y.##) + + // ticket #2087 + property("short/char") = forAll { (x: Short) => { + val ch: Char = x.toChar + (x == ch) == (ch == x) + } + } + + property("symmetry") = forAll { (x: AnyVal, y: AnyVal) => (x == y) == (y == x) } + property("transitivity") = forAll { (x: AnyVal, y: AnyVal, z: AnyVal) => x != y || y != z || x == z } + + property("##") = forAll { + (x: Short) => { + val anyvals = List(x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x)) + val shortAndLarger = anyvals drop 2 + + val result = ( + ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && + ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && + ((shortAndLarger, shortAndLarger).zipped forall ((x, y) => (x: Any) == (y: Any))) + ) + result + } + } + property("## 2") = forAll { + (dv: Double) => { + val fv = dv.toFloat + (fv != dv) || (fv.## == dv.##) + } + } +} diff --git a/test/files/scalacheck/list.scala b/test/files/scalacheck/list.scala index 87ecd70a48..1caf35e872 100644 --- a/test/files/scalacheck/list.scala +++ b/test/files/scalacheck/list.scala @@ -7,14 +7,14 @@ object Test extends Properties("List") { property("concat size") = forAll { (l1: List[Int], l2: List[Int]) => (l1.size + l2.size) == (l1 ::: l2).size } property("reverse") = forAll { (l1: List[Int]) => l1.reverse.reverse == l1 } - property("toSet") = forAll { (l1: List[Int]) => sorted(l1.toSet.toList) sameElements sorted(l1).removeDuplicates } + property("toSet") = forAll { (l1: List[Int]) => sorted(l1.toSet.toList) sameElements sorted(l1).distinct } property("flatten") = forAll { (xxs: List[List[Int]]) => xxs.flatten.length == (xxs map (_.length) sum) } property("startsWith/take") = forAll { (xs: List[Int], count: Int) => xs startsWith (xs take count) } property("endsWith/takeRight") = forAll { (xs: List[Int], count: Int) => xs endsWith (xs takeRight count) } property("fill") = forAll(choose(1, 100)) { count => forAll { (x: Int) => val xs = List.fill(count)(x) - (xs.length == count) && (xs.removeDuplicates == List(x)) + (xs.length == count) && (xs.distinct == List(x)) } } } diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala new file mode 100644 index 0000000000..faa1f5d479 --- /dev/null +++ b/test/files/scalacheck/range.scala @@ -0,0 +1,205 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +class Counter(r: Range) { + var cnt = 0L + var last: Option[Int] = None + val str = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") + def apply(x: Int) = { + cnt += 1L + if (cnt % 500000000L == 0L) { + println("Working: %s %d %d" format (str, cnt, x)) + } + if (cnt > (Int.MaxValue.toLong + 1) * 2) + error("Count exceeds maximum possible for an Int Range") + if ((r.step > 0 && last.exists(_ > x)) || (r.step < 0 && last.exists(_ < x))) + error("Range wrapped: %d %s" format (x, last.toString)) + last = Some(x) + } +} + +abstract class RangeTest(kind: String) extends Properties("Range "+kind) { + def myGen: Gen[Range] + + val genRange = for { + start <- arbitrary[Int] + end <- arbitrary[Int] + step <- Gen.choose(1, (start - end).abs + 1) + } yield if (start < end) Range(start, end, step) else Range(start, end, -step) + + val genReasonableSizeRange = for { + start <- choose(-Int.MinValue, Int.MaxValue) + end <- choose(-Int.MinValue, Int.MaxValue) + step <- choose(-Int.MaxValue, Int.MaxValue) + } yield Range(start, end, if (step == 0) 100 else step) + + val genSmallRange = for { + start <- choose(-100, 100) + end <- choose(-100, 100) + step <- choose(1, 1) + } yield if (start < end) Range(start, end, step) else Range(start, end, -step) + + val genRangeByOne = for { + start <- arbitrary[Int] + end <- arbitrary[Int] + if (end.toLong - start.toLong).abs <= 10000000L + } yield if (start < end) Range(start, end) else Range(end, start) + + def str(r: Range) = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") + + def expectedSize(r: Range): Long = if (r.isInclusive) { + (r.end.toLong - r.start.toLong < 0, r.step < 0) match { + case (true, true) | (false, false) => (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong + 1L + case _ => if (r.start == r.end) 1L else 0L + } + } else { + (r.end.toLong - r.start.toLong < 0, r.step < 0) match { + case (true, true) | (false, false) => ( + (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong + + (if ((r.end.toLong - r.start.toLong).abs % r.step.abs.toLong > 0L) 1L else 0L) + ) + case _ => 0L + } + } + + def within(r: Range, x: Int) = if (r.step > 0) + r.start <= x && (if (r.isInclusive) x <= r.end else x < r.end) + else + r.start >= x && (if (r.isInclusive) x >= r.end else x > r.end) + + def multiple(r: Range, x: Int) = (x.toLong - r.start) % r.step == 0 + + property("foreach.step") = forAll(myGen) { r => + var allValid = true + val cnt = new Counter(r) +// println("--------------------") +// println(r) + r foreach { x => cnt(x) +// println(x + ", " + (x - r.start) + ", " + (x.toLong - r.start) + ", " + ((x.toLong - r.start) % r.step)) + allValid &&= multiple(r, x) + } + allValid :| str(r) + } + + property("foreach.inside.range") = forAll(myGen) { r => + var allValid = true + var last: Option[Int] = None + val cnt = new Counter(r) + r foreach { x => cnt(x) + allValid &&= within(r, x) + } + allValid :| str(r) + } + + property("foreach.visited.size") = forAll(myGen) { r => + var visited = 0L + val cnt = new Counter(r) + r foreach { x => cnt(x) + visited += 1L + } +// println("----------") +// println(str(r)) +// println("size: " + r.size) +// println("expected: " + expectedSize(r)) +// println("visited: " + visited) + (visited == expectedSize(r)) :| str(r) + } + + property("length") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => + (r.length == expectedSize(r)) :| str(r) + } + + property("isEmpty") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => + (r.isEmpty == (expectedSize(r) == 0L)) :| str(r) + } + + property("contains") = forAll(myGen, arbInt.arbitrary) { (r, x) => +// println("----------------") +// println(str(r)) +// println(x) +// println("within: " + within(r, x)) +// println("multiple: " + multiple(r, x)) +// println("contains: " + r.contains(x)) + ((within(r, x) && multiple(r, x)) == r.contains(x)) :| str(r)+": "+x + } + + property("take") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => + val t = r take x + (t.size == (0 max x min r.size) && t.start == r.start && t.step == r.step) :| str(r)+" / "+str(t)+": "+x + } + + property("takeWhile") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => + val t = (if (r.step > 0) r takeWhile (_ <= x) else r takeWhile(_ >= x)) + if (r.size == 0) { + (t.size == 0) :| str(r)+" / "+str(t)+": "+x + } else { + val t2 = (if (r.step > 0) Range(r.start, x min r.last, r.step).inclusive else Range(r.start, x max r.last, r.step).inclusive) + (t.start == r.start && t.size == t2.size && t.step == r.step) :| str(r)+" / "+str(t)+" / "+str(t2)+": "+x + } + } + + property("reverse.toSet.equal") = forAll(myGen) { r => + val reversed = r.reverse + val aresame = r.toSet == reversed.toSet + if (!aresame) { + println(str(r)) + println(r) + println(reversed) + println(r.toSet) + println(reversed.toSet) + } + aresame + } +} + +object NormalRangeTest extends RangeTest("normal") { + override def myGen = genReasonableSizeRange + def genOne = for { + start <- arbitrary[Int] + end <- arbitrary[Int] + if (start.toLong - end.toLong).abs < Int.MaxValue.toLong + } yield Range(start, end, if (start < end) 1 else - 1) + property("by 1.size + 1 == inclusive.size") = forAll(genOne) { r => + (r.size + 1 == r.inclusive.size) :| str(r) + } +} + +object InclusiveRangeTest extends RangeTest("inclusive") { + override def myGen = for (r <- genReasonableSizeRange) yield r.inclusive +} + +object ByOneRangeTest extends RangeTest("byOne") { + override def myGen = genSmallRange +} + +object InclusiveByOneRangeTest extends RangeTest("inclusiveByOne") { + override def myGen = for (r <- genSmallRange) yield r.inclusive +} + +object SmallValuesRange extends RangeTest("smallValues") { + override def myGen = genSmallRange +} + +object Test extends Properties("Range") { + include(NormalRangeTest) + include(InclusiveRangeTest) + include(ByOneRangeTest) + include(InclusiveByOneRangeTest) +} + +/* Mini-benchmark +def testRange(i: Int, j: Int, k: Int) = { + var count = 0 + for { + vi <- 0 to i + vj <- 0 to j + vk <- 0 to k + } { count += 1 } +} + +testRange(10, 1000, 10000) +testRange(10000, 1000, 10) +*/ + diff --git a/test/files/scalacheck/scan.scala b/test/files/scalacheck/scan.scala new file mode 100644 index 0000000000..e9b25ce3df --- /dev/null +++ b/test/files/scalacheck/scan.scala @@ -0,0 +1,17 @@ +import org.scalacheck._ +import Prop._ +import Gen._ + + +object Test extends Properties("TraversableLike.scanLeft") { + property("scanLeft") = forAll { (xs: List[Int], z: Int) => { + val sums = xs.scanLeft(z)(_ + _) + (xs.size == 0) || sums.zip(sums.tail).map(x => x._2 - x._1) == xs + }} +} + + + + + + diff --git a/test/files/scalap/caseClass/result.test b/test/files/scalap/caseClass/result.test index cabf321a07..eb1ad74295 100644 --- a/test/files/scalap/caseClass/result.test +++ b/test/files/scalap/caseClass/result.test @@ -1,10 +1,9 @@ -case class CaseClass[A >: scala.Nothing <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends java.lang.Object with scala.ScalaObject with scala.Product { +@scala.serializable +case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends java.lang.Object with scala.ScalaObject with scala.Product { val i : A = { /* compiled code */ } val s : scala.Predef.String = { /* compiled code */ } def foo : scala.Int = { /* compiled code */ } - def copy[A >: scala.Nothing <: scala.Seq[scala.Int]]() : CaseClass[A] = { /* compiled code */ } - def copy$default$1[A >: scala.Nothing <: scala.Seq[scala.Int]] : A = { /* compiled code */ } - def copy$default$2[A >: scala.Nothing <: scala.Seq[scala.Int]] : scala.Predef.String = { /* compiled code */ } + def copy[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ } override def hashCode() : scala.Int = { /* compiled code */ } override def toString() : scala.Predef.String = { /* compiled code */ } override def equals(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } diff --git a/test/files/scalap/classPrivate/A.scala b/test/files/scalap/classPrivate/A.scala new file mode 100644 index 0000000000..9f1bd34a6a --- /dev/null +++ b/test/files/scalap/classPrivate/A.scala @@ -0,0 +1,9 @@ +class ClassPrivate { + private def foo = 1 + private[ClassPrivate] def bar = 2 + def baz = 3 + class Outer { + private[ClassPrivate] def qux = 4 + } + protected def quux = 5 +}
\ No newline at end of file diff --git a/test/files/scalap/classPrivate/result.test b/test/files/scalap/classPrivate/result.test new file mode 100644 index 0000000000..0d12b779c3 --- /dev/null +++ b/test/files/scalap/classPrivate/result.test @@ -0,0 +1,10 @@ +class ClassPrivate extends java.lang.Object with scala.ScalaObject { + def this() = { /* compiled code */ } + def baz : scala.Int = { /* compiled code */ } + class Outer extends java.lang.Object with scala.ScalaObject { + def this() = { /* compiled code */ } + private[ClassPrivate] def qux : scala.Int = { /* compiled code */ } + } + protected def quux : scala.Int = { /* compiled code */ } + private[ClassPrivate] def bar : scala.Int = { /* compiled code */ } +}
\ No newline at end of file diff --git a/test/files/scalap/classWithExistential/result.test b/test/files/scalap/classWithExistential/result.test index 243f51e2ad..91afddaf0e 100644 --- a/test/files/scalap/classWithExistential/result.test +++ b/test/files/scalap/classWithExistential/result.test @@ -1,4 +1,4 @@ class ClassWithExistential extends java.lang.Object with scala.ScalaObject { def this() = { /* compiled code */ } - def foo[A >: scala.Nothing <: scala.Any, B >: scala.Nothing <: scala.Any] : scala.Function1[A, B forSome {type A >: scala.Nothing <: scala.Seq[scala.Int]; type B >: scala.Predef.String <: scala.Any}] = { /* compiled code */ } -} + def foo[A, B] : scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ } +}
\ No newline at end of file diff --git a/test/files/scalap/covariantParam/result.test b/test/files/scalap/covariantParam/result.test index ce480ee0cd..8acd9b497a 100644 --- a/test/files/scalap/covariantParam/result.test +++ b/test/files/scalap/covariantParam/result.test @@ -1,4 +1,4 @@ -class CovariantParam[+A >: scala.Nothing <: scala.Any] extends java.lang.Object with scala.ScalaObject { +class CovariantParam[+A] extends java.lang.Object with scala.ScalaObject { def this() = { /* compiled code */ } - def foo[A >: scala.Nothing <: scala.Any](a : A) : scala.Int = { /* compiled code */ } + def foo[A](a : A) : scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/defaultParameter/A.scala b/test/files/scalap/defaultParameter/A.scala new file mode 100644 index 0000000000..d3514952f4 --- /dev/null +++ b/test/files/scalap/defaultParameter/A.scala @@ -0,0 +1,3 @@ +trait DefaultParameter { + def foo(s: String = "hello"): Unit +}
\ No newline at end of file diff --git a/test/files/scalap/defaultParameter/result.test b/test/files/scalap/defaultParameter/result.test new file mode 100644 index 0000000000..38bf6ac4e3 --- /dev/null +++ b/test/files/scalap/defaultParameter/result.test @@ -0,0 +1,3 @@ +trait DefaultParameter extends java.lang.Object { + def foo(s : scala.Predef.String) : scala.Unit +}
\ No newline at end of file diff --git a/test/files/scalap/typeAnnotations/A.scala b/test/files/scalap/typeAnnotations/A.scala new file mode 100644 index 0000000000..ff2445edc9 --- /dev/null +++ b/test/files/scalap/typeAnnotations/A.scala @@ -0,0 +1,9 @@ +abstract class TypeAnnotations[@specialized R] { + @specialized val x = 10 + @specialized type T + + def compose[@specialized A](x: A, y: R): A = { + val y: A = x + x + } +}
\ No newline at end of file diff --git a/test/files/scalap/typeAnnotations/result.test b/test/files/scalap/typeAnnotations/result.test new file mode 100644 index 0000000000..b565d6185b --- /dev/null +++ b/test/files/scalap/typeAnnotations/result.test @@ -0,0 +1,8 @@ +abstract class TypeAnnotations[@scala.specialized R] extends java.lang.Object with scala.ScalaObject { + def this() = { /* compiled code */ } + @scala.specialized + val x : scala.Int = { /* compiled code */ } + @scala.specialized + type T + def compose[@scala.specialized A](x : A, y : R) : A = { /* compiled code */ } +}
\ No newline at end of file diff --git a/test/files/script/fact.scala b/test/files/script/fact.scala index d48dac6f0f..d48dac6f0f 100644..100755 --- a/test/files/script/fact.scala +++ b/test/files/script/fact.scala diff --git a/test/partest b/test/partest index 1405efa0c0..124c4d605e 100755 --- a/test/partest +++ b/test/partest @@ -75,7 +75,23 @@ if $cygwin; then fi # Reminder: substitution ${JAVA_OPTS:=-Xmx256M -Xms16M} DO NOT work on Solaris -[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx512M -Xms16M" -[ -n "$SCALAC_OPTS" ] || SCALAC_OPTS="-deprecation" +[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:MaxPermSize=128M" +[ -n "$SCALAC_OPTS" ] || SCALAC_OPTS="" -${JAVACMD:=java} $JAVA_OPTS -cp "$EXT_CLASSPATH" -Dpartest.debug="${PARTEST_DEBUG}" -Dscala.home="${SCALA_HOME}" -Dscalatest.javacmd="${JAVACMD}" -Dscalatest.java_opts="${JAVA_OPTS}" -Dscalatest.scalac_opts="${SCALAC_OPTS}" -Dscalatest.javac_cmd="${JAVA_HOME}/bin/javac" scala.tools.partest.nest.NestRunner "$@" +export SCALAC_OPTS +export JAVA_OPTS +export JAVACMD + +${JAVACMD:=java} $JAVA_OPTS \ + -cp "$EXT_CLASSPATH" \ + -Dscala.home="${SCALA_HOME}" \ + scala.tools.partest.Runner "$@" + +# ${JAVACMD:=java} $JAVA_OPTS \ +# -cp "$EXT_CLASSPATH" \ +# -Dscala.home="${SCALA_HOME}" \ +# -Dpartest.scalac_opts="${SCALAC_OPTS}" \ +# -Dpartest.javacmd="${JAVACMD}" \ +# -Dpartest.java_opts="${JAVA_OPTS}" \ +# -Dpartest.javac_cmd="${JAVA_HOME}/bin/javac" \ +# scala.tools.partest.Runner "$@" diff --git a/test/partest.bat b/test/partest.bat index 861c0a2465..0b5618a164 100755 --- a/test/partest.bat +++ b/test/partest.bat @@ -53,10 +53,10 @@ if "%_EXTENSION_CLASSPATH%"=="" ( )
)
-set _PROPS=-Dscala.home="%_SCALA_HOME%" -Dscalatest.javacmd="%_JAVACMD%" -Dscalatest.java_options="%_JAVA_OPTS%" -Dscalatest.scalac_options="%_SCALAC_OPTS%" -Dscalatest.javac_cmd="%JAVA_HOME%\bin\javac"
+set _PROPS=-Dscala.home="%_SCALA_HOME%" -Dpartest.javacmd="%_JAVACMD%" -Dpartest.java_options="%_JAVA_OPTS%" -Dpartest.scalac_options="%_SCALAC_OPTS%" -Dpartest.javac_cmd="%JAVA_HOME%\bin\javac"
-rem echo %_JAVACMD% %_JAVA_OPTS% %_PROPS% -cp "%_EXTENSION_CLASSPATH%" scala.tools.partest.nest.NestRunner %_ARGS%
-%_JAVACMD% %_JAVA_OPTS% %_PROPS% -cp "%_EXTENSION_CLASSPATH%" scala.tools.partest.nest.NestRunner %_ARGS%
+rem echo %_JAVACMD% %_JAVA_OPTS% %_PROPS% -cp "%_EXTENSION_CLASSPATH%" scala.tools.partest.Runner %_ARGS%
+%_JAVACMD% %_JAVA_OPTS% %_PROPS% -cp "%_EXTENSION_CLASSPATH%" scala.tools.partest.Runner %_ARGS%
goto end
rem ##########################################################################
diff --git a/test/pending/buildmanager/t2443/BitSet.scala b/test/pending/buildmanager/t2443/BitSet.scala new file mode 100644 index 0000000000..8d7c8dcd23 --- /dev/null +++ b/test/pending/buildmanager/t2443/BitSet.scala @@ -0,0 +1,2 @@ +import scala.collection.BitSet +//class BitSet diff --git a/test/pending/buildmanager/t2443/t2443.changes/BitSet2.scala b/test/pending/buildmanager/t2443/t2443.changes/BitSet2.scala new file mode 100644 index 0000000000..27a5d4de9f --- /dev/null +++ b/test/pending/buildmanager/t2443/t2443.changes/BitSet2.scala @@ -0,0 +1 @@ +import scala.collection.BitSet diff --git a/test/pending/buildmanager/t2443/t2443.check b/test/pending/buildmanager/t2443/t2443.check new file mode 100644 index 0000000000..dd88e1ceb9 --- /dev/null +++ b/test/pending/buildmanager/t2443/t2443.check @@ -0,0 +1,6 @@ +builder > BitSet.scala +compiling Set(BitSet.scala) +builder > BitSet.scala +Changes: Map(class BitSet -> List(Removed(Class(BitSet)))) + + diff --git a/test/pending/buildmanager/t2443/t2443.test b/test/pending/buildmanager/t2443/t2443.test new file mode 100644 index 0000000000..a1d61ff5a3 --- /dev/null +++ b/test/pending/buildmanager/t2443/t2443.test @@ -0,0 +1,3 @@ +>>compile BitSet.scala +>>update BitSet.scala=>BitSet2.scala +>>compile BitSet.scala diff --git a/test/pending/continuations-run/example0.scala b/test/pending/continuations-run/example0.scala new file mode 100644 index 0000000000..44b1331339 --- /dev/null +++ b/test/pending/continuations-run/example0.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test0.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example1.scala b/test/pending/continuations-run/example1.scala new file mode 100644 index 0000000000..195a98e59f --- /dev/null +++ b/test/pending/continuations-run/example1.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test1.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example16.scala b/test/pending/continuations-run/example16.scala new file mode 100644 index 0000000000..5eb64046ed --- /dev/null +++ b/test/pending/continuations-run/example16.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test16Printf.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example2.scala b/test/pending/continuations-run/example2.scala new file mode 100644 index 0000000000..0d96257c40 --- /dev/null +++ b/test/pending/continuations-run/example2.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test2.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example3.scala b/test/pending/continuations-run/example3.scala new file mode 100644 index 0000000000..3f5052a4ad --- /dev/null +++ b/test/pending/continuations-run/example3.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test3.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example4.scala b/test/pending/continuations-run/example4.scala new file mode 100644 index 0000000000..66c6774791 --- /dev/null +++ b/test/pending/continuations-run/example4.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test4.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example5.scala b/test/pending/continuations-run/example5.scala new file mode 100644 index 0000000000..0994bdee8a --- /dev/null +++ b/test/pending/continuations-run/example5.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test5.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example6.scala b/test/pending/continuations-run/example6.scala new file mode 100644 index 0000000000..5207e3fc68 --- /dev/null +++ b/test/pending/continuations-run/example6.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test6.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example7.scala b/test/pending/continuations-run/example7.scala new file mode 100644 index 0000000000..fb22387dac --- /dev/null +++ b/test/pending/continuations-run/example7.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test7.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example8.scala b/test/pending/continuations-run/example8.scala new file mode 100644 index 0000000000..8e21e6c674 --- /dev/null +++ b/test/pending/continuations-run/example8.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test8.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/example9.scala b/test/pending/continuations-run/example9.scala new file mode 100644 index 0000000000..0f27c686f7 --- /dev/null +++ b/test/pending/continuations-run/example9.scala @@ -0,0 +1,9 @@ +// $Id$ + +object Test { + + def main(args: Array[String]): Any = { + examples.continuations.Test9Monads.main(args) + } + +}
\ No newline at end of file diff --git a/test/pending/continuations-run/foreach.check b/test/pending/continuations-run/foreach.check new file mode 100644 index 0000000000..9bab7a2eed --- /dev/null +++ b/test/pending/continuations-run/foreach.check @@ -0,0 +1,4 @@ +1 +2 +3 +enough is enough
\ No newline at end of file diff --git a/test/pending/continuations-run/foreach.scala b/test/pending/continuations-run/foreach.scala new file mode 100644 index 0000000000..4daade452c --- /dev/null +++ b/test/pending/continuations-run/foreach.scala @@ -0,0 +1,33 @@ +// $Id$ + +import scala.util.continuations._ + +import scala.util.continuations.Loops._ + +object Test { + + def main(args: Array[String]): Any = { + + + reset { + + val list = List(1,2,3,4,5) + + for (x <- list.suspendable) { + + shift { k: (Unit => Unit) => + println(x) + if (x < 3) + k() + else + println("enough is enough") + } + + } + + } + + + } + +}
\ No newline at end of file diff --git a/test/pending/jvm/actor-executor4.check b/test/pending/jvm/actor-executor4.check new file mode 100644 index 0000000000..da78f45836 --- /dev/null +++ b/test/pending/jvm/actor-executor4.check @@ -0,0 +1,21 @@ +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +Two: OK +One: OK +One exited diff --git a/test/pending/jvm/actor-executor4.scala b/test/pending/jvm/actor-executor4.scala new file mode 100644 index 0000000000..a912d76094 --- /dev/null +++ b/test/pending/jvm/actor-executor4.scala @@ -0,0 +1,64 @@ +import scala.actors.{Actor, Exit} +import scala.actors.scheduler.ExecutorScheduler +import java.util.concurrent.Executors + +object One extends AdaptedActor { + def act() { + Two.start() + var i = 0 + loopWhile (i < Test.NUM_MSG) { + i += 1 + Two ! 'MsgForTwo + react { + case 'MsgForOne => + if (i % (Test.NUM_MSG/10) == 0) + println("One: OK") + } + } + } +} + +object Two extends AdaptedActor { + def act() { + var i = 0 + loopWhile (i < Test.NUM_MSG) { + i += 1 + react { + case 'MsgForTwo => + if (i % (Test.NUM_MSG/10) == 0) + println("Two: OK") + One ! 'MsgForOne + } + } + } +} + +trait AdaptedActor extends Actor { + override def scheduler = + Test.scheduler +} + +object Test { + val NUM_MSG = 100000 + + val scheduler = + ExecutorScheduler( + Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()), + false) + + def main(args: Array[String]) { + (new AdaptedActor { + def act() { + trapExit = true + link(One) + One.start() + + receive { + case Exit(from, reason) => + println("One exited") + Test.scheduler.shutdown() + } + } + }).start() + } +} diff --git a/test/files/neg/bug1210.check b/test/pending/neg/bug1210.check index 4db920556f..4db920556f 100644 --- a/test/files/neg/bug1210.check +++ b/test/pending/neg/bug1210.check diff --git a/test/pending/pos/t0644.scala b/test/pending/pos/t0644.scala deleted file mode 100644 index 5ad12c3632..0000000000 --- a/test/pending/pos/t0644.scala +++ /dev/null @@ -1,11 +0,0 @@ -class A { - def appply(): Int = 0 - def update(n: Int) {} -} - -class B extends A { - this() - this()=1 - super() - super()=1 -} diff --git a/test/files/pos/t1380/gnujaxp.jar.desired.sha1 b/test/pending/pos/t1380/gnujaxp.jar.desired.sha1 index c155c2aaa2..c155c2aaa2 100644 --- a/test/files/pos/t1380/gnujaxp.jar.desired.sha1 +++ b/test/pending/pos/t1380/gnujaxp.jar.desired.sha1 diff --git a/test/files/pos/t1380/hallo.scala b/test/pending/pos/t1380/hallo.scala index 27ecd9fb8b..27ecd9fb8b 100644 --- a/test/files/pos/t1380/hallo.scala +++ b/test/pending/pos/t1380/hallo.scala diff --git a/test/pending/pos/t1659.scala b/test/pending/pos/t1659.scala deleted file mode 100644 index 10470d66f8..0000000000 --- a/test/pending/pos/t1659.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait Y { type X } -trait W { def u[A](v : Y { type X = A }) : Unit } -class Z extends W { def u[A](v : Y { type X = A }) = null } - diff --git a/test/pending/pos/t2060.scala b/test/pending/pos/t2060.scala deleted file mode 100644 index 3f47259849..0000000000 --- a/test/pending/pos/t2060.scala +++ /dev/null @@ -1,28 +0,0 @@ -object Test { - class Op[I]; - class IntOp extends Op[Int]; - - class Rich(x : Double) { - def + (op : IntOp) = op; - def + [I](op : Op[I]) = op; - def plus [I](op : Op[I]) = op; - } - - implicit def iToRich(x : Double) = - new Rich(x); - - // fails to compile - val failure = 1.0 + new Op[Int]; - - // works as expected -- - // problem isn't in adding new "+" - val a = 1.0 + new IntOp; - - // works as expected -- - // problem isn't in binding type variable I - val b = 1.0 plus new Op[Int]; - - // works as expected -- - // problem isn't in using Rich.+[I](op : Op[I]) - val c = iToRich(1.0) + new Op[Int]; -} diff --git a/test/files/run/bug1697.scala b/test/pending/run/bug1697.scala index 01590dd405..01590dd405 100644 --- a/test/files/run/bug1697.scala +++ b/test/pending/run/bug1697.scala diff --git a/test/pending/run/bug2365/run b/test/pending/run/bug2365/run deleted file mode 100755 index f3c44ad086..0000000000 --- a/test/pending/run/bug2365/run +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# This script should fail with any build of scala where #2365 -# is not fixed, and otherwise succeed. Failure means running out -# of PermGen space. - -CP=.:/local/lib/java/ivy.jar -# SCALAC=/scala/inst/28/bin/scalac -SCALAC=scalac -RUN_OPTS="-XX:MaxPermSize=25M -verbose:gc" - -$SCALAC -cp $CP *.scala -JAVA_OPTS="${RUN_OPTS}" scala -cp $CP Test diff --git a/test/pending/run/bugs425-and-816.scala b/test/pending/run/bugs425-and-816.scala deleted file mode 100644 index d9267d06af..0000000000 --- a/test/pending/run/bugs425-and-816.scala +++ /dev/null @@ -1,27 +0,0 @@ -object Test { - object bug425 { - case class A(x: Int) - case class B(override val x: Int, y: Double) extends A(x) - - val b: A = B(5, 3.3) - b match { - case B(x, y) => Console.println(y) - case A(x) => Console.println(x) - } - } - - object bug816 { - abstract class Atest(val data: String) - - case class Btest(override val data: String, val b: boolean) extends Atest(data) - - case class Ctest(override val data: String) extends Btest(data, true) - - class testCaseClass { - def test(x: Atest) = x match { - case Ctest(data) => Console.println("C") - case Btest(data, b) => Console.println("B") - } - } - } -} diff --git a/test/pending/run/instanceOfAndTypeMatching.scala b/test/pending/run/instanceOfAndTypeMatching.scala new file mode 100644 index 0000000000..9ab2d6c3c4 --- /dev/null +++ b/test/pending/run/instanceOfAndTypeMatching.scala @@ -0,0 +1,193 @@ +// Summary of incorrect or questionable behavior. +// Full code and successful parts follow. + +object Summary { + class Outer { + class Inner { } + def f() = { class MethodInner ; new MethodInner } + } + + // 1 static issue: + // + // Given method in MethodInner: def g(other: MethodInner) = () + // method1.g(method1) fails to compile with type error. + // + // Note that this cannot be worked around by widening the return type + // of f() because MethodInner is declared inside of f. So there is no way + // I see for a class declared inside a method to receive members of its + // own declared type -- not only the narrow type of those from this + // instance, but ANY members, because there is no Foo#Bar syntax which will + // traverse a method. + // + // 4 runtime issues: + // + // From the outside: inner1.isInstanceOf[outer2.Inner] is true, should (maybe) be false + // From inside inner1: inner2.isInstanceOf[Outer.this.Inner] is true, should (maybe) be false + // From the outside: inner1 match { case _: outer2.Inner => true ... } is true, should definitely be false + // From inside method1: method2 match { case _: MethodInner => true ... } is true, should definitely be false + // + // Note that the fact that every test returns true on instances of MethodInner means + // that it is impossible to draw any type distinction between instances. As far as one + // can tell, they are all of the same type regardless not only of whether they were + // created on the same method invocation but whether they are contained in the same + // instance of Outer. + // + // WRT "same method invocation", see Iterator.duplicate for an example of this. +} + +// Tests + +class Outer { + class Inner { + def passOuter(other: Outer) = () // pass any Outer + def passThisType(other: Outer.this.type) = () // pass only this Outer instance + def passInner(other: Inner) = () // pass only Inners from this Outer instance + def passInner2(other: Outer.this.Inner) = () // same as above + def passInnerSharp(other: Outer#Inner) = () // pass any Inner + + def compareSimpleWithTypeMatch(other: Any) = other match { + case _: Inner => true + case _ => false + } + def compareSimpleWithInstanceOf(other: Any) = other.isInstanceOf[Inner] + + def compareSharpWithTypeMatch(other: Any) = { + other match { + case _: Outer#Inner => true + case _ => false + } + } + def compareSharpWithInstanceOf(other: Any) = other.isInstanceOf[Outer#Inner] + + def comparePathWithTypeMatch(other: Any) = other match { + case _: Outer.this.Inner => true + case _ => false + } + def comparePathWithInstanceOf(other: Any) = other.isInstanceOf[Outer.this.Inner] + } + + def f() = { + class MethodInner { + def passOuter(other: Outer) = () // pass any Outer + def passThisType(other: Outer.this.type) = () // pass only this Outer instance + def passInner(other: Inner) = () // pass only Inners from this Outer instance + def passInner2(other: Outer.this.Inner) = () // same as above + def passInnerSharp(other: Outer#Inner) = () // pass any Inner + def passMethodInner(other: MethodInner) = () // pass only MethodInners from this Outer instance + // is there any way to refer to Outer#MethodInner? Not that there should be. + + def compareWithInstanceOf(other: Any) = other.isInstanceOf[MethodInner] + def compareWithTypeMatch(other: Any) = other match { + case _: MethodInner => true + case _ => false + } + } + + new MethodInner + } +} + +object Test +{ + val outer1 = new Outer + val outer2 = new Outer + val inner1 = new outer1.Inner + val inner2 = new outer2.Inner + val method1 = outer1.f() + val method2 = outer2.f() + + def testInnerStatic = { + // these should all work + inner1.passOuter(outer1) + inner1.passOuter(outer2) + inner1.passThisType(outer1) + inner1.passInner(inner1) + inner1.passInner2(inner1) + inner1.passInnerSharp(inner1) + inner1.passInnerSharp(inner2) + + // these should all fail to compile, and do + // + // inner1.passThisType(outer2) + // inner1.passInner(inner2) + // inner1.passInner2(inner2) + } + def testInnerRuntime = { + println("testInnerRuntime\n") + + List("These should be true under any scenario: ", + inner1.isInstanceOf[outer1.Inner] , + inner1.isInstanceOf[Outer#Inner] , + inner1 match { case _: Outer#Inner => true ; case _ => false } , + inner1 match { case _: outer1.Inner => true ; case _ => false } , + inner1.compareSharpWithTypeMatch(inner2) , + inner1.compareSharpWithInstanceOf(inner2) + ) foreach println + + List("These should be true under current proposal: ", + inner1.compareSimpleWithInstanceOf(inner2) + ) foreach println + + List("These should be false under current proposal: ", + inner1.compareSimpleWithTypeMatch(inner2) , + inner1.comparePathWithTypeMatch(inner2) + ) foreach println + + List("These return true but I think should return false: ", + inner1.isInstanceOf[outer2.Inner] , // true + inner1.comparePathWithInstanceOf(inner2) // true + ) foreach println + + List("These are doing the wrong thing under current proposal", + inner1 match { case _: outer2.Inner => true ; case _ => false } // should be false + ) foreach println + } + + def testMethodInnerStatic = { + // these should all work + method1.passOuter(outer1) + method1.passOuter(outer2) + method1.passThisType(outer1) + method1.passInner(inner1) + method1.passInner2(inner1) + method1.passInnerSharp(inner1) + method1.passInnerSharp(inner2) + // This fails with: + // + // a.scala:114: error: type mismatch; + // found : Test.method1.type (with underlying type MethodInner forSome { type MethodInner <: java.lang.Object with ScalaObject{def passOuter(other: Outer): Unit; def passThisType(other: Test.outer1.type): Unit; def passInner(other: Test.outer1.Inner): Unit; def passInner2(other: Test.outer1.Inner): Unit; def passInnerSharp(other: Outer#Inner): Unit; def passMethodInner(other: MethodInner): Unit} }) + // required: MethodInner where type MethodInner <: java.lang.Object with ScalaObject{def passOuter(other: Outer): Unit; def passThisType(other: Test.outer1.type): Unit; def passInner(other: Test.outer1.Inner): Unit; def passInner2(other: Test.outer1.Inner): Unit; def passInnerSharp(other: Outer#Inner): Unit; def passMethodInner(other: MethodInner): Unit} + // method1.passMethodInner(method1) + // ^ + // method1.passMethodInner(method1) + + // these should all fail to compile, and do + // + // method1.passThisType(outer2) + // method1.passInner(inner2) + // method1.passInner2(inner2) + // method1.passMethodInner(method2) + } + + def testMethodInnerRuntime = { + println("\ntestMethodInnerRuntime\n") + + List("These should be true under any scenario: ", + method1.compareWithInstanceOf(method1) , + method1.compareWithTypeMatch(method1) + ) foreach println + + List("These should be true under current proposal: ", + method1.compareWithInstanceOf(method2) + ) foreach println + + List("These are doing the wrong thing under current proposal", + method1.compareWithTypeMatch(method2) // should be false + ) foreach println + } + + def main(args: Array[String]): Unit = { + testInnerRuntime + testMethodInnerRuntime + } +} diff --git a/test/pending/run/subarray.check b/test/pending/run/subarray.check deleted file mode 100644 index 814f4a4229..0000000000 --- a/test/pending/run/subarray.check +++ /dev/null @@ -1,2 +0,0 @@ -one -two diff --git a/test/pending/run/bug2365/bug2365.javaopts b/test/pending/script/bug2365.javaopts index 357e033c1c..357e033c1c 100644 --- a/test/pending/run/bug2365/bug2365.javaopts +++ b/test/pending/script/bug2365.javaopts diff --git a/test/pending/run/bug2365/Test.scala b/test/pending/script/bug2365/Test.scala index 92b58f4a25..53581d256b 100644 --- a/test/pending/run/bug2365/Test.scala +++ b/test/pending/script/bug2365/Test.scala @@ -20,11 +20,11 @@ object Test def test(withF0: StructF0 => Int): Int = { // Some large jar - val ivyJar = File("/local/lib/java/ivy.jar").toURL + val jar = File("../../../../lib/scalacheck.jar").toURL // load a class in a separate loader that will be passed to A - val loader = new java.net.URLClassLoader(Array(File(".").toURL, ivyJar)) + val loader = new java.net.URLClassLoader(Array(File(".").toURL, jar)) // load a real class to fill perm gen space - Class.forName("org.apache.ivy.Ivy", true, loader).newInstance + Class.forName("org.scalacheck.Properties", true, loader).newInstance // create a class from another class loader with an apply: Int method val b = Class.forName("B", true, loader).newInstance diff --git a/test/pending/script/bug2365/bug2365.scala b/test/pending/script/bug2365/bug2365.scala new file mode 100755 index 0000000000..b5e05325cf --- /dev/null +++ b/test/pending/script/bug2365/bug2365.scala @@ -0,0 +1,9 @@ +#!/bin/sh +# +# This script should fail with any build of scala where #2365 +# is not fixed, and otherwise succeed. Failure means running out +# of PermGen space. +# + +scalac -cp .:/local/lib/java/ivy.jar Test.scala +JAVA_OPTS="-XX:MaxPermSize=25M -verbose:gc" scalac -cp $CP Test diff --git a/test/files/jvm/NestedAnnotations.java b/test/support/annotations/NestedAnnotations.java index 8f2327dcce..8f2327dcce 100644 --- a/test/files/jvm/NestedAnnotations.java +++ b/test/support/annotations/NestedAnnotations.java diff --git a/test/files/jvm/OuterEnum.java b/test/support/annotations/OuterEnum.java index 75d3f34223..75d3f34223 100644 --- a/test/files/jvm/OuterEnum.java +++ b/test/support/annotations/OuterEnum.java diff --git a/test/files/jvm/OuterTParams.java b/test/support/annotations/OuterTParams.java index 1d3db49fcf..1d3db49fcf 100644 --- a/test/files/jvm/OuterTParams.java +++ b/test/support/annotations/OuterTParams.java diff --git a/test/files/jvm/SourceAnnotation.java b/test/support/annotations/SourceAnnotation.java index 047751ddfe..047751ddfe 100644 --- a/test/files/jvm/SourceAnnotation.java +++ b/test/support/annotations/SourceAnnotation.java diff --git a/test/files/jvm/mkAnnotationsJar.sh b/test/support/annotations/mkAnnotationsJar.sh index 3d69351165..3d69351165 100755 --- a/test/files/jvm/mkAnnotationsJar.sh +++ b/test/support/annotations/mkAnnotationsJar.sh |