summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/disabled/pos/bug2919.scala12
-rw-r--r--test/disabled/run/script-positions.scala86
-rw-r--r--test/files/jvm/methvsfield/methvsfield.jar.desired.sha11
-rw-r--r--test/files/jvm/methvsfield/methvsfield.java11
-rw-r--r--test/files/jvm/methvsfield/methvsfield.scala4
-rw-r--r--test/files/jvm/t3470.check3
-rw-r--r--test/files/jvm/t3470.scala30
-rw-r--r--test/files/neg/array-not-seq.check16
-rw-r--r--test/files/neg/array-not-seq.flags1
-rw-r--r--test/files/neg/array-not-seq.scala26
-rw-r--r--test/files/neg/bug3189.check7
-rw-r--r--test/files/neg/bug3189.scala3
-rw-r--r--test/files/neg/spec-overrides.check7
-rw-r--r--test/files/neg/spec-overrides.scala26
-rw-r--r--test/files/neg/t3453.check21
-rw-r--r--test/files/neg/t3453.scala66
-rw-r--r--test/files/pos/bug2187-2.scala7
-rw-r--r--test/files/pos/bug2409/J.java4
-rw-r--r--test/files/pos/bug2409/bug2409.scala1
-rw-r--r--test/files/pos/bug2691.scala10
-rw-r--r--test/files/pos/bug2939.scala13
-rw-r--r--test/files/pos/bug2945.scala12
-rw-r--r--test/files/pos/bug3020.scala9
-rw-r--r--test/files/pos/bug3252.flags1
-rw-r--r--test/files/pos/bug3252.scala15
-rw-r--r--test/files/pos/bug3411.scala8
-rw-r--r--test/files/pos/bug3430.flags1
-rw-r--r--test/files/pos/bug3430.scala13
-rw-r--r--test/files/pos/spec-constr.scala7
-rw-r--r--test/files/pos/spec-doubledef.scala14
-rw-r--r--test/files/pos/spec-multiplectors.scala3
-rw-r--r--test/files/pos/t3404/Base.java3
-rw-r--r--test/files/pos/t3404/Derived.scala3
-rw-r--r--test/files/pos/t3417.scala11
-rw-r--r--test/files/pos/t3429/A.scala12
-rw-r--r--test/files/pos/t3429/Test.java3
-rw-r--r--test/files/run/bug2958.scala16
-rw-r--r--test/files/run/bug3050.scala9
-rw-r--r--test/files/run/bug3395.check2
-rw-r--r--test/files/run/bug3395.scala13
-rw-r--r--test/files/run/colltest1.scala6
-rw-r--r--test/files/run/equality.scala2
-rw-r--r--test/files/run/groupby.scala18
-rw-r--r--test/files/run/iterator3444.scala23
-rw-r--r--test/files/run/matcharraytail.check2
-rw-r--r--test/files/run/nodebuffer-array.check3
-rw-r--r--test/files/run/nodebuffer-array.scala15
-rw-r--r--test/files/run/patmat-seqs.check13
-rw-r--r--test/files/run/patmat-seqs.scala42
-rw-r--r--test/files/run/spec-ame.check2
-rw-r--r--test/files/run/spec-ame.scala17
-rw-r--r--test/files/run/spec-overrides.check0
-rw-r--r--test/files/run/spec-overrides.scala20
-rw-r--r--test/files/run/unittest_iterator.scala9
-rw-r--r--test/files/scalacheck/.gitignore0
-rw-r--r--test/pending/pos/bug3420.flags1
-rw-r--r--test/pending/pos/bug3420.scala5
-rw-r--r--test/pending/run/bug3150.scala10
58 files changed, 676 insertions, 22 deletions
diff --git a/test/disabled/pos/bug2919.scala b/test/disabled/pos/bug2919.scala
new file mode 100644
index 0000000000..5e51cf9de7
--- /dev/null
+++ b/test/disabled/pos/bug2919.scala
@@ -0,0 +1,12 @@
+import javax.xml.bind.annotation.adapters.XmlAdapter
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
+
+case class Link(
+ @XmlJavaTypeAdapter(classOf[StringOptionAdapter]) val title: Option[String]
+)
+
+class StringOptionAdapter extends XmlAdapter[String, Option[String]] {
+ def unmarshal(str: String) = error("stub")
+ def marshal(op: Option[String]) = error("Stub")
+}
+
diff --git a/test/disabled/run/script-positions.scala b/test/disabled/run/script-positions.scala
new file mode 100644
index 0000000000..6982ed8440
--- /dev/null
+++ b/test/disabled/run/script-positions.scala
@@ -0,0 +1,86 @@
+import scala.tools.nsc._
+import util.stringFromStream
+
+// Testing "scripts" without the platform delights which accompany actual scripts.
+object Scripts {
+
+ val test1 =
+"""#!/bin/sh
+ exec scala $0 $@
+!#
+
+println("statement 1")
+println("statement 2".thisisborked)
+println("statement 3")
+"""
+
+ val output1 =
+"""thisisborked.scala:6: error: value thisisborked is not a member of java.lang.String
+println("statement 2".thisisborked)
+ ^
+one error found"""
+ val test2 =
+"""#!scala
+// foo
+// bar
+!#
+
+val x = "line 6"
+val y = "line 7"
+val z "line 8""""
+
+ val output2 =
+"""bob.scala:8: error: '=' expected but string literal found.
+val z "line 8"
+ ^
+bob.scala:8: error: illegal start of simple expression
+val z "line 8"
+ ^
+two errors found"""
+}
+
+object Test {
+ import Scripts._
+
+ def settings = new GenericRunnerSettings(println _)
+ settings.nocompdaemon.value = true
+
+ def runScript(code: String): String =
+ stringFromStream(stream =>
+ Console.withOut(stream) {
+ Console.withErr(stream) {
+ ScriptRunner.runCommand(settings, code, Nil)
+ }
+ }
+ )
+
+ val tests: List[(String, String)] = List(
+ test1 -> output1,
+ test2 -> output2
+ )
+ // def lines(s: String) = s split """\r\n|\r|\n""" toList
+ def lines(s: String) = s split "\\n" toList
+
+ // strip the random temp filename from error msgs
+ def stripFilename(s: String) = (s indexOf ".scala:") match {
+ case -1 => s
+ case idx => s drop (idx + 7)
+ }
+ def toLines(text: String) = lines(text) map stripFilename
+
+ def main(args: Array[String]): Unit = {
+ for ((code, expected) <- tests) {
+ val out = toLines(runScript(code))
+ val exp = toLines(expected)
+ val nomatch = out zip exp filter { case (x, y) => x != y }
+ val success = out.size == exp.size && nomatch.isEmpty
+
+ assert(
+ success,
+ "Output doesn't match expected:\n" +
+ "Expected:\n" + expected +
+ "Actual:\n" + out.mkString("\n")
+ )
+ }
+ }
+}
diff --git a/test/files/jvm/methvsfield/methvsfield.jar.desired.sha1 b/test/files/jvm/methvsfield/methvsfield.jar.desired.sha1
deleted file mode 100644
index 8c01532b88..0000000000
--- a/test/files/jvm/methvsfield/methvsfield.jar.desired.sha1
+++ /dev/null
@@ -1 +0,0 @@
-be8454d5e7751b063ade201c225dcedefd252775 ?methvsfield.jar
diff --git a/test/files/jvm/methvsfield/methvsfield.java b/test/files/jvm/methvsfield/methvsfield.java
deleted file mode 100644
index dadc98669a..0000000000
--- a/test/files/jvm/methvsfield/methvsfield.java
+++ /dev/null
@@ -1,11 +0,0 @@
-// This should be compiled with javac and saved
-// in ../lib/methvsfield.jar .
-class MethVsField
-{
- int three = 3;
-
- int three()
- {
- return 3;
- }
-}
diff --git a/test/files/jvm/methvsfield/methvsfield.scala b/test/files/jvm/methvsfield/methvsfield.scala
deleted file mode 100644
index e9795ec6a8..0000000000
--- a/test/files/jvm/methvsfield/methvsfield.scala
+++ /dev/null
@@ -1,4 +0,0 @@
-// bug #1062
-object Test extends Application {
- println((new MethVsField).three)
-}
diff --git a/test/files/jvm/t3470.check b/test/files/jvm/t3470.check
new file mode 100644
index 0000000000..94cb526756
--- /dev/null
+++ b/test/files/jvm/t3470.check
@@ -0,0 +1,3 @@
+A: started: 1
+A: started: 2
+A: started: 3
diff --git a/test/files/jvm/t3470.scala b/test/files/jvm/t3470.scala
new file mode 100644
index 0000000000..5e4242cdd7
--- /dev/null
+++ b/test/files/jvm/t3470.scala
@@ -0,0 +1,30 @@
+import scala.actors._
+
+object Test {
+
+ 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]) {
+ val a = new Actor { var c = 0; def act() = { c += 1; println("A: started: " + c) } }
+ a.start()
+ expectActorState(a, Actor.State.Terminated)
+ a.restart()
+ expectActorState(a, Actor.State.Terminated)
+ a.restart()
+ }
+
+}
diff --git a/test/files/neg/array-not-seq.check b/test/files/neg/array-not-seq.check
new file mode 100644
index 0000000000..bd72bb4e13
--- /dev/null
+++ b/test/files/neg/array-not-seq.check
@@ -0,0 +1,16 @@
+array-not-seq.scala:2: error: An Array will no longer match as Seq[_].
+ def f1(x: Any) = x.isInstanceOf[Seq[_]]
+ ^
+array-not-seq.scala:4: error: An Array will no longer match as Seq[_].
+ case _: Seq[_] => true
+ ^
+error: An Array will no longer match as Seq[_].
+array-not-seq.scala:16: error: An Array will no longer match as Seq[_].
+ case (Some(_: Seq[_]), Nil, _) => 1
+ ^
+error: An Array will no longer match as Seq[_].
+array-not-seq.scala:15: error: An Array will no longer match as Seq[_].
+ def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match {
+ ^
+error: An Array will no longer match as Seq[_].
+7 errors found
diff --git a/test/files/neg/array-not-seq.flags b/test/files/neg/array-not-seq.flags
new file mode 100644
index 0000000000..4e9f7e4a56
--- /dev/null
+++ b/test/files/neg/array-not-seq.flags
@@ -0,0 +1 @@
+-Xmigration -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/array-not-seq.scala b/test/files/neg/array-not-seq.scala
new file mode 100644
index 0000000000..07a2898d88
--- /dev/null
+++ b/test/files/neg/array-not-seq.scala
@@ -0,0 +1,26 @@
+object Test {
+ def f1(x: Any) = x.isInstanceOf[Seq[_]]
+ def f2(x: Any) = x match {
+ case _: Seq[_] => true
+ case _ => false
+ }
+
+ def f3(x: Any) = x match {
+ case _: Array[_] => true
+ case _ => false
+ }
+
+ def f4(x: Any) = x.isInstanceOf[Traversable[_]]
+
+ def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match {
+ case (Some(_: Seq[_]), Nil, _) => 1
+ case (None, List(_: List[_], _), _) => 2
+ case _ => 3
+ }
+
+ def main(args: Array[String]): Unit = {
+ // println(f1(Array(1)))
+ // println(f2(Array(1)))
+ // println(f3(Array(1))
+ }
+}
diff --git a/test/files/neg/bug3189.check b/test/files/neg/bug3189.check
new file mode 100644
index 0000000000..520644fd43
--- /dev/null
+++ b/test/files/neg/bug3189.check
@@ -0,0 +1,7 @@
+bug3189.scala:2: error: illegal start of simple pattern
+ val Array(a,b*) = ("": Any)
+ ^
+bug3189.scala:3: error: ')' expected but '}' found.
+}
+^
+two errors found
diff --git a/test/files/neg/bug3189.scala b/test/files/neg/bug3189.scala
new file mode 100644
index 0000000000..4ea4bb7581
--- /dev/null
+++ b/test/files/neg/bug3189.scala
@@ -0,0 +1,3 @@
+object A {
+ val Array(a,b*) = ("": Any)
+} \ No newline at end of file
diff --git a/test/files/neg/spec-overrides.check b/test/files/neg/spec-overrides.check
new file mode 100644
index 0000000000..639186af40
--- /dev/null
+++ b/test/files/neg/spec-overrides.check
@@ -0,0 +1,7 @@
+spec-overrides.scala:8: error: Type parameter has to be specialized at least for the same types as in the overridden method. Missing types: Int
+ override def a[@specialized(Double) T](t: T): List[T] = Nil
+ ^
+spec-overrides.scala:12: error: Type parameter has to be specialized at least for the same types as in the overridden method. Missing types: Int
+ override def a[T](t: T): List[T] = Nil
+ ^
+two errors found
diff --git a/test/files/neg/spec-overrides.scala b/test/files/neg/spec-overrides.scala
new file mode 100644
index 0000000000..8c92b8ee25
--- /dev/null
+++ b/test/files/neg/spec-overrides.scala
@@ -0,0 +1,26 @@
+class P {
+ def a[@specialized(Int) T](t: T): List[T] = List(t)
+}
+class FX extends P {
+ override def a[@specialized(Int) T](t: T): List[T] = Nil
+}
+class FX1 extends P {
+ override def a[@specialized(Double) T](t: T): List[T] = Nil
+}
+
+class FX2 extends P {
+ override def a[T](t: T): List[T] = Nil
+}
+
+object Test extends Application {
+ val fx = new FX
+ val p = new P
+
+ println(fx.a(3))
+ println((fx: P).a(3))
+ println((fx: P).a(3.0))
+
+
+ // val d = new Derived[Int]
+ // println((d: Base[Int]).m(10))
+}
diff --git a/test/files/neg/t3453.check b/test/files/neg/t3453.check
new file mode 100644
index 0000000000..52c948128c
--- /dev/null
+++ b/test/files/neg/t3453.check
@@ -0,0 +1,21 @@
+t3453.scala:18: error: type mismatch;
+ found : A
+ required: B
+ new A
+ ^
+t3453.scala:36: error: type mismatch;
+ found : A
+ required: B
+ new A
+ ^
+t3453.scala:50: error: type mismatch;
+ found : A
+ required: B
+ new A
+ ^
+t3453.scala:64: error: type mismatch;
+ found : A
+ required: B
+ new A
+ ^
+four errors found
diff --git a/test/files/neg/t3453.scala b/test/files/neg/t3453.scala
new file mode 100644
index 0000000000..090b777151
--- /dev/null
+++ b/test/files/neg/t3453.scala
@@ -0,0 +1,66 @@
+// test shadowing of implicits by synonymous non-implicit symbols
+// whether they be inherited, imported (explicitly or using a wildcard) or defined directly
+class A
+class B
+
+trait S {
+ implicit def aToB(a: A): B = new B
+}
+
+class T1 extends S {
+ def x: B = {
+ val aToB = 3
+ // ok: doesn't compile, because aToB method requires 'T.this.' prefix
+ //aToB(new A)
+
+ // bug: compiles, using T.this.aToB,
+ // despite it not being accessible without a prefix
+ new A
+ }
+}
+
+object O {
+ implicit def aToB(a: A): B = new B
+}
+
+class T2a {
+ import O._
+
+ def x: B = {
+ val aToB = 3
+ // ok: doesn't compile, because aToB method requires 'T.this.' prefix
+ //aToB(new A)
+
+ // bug: compiles, using T.this.aToB,
+ // despite it not being accessible without a prefix
+ new A
+ }
+}
+
+class T2b {
+ import O.aToB
+
+ def x: B = {
+ val aToB = 3
+ // ok: doesn't compile, because aToB method requires 'T.this.' prefix
+ //aToB(new A)
+
+ // bug: compiles, using T.this.aToB,
+ // despite it not being accessible without a prefix
+ new A
+ }
+}
+
+class T3 {
+ implicit def aToB(a: A): B = new B
+
+ def x: B = {
+ val aToB = 3
+ // ok: doesn't compile, because aToB method requires 'T.this.' prefix
+ //aToB(new A)
+
+ // bug: compiles, using T.this.aToB,
+ // despite it not being accessible without a prefix
+ new A
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/bug2187-2.scala b/test/files/pos/bug2187-2.scala
new file mode 100644
index 0000000000..3f2742dd89
--- /dev/null
+++ b/test/files/pos/bug2187-2.scala
@@ -0,0 +1,7 @@
+class Test {
+ def test[A](list: List[A]) = list match {
+ case Seq(x, y) => "xy"
+ case Seq(x) => "x"
+ case _ => "something else"
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/bug2409/J.java b/test/files/pos/bug2409/J.java
new file mode 100644
index 0000000000..6b7c45ff6d
--- /dev/null
+++ b/test/files/pos/bug2409/J.java
@@ -0,0 +1,4 @@
+class J {
+ static class J2 { }
+ J(J2 j2) { }
+}
diff --git a/test/files/pos/bug2409/bug2409.scala b/test/files/pos/bug2409/bug2409.scala
new file mode 100644
index 0000000000..5775008fc4
--- /dev/null
+++ b/test/files/pos/bug2409/bug2409.scala
@@ -0,0 +1 @@
+object S { new J(null) } \ No newline at end of file
diff --git a/test/files/pos/bug2691.scala b/test/files/pos/bug2691.scala
new file mode 100644
index 0000000000..1037b53601
--- /dev/null
+++ b/test/files/pos/bug2691.scala
@@ -0,0 +1,10 @@
+object Breakdown {
+ def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there"))
+}
+object Test {
+ 42 match {
+ case Breakdown("") => // needed to trigger bug
+ case Breakdown("foo") => // needed to trigger bug
+ case Breakdown("", who) => println ("hello " + who)
+ }
+}
diff --git a/test/files/pos/bug2939.scala b/test/files/pos/bug2939.scala
new file mode 100644
index 0000000000..3be4d4d561
--- /dev/null
+++ b/test/files/pos/bug2939.scala
@@ -0,0 +1,13 @@
+import collection._
+
+object Proxies {
+ class C1 extends MapProxy[Int,Int] { def self = Map[Int,Int]() }
+ class C2 extends mutable.MapProxy[Int,Int] { def self = mutable.Map[Int,Int]() }
+ class C3 extends immutable.MapProxy[Int,Int] { def self = immutable.Map[Int,Int]() }
+
+ class C4 extends SetProxy[Int] { def self = Set[Int]() }
+ class C5 extends mutable.SetProxy[Int] { def self = mutable.Set[Int]() }
+ class C6 extends immutable.SetProxy[Int] { def self = immutable.Set[Int]() }
+
+ class C7 extends SeqProxy[Int] { def self = Seq[Int]() }
+} \ No newline at end of file
diff --git a/test/files/pos/bug2945.scala b/test/files/pos/bug2945.scala
new file mode 100644
index 0000000000..762bdb61e1
--- /dev/null
+++ b/test/files/pos/bug2945.scala
@@ -0,0 +1,12 @@
+object Foo {
+ def test(s: String) = {
+ (s: Seq[Char]) match {
+ case Seq('f', 'o', 'o', ' ', rest1 @ _*) =>
+ rest1
+ case Seq('b', 'a', 'r', ' ', ' ', rest2 @ _*) =>
+ rest2
+ case _ =>
+ s
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/bug3020.scala b/test/files/pos/bug3020.scala
new file mode 100644
index 0000000000..016563e27f
--- /dev/null
+++ b/test/files/pos/bug3020.scala
@@ -0,0 +1,9 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ var x = true
+
+ ( { if (x) new scala.util.Random() } .asInstanceOf[Runnable] )
+ }
+}
+
+
diff --git a/test/files/pos/bug3252.flags b/test/files/pos/bug3252.flags
new file mode 100644
index 0000000000..eb4d19bcb9
--- /dev/null
+++ b/test/files/pos/bug3252.flags
@@ -0,0 +1 @@
+-optimise \ No newline at end of file
diff --git a/test/files/pos/bug3252.scala b/test/files/pos/bug3252.scala
new file mode 100644
index 0000000000..4b8e862714
--- /dev/null
+++ b/test/files/pos/bug3252.scala
@@ -0,0 +1,15 @@
+class A {
+ def f(x : Boolean) : Thread = {
+ g {
+ x match {
+ case false =>
+ B.h { }
+ }
+ }
+ }
+
+ private def g[T](block : => T) = error("")
+}
+object B {
+ def h(block : => Unit) : Nothing = error("")
+} \ No newline at end of file
diff --git a/test/files/pos/bug3411.scala b/test/files/pos/bug3411.scala
new file mode 100644
index 0000000000..b58e52db8d
--- /dev/null
+++ b/test/files/pos/bug3411.scala
@@ -0,0 +1,8 @@
+object A {
+ def g(c: PartialFunction[Any,Unit]) {}
+
+ def f {
+ lazy val x = 0
+ g { case `x` => }
+ }
+}
diff --git a/test/files/pos/bug3430.flags b/test/files/pos/bug3430.flags
new file mode 100644
index 0000000000..eb4d19bcb9
--- /dev/null
+++ b/test/files/pos/bug3430.flags
@@ -0,0 +1 @@
+-optimise \ No newline at end of file
diff --git a/test/files/pos/bug3430.scala b/test/files/pos/bug3430.scala
new file mode 100644
index 0000000000..3129c6276a
--- /dev/null
+++ b/test/files/pos/bug3430.scala
@@ -0,0 +1,13 @@
+// package com.example
+
+object A {
+ def f1(f: String => Boolean) = f("a")
+
+ def f2(): Boolean =
+ f1 { s1 =>
+ f1 { s2 =>
+ while (true) { }
+ true
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/spec-constr.scala b/test/files/pos/spec-constr.scala
new file mode 100644
index 0000000000..e908b65a41
--- /dev/null
+++ b/test/files/pos/spec-constr.scala
@@ -0,0 +1,7 @@
+class SparseArray2[@specialized(Int) T:ClassManifest](val maxSize: Int, initialLength:Int = 3) {
+ private var data = new Array[T](initialLength);
+ private var index = new Array[Int](initialLength);
+
+ // comment out to compile correctly
+ data.length + 3;
+}
diff --git a/test/files/pos/spec-doubledef.scala b/test/files/pos/spec-doubledef.scala
new file mode 100644
index 0000000000..014f683065
--- /dev/null
+++ b/test/files/pos/spec-doubledef.scala
@@ -0,0 +1,14 @@
+object Test {
+ def fn[@specialized T, @specialized U](t : T => Int, u : U => Int) : T =
+ null.asInstanceOf[T]
+}
+
+trait A[@specialized(Int) T] {
+ var value: T
+ def getWith[@specialized(Int) Z](f: T => Z) = f(value)
+}
+
+class C extends A[Int] {
+ var value = 10
+ override def getWith[@specialized(Int) Z](f: Int => Z) = f(value)
+}
diff --git a/test/files/pos/spec-multiplectors.scala b/test/files/pos/spec-multiplectors.scala
new file mode 100644
index 0000000000..8434a13936
--- /dev/null
+++ b/test/files/pos/spec-multiplectors.scala
@@ -0,0 +1,3 @@
+class Spec[@specialized(Int) A]() {
+ def this(n: Int) = this()
+}
diff --git a/test/files/pos/t3404/Base.java b/test/files/pos/t3404/Base.java
new file mode 100644
index 0000000000..c5df18cc9f
--- /dev/null
+++ b/test/files/pos/t3404/Base.java
@@ -0,0 +1,3 @@
+abstract class Base {
+ abstract Class foo(Object o);
+} \ No newline at end of file
diff --git a/test/files/pos/t3404/Derived.scala b/test/files/pos/t3404/Derived.scala
new file mode 100644
index 0000000000..16976fe3d5
--- /dev/null
+++ b/test/files/pos/t3404/Derived.scala
@@ -0,0 +1,3 @@
+class Derived extends Base {
+ def foo(a: AnyRef) = classOf[String]
+} \ No newline at end of file
diff --git a/test/files/pos/t3417.scala b/test/files/pos/t3417.scala
new file mode 100644
index 0000000000..d2de1608aa
--- /dev/null
+++ b/test/files/pos/t3417.scala
@@ -0,0 +1,11 @@
+trait X extends NotNull {
+ def foo = 1
+}
+
+trait Y extends Object with NotNull {
+ def bar = 1
+}
+
+class Z extends NotNull
+
+class W extends Object with NotNull
diff --git a/test/files/pos/t3429/A.scala b/test/files/pos/t3429/A.scala
new file mode 100644
index 0000000000..80785db51d
--- /dev/null
+++ b/test/files/pos/t3429/A.scala
@@ -0,0 +1,12 @@
+class A {
+ @Test(exc = classOf[Exception])
+ def myTestMethod = 0
+}
+// rytz@chara:~/scala/trunk/sandbox$ javac Test.java
+// rytz@chara:~/scala/trunk/sandbox$ ../build/pack/bin/scalac A.scala
+// A.scala:2: error: type mismatch;
+// found : java.lang.Class[Exception](classOf[java.lang.Exception])
+// required: java.lang.Class
+// @Test(exc = classOf[Exception])
+// ^
+// one error found \ No newline at end of file
diff --git a/test/files/pos/t3429/Test.java b/test/files/pos/t3429/Test.java
new file mode 100644
index 0000000000..e7c57c90c5
--- /dev/null
+++ b/test/files/pos/t3429/Test.java
@@ -0,0 +1,3 @@
+public @interface Test {
+ public Class exc() default Exception.class;
+} \ No newline at end of file
diff --git a/test/files/run/bug2958.scala b/test/files/run/bug2958.scala
new file mode 100644
index 0000000000..dcd24ecc36
--- /dev/null
+++ b/test/files/run/bug2958.scala
@@ -0,0 +1,16 @@
+object Test {
+ def f(args: Array[String]) = args match {
+ case Array("-p", prefix, from, to) =>
+ prefix + from + to
+
+ case Array(from, to) =>
+ from + to
+
+ case _ =>
+ "default"
+ }
+
+ def main(args: Array[String]) {
+ assert(f(Array("1", "2")) == "12")
+ }
+} \ No newline at end of file
diff --git a/test/files/run/bug3050.scala b/test/files/run/bug3050.scala
new file mode 100644
index 0000000000..aaec99ec14
--- /dev/null
+++ b/test/files/run/bug3050.scala
@@ -0,0 +1,9 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ val x =
+ try { ("": Any) match { case List(_*) => true } }
+ catch { case _ => false }
+
+ assert(x == false)
+ }
+}
diff --git a/test/files/run/bug3395.check b/test/files/run/bug3395.check
new file mode 100644
index 0000000000..5f5521fae2
--- /dev/null
+++ b/test/files/run/bug3395.check
@@ -0,0 +1,2 @@
+abc
+def
diff --git a/test/files/run/bug3395.scala b/test/files/run/bug3395.scala
new file mode 100644
index 0000000000..b4990a1716
--- /dev/null
+++ b/test/files/run/bug3395.scala
@@ -0,0 +1,13 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ Seq("") match {
+ case Seq("") => println("abc")
+ case Seq(_, _, x) => println(x)
+ }
+
+ Seq(1, 2, "def") match {
+ case Seq("") => println("abc")
+ case Seq(_, _, x) => println(x)
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala
index 557282cb8d..943fe4c4e7 100644
--- a/test/files/run/colltest1.scala
+++ b/test/files/run/colltest1.scala
@@ -2,8 +2,7 @@ import collection._
object Test extends Application {
- def orderedTraversableTest(empty: Traversable[Int])
- {
+ def orderedTraversableTest(empty: Traversable[Int]) {
println("new test starting with "+empty)
assert(empty.isEmpty)
val ten = empty ++ List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@@ -113,6 +112,9 @@ object Test extends Application {
assert(ten.endsWith(List(9, 10)))
assert(ten.endsWith(List()))
assert(ten.indexOfSlice(List(3, 4, 5)) == 2, ten.indexOfSlice(List(3, 4, 5)))
+ assert(ten.lastIndexOfSlice(List(8, 9, 10)) == 7)
+ assert(ten.lastIndexOfSlice(List(1, 2, 3)) == 0)
+ assert(ten.lastIndexOfSlice(List(9, 10, 11)) == -1)
assert(ten contains 1)
assert(ten contains 10)
assert(!(ten contains 0))
diff --git a/test/files/run/equality.scala b/test/files/run/equality.scala
index 6498b232e1..ff59898821 100644
--- a/test/files/run/equality.scala
+++ b/test/files/run/equality.scala
@@ -34,5 +34,7 @@ object Test
// negatives
val bigLong = new java.util.concurrent.atomic.AtomicLong(Long.MaxValue)
assert(-1 != bigLong && bigLong != -1) // bigLong.intValue() == -1
+ assert(BigDecimal(1.1) != 1L)
+ assert(1L != BigDecimal(1.1))
}
}
diff --git a/test/files/run/groupby.scala b/test/files/run/groupby.scala
new file mode 100644
index 0000000000..a751e65e80
--- /dev/null
+++ b/test/files/run/groupby.scala
@@ -0,0 +1,18 @@
+
+
+
+// Fixes #3422
+object Test {
+
+ def main(args: Array[String]) {
+ val arr = Array.range(0,10)
+ val map = arr groupBy (_%2)
+ val v1 = map(0)
+ val v2 = map(0)
+ // this should hold, of course, assuming also that group by returns a regular
+ // map implementation, and does nothing fancy - and it should return just a
+ // hash map by default.
+ assert(v1 eq v2)
+ }
+
+}
diff --git a/test/files/run/iterator3444.scala b/test/files/run/iterator3444.scala
new file mode 100644
index 0000000000..1d0713addc
--- /dev/null
+++ b/test/files/run/iterator3444.scala
@@ -0,0 +1,23 @@
+
+
+// ticked #3444
+object Test {
+
+ def main(args: Array[String]) {
+ val it = (1 to 12).toSeq.iterator
+
+ assert(it.next == 1)
+ assert(it.take(2).toList == List(2, 3))
+
+ val jt = (4 to 12).toSeq.iterator
+ assert(jt.next == 4)
+ assert(jt.drop(5).toList == List(10, 11, 12))
+
+ val kt = (1 until 10).toSeq.iterator
+ assert(kt.drop(50).toList == Nil)
+
+ val mt = (1 until 5).toSeq.iterator
+ assert(mt.take(50).toList == List(1, 2, 3, 4))
+ }
+
+}
diff --git a/test/files/run/matcharraytail.check b/test/files/run/matcharraytail.check
index 15381501a9..f2844d41a9 100644
--- a/test/files/run/matcharraytail.check
+++ b/test/files/run/matcharraytail.check
@@ -1,2 +1,2 @@
Array(foo, bar, baz)
-ArrayBuffer(bar, baz)
+Vector(bar, baz)
diff --git a/test/files/run/nodebuffer-array.check b/test/files/run/nodebuffer-array.check
new file mode 100644
index 0000000000..49f8bfaf8d
--- /dev/null
+++ b/test/files/run/nodebuffer-array.check
@@ -0,0 +1,3 @@
+<entry>
+ <elem>a</elem><elem>b</elem><elem>c</elem>
+ </entry>
diff --git a/test/files/run/nodebuffer-array.scala b/test/files/run/nodebuffer-array.scala
new file mode 100644
index 0000000000..f9cfbc50df
--- /dev/null
+++ b/test/files/run/nodebuffer-array.scala
@@ -0,0 +1,15 @@
+object Test {
+
+ def f(s: String) = {
+ <entry>
+ {
+ for (item <- s split ',') yield
+ <elem>{ item }</elem>
+ }
+ </entry>
+ }
+
+ def main(args: Array[String]): Unit = {
+ println(f("a,b,c"))
+ }
+}
diff --git a/test/files/run/patmat-seqs.check b/test/files/run/patmat-seqs.check
new file mode 100644
index 0000000000..bb2a5ee44a
--- /dev/null
+++ b/test/files/run/patmat-seqs.check
@@ -0,0 +1,13 @@
+s3
+s2
+s1
+s0
+ss6
+d
+s3
+s3
+d
+s1
+s3
+d
+d
diff --git a/test/files/run/patmat-seqs.scala b/test/files/run/patmat-seqs.scala
new file mode 100644
index 0000000000..b5c47b4b4b
--- /dev/null
+++ b/test/files/run/patmat-seqs.scala
@@ -0,0 +1,42 @@
+object Test {
+ def f1(x: Any) = x match {
+ case Seq(1, 2, 3) => "s3"
+ case Seq(4, 5) => "s2"
+ case Seq(7) => "s1"
+ case Nil => "s0"
+ case Seq(_, _, _, _, _, x: String) => "ss6"
+ case _ => "d"
+ }
+
+ def f2(x: Any) = x match {
+ case Seq("a", "b", _*) => "s2"
+ case Seq(1, _*) => "s1"
+ case Seq(5, 6, 7, _*) => "s3"
+ case _ => "d"
+ }
+
+ def main(args: Array[String]): Unit = {
+ val xs1 = List(
+ List(1,2,3),
+ List(4,5),
+ Vector(7),
+ Seq(),
+ Seq(1, 2, 3, 4, 5, "abcd"),
+ "abc"
+ ) map f1
+
+ xs1 foreach println
+
+ val xs2 = List(
+ Seq(5, 6, 7),
+ Seq(5, 6, 7, 8, 9),
+ Seq("a"),
+ Seq(1, 6, 7),
+ List(5, 6, 7),
+ Nil,
+ 5
+ ) map f2
+
+ xs2 foreach println
+ }
+}
diff --git a/test/files/run/spec-ame.check b/test/files/run/spec-ame.check
new file mode 100644
index 0000000000..afa12db4df
--- /dev/null
+++ b/test/files/run/spec-ame.check
@@ -0,0 +1,2 @@
+abc
+10
diff --git a/test/files/run/spec-ame.scala b/test/files/run/spec-ame.scala
new file mode 100644
index 0000000000..86c47077f0
--- /dev/null
+++ b/test/files/run/spec-ame.scala
@@ -0,0 +1,17 @@
+// ticket #3432
+object Test {
+ trait B[@specialized(Int) T] {
+ def value: T
+ }
+
+ class A[@specialized(Int) T](x: T) {
+ def foo: B[T] = new B[T] {
+ def value = x
+ }
+ }
+
+ def main(args: Array[String]) {
+ println((new A("abc")).foo.value)
+ println((new A(10)).foo.value)
+ }
+}
diff --git a/test/files/run/spec-overrides.check b/test/files/run/spec-overrides.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/run/spec-overrides.check
diff --git a/test/files/run/spec-overrides.scala b/test/files/run/spec-overrides.scala
new file mode 100644
index 0000000000..f5d2e2f9c7
--- /dev/null
+++ b/test/files/run/spec-overrides.scala
@@ -0,0 +1,20 @@
+ trait Base[@specialized(Double) B] {
+ def default: B;
+ }
+
+ trait D1 extends Base[Double] {
+ override def default = 0.0;
+ }
+
+ class D2 extends D1 {
+ override def default: Double = 1.0;
+ }
+
+
+object Test extends Application {
+ val d2 = new D2
+
+ assert(d2.default == 1.0, d2.default)
+ assert((d2: Base[_]).default == 1.0, (d2: Base[_]).default)
+ assert((d2: D1).default == 1.0, (d2: D1).default)
+}
diff --git a/test/files/run/unittest_iterator.scala b/test/files/run/unittest_iterator.scala
index 28a548160f..21dc64c3c5 100644
--- a/test/files/run/unittest_iterator.scala
+++ b/test/files/run/unittest_iterator.scala
@@ -1,6 +1,5 @@
// Some iterator grouped/sliding unit tests
-object Test
-{
+object Test {
def it = (1 to 10).iterator
def assertThat[T](expectedLength: Int, expectedLast: Seq[T])(it: Iterator[Seq[T]]) {
val xs = it.toList
@@ -34,7 +33,11 @@ object Test
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
+ // larger step than window
+ assertThat(5, List(9)) { it.sliding(1, 2) }
+ assertThat(3, List(9, 10)) { it.sliding(2, 4) }
+
+ // make sure it throws past the end
val thrown = try {
val it = List(1,2,3).sliding(2)
it.next
diff --git a/test/files/scalacheck/.gitignore b/test/files/scalacheck/.gitignore
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/scalacheck/.gitignore
diff --git a/test/pending/pos/bug3420.flags b/test/pending/pos/bug3420.flags
new file mode 100644
index 0000000000..ea03113c66
--- /dev/null
+++ b/test/pending/pos/bug3420.flags
@@ -0,0 +1 @@
+-optimise -Xfatal-warnings \ No newline at end of file
diff --git a/test/pending/pos/bug3420.scala b/test/pending/pos/bug3420.scala
new file mode 100644
index 0000000000..0fc56ed67b
--- /dev/null
+++ b/test/pending/pos/bug3420.scala
@@ -0,0 +1,5 @@
+class C {
+ val cv = Map[Int, Int](1 -> 2)
+ lazy val cl = Map[Int, Int](1 -> 2)
+ def cd = Map[Int, Int](1 -> 2)
+}
diff --git a/test/pending/run/bug3150.scala b/test/pending/run/bug3150.scala
new file mode 100644
index 0000000000..034703b5f7
--- /dev/null
+++ b/test/pending/run/bug3150.scala
@@ -0,0 +1,10 @@
+object Test {
+ case object Bob { override def equals(other: Any) = true }
+ def f(x: Any) = x match { case Bob => Bob }
+
+ def main(args: Array[String]): Unit = {
+ assert(f(Bob) eq Bob)
+ assert(f(0) eq Bob)
+ assert(f(Nil) eq Bob)
+ }
+}