summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/pos/t1133.scala32
-rw-r--r--test/files/pos/t5029.flags1
-rw-r--r--test/files/pos/t5029.scala3
-rw-r--r--test/files/pos/t5137.scala17
-rw-r--r--test/files/pos/t5626.scala12
-rw-r--r--test/files/pos/t5720-ownerous.scala4
-rw-r--r--test/files/run/names-defaults.check2
-rw-r--r--test/files/run/names-defaults.scala4
-rw-r--r--test/files/run/t4025.check19
-rw-r--r--test/files/run/t4025.scala12
-rw-r--r--test/files/run/t5009.check4
-rw-r--r--test/files/run/t5009.scala17
-rw-r--r--test/files/run/t5037.check2
-rw-r--r--test/files/run/t5037.scala18
-rw-r--r--test/files/run/t5407.check2
-rw-r--r--test/files/run/t5407.scala17
-rw-r--r--test/files/run/t5527.check2
-rw-r--r--test/files/specialized/SI-5005.check2
18 files changed, 163 insertions, 7 deletions
diff --git a/test/files/pos/t1133.scala b/test/files/pos/t1133.scala
new file mode 100644
index 0000000000..4538de5f5f
--- /dev/null
+++ b/test/files/pos/t1133.scala
@@ -0,0 +1,32 @@
+object Match
+{
+ def main(args: Array[String]) = {
+ args(0) match {
+ case Extractor1(Extractor2(Extractor3("dog", "dog", "dog"), x2, x3), b, c, Extractor3("b", "b", f), e) => println(e)
+ case Extractor3(Extractor2(Extractor1("a", "aa", "aaa", "aa", "a"), Extractor2("a", "aa", "aaa"), e), y, z) => println(e)
+ case Extractor2(Extractor3("a", "a", x), Extractor3("b", "b", y), Extractor3("c", "c", z)) => println(z)
+ case _ => println("fail")
+ }
+ }
+
+ object Extractor1 {
+ def unapply(x: Any) = x match {
+ case x: String => Some(x, x+x, x+x+x, x+x, x)
+ case _ => None
+ }
+ }
+
+ object Extractor2 {
+ def unapply(x: Any) = x match {
+ case x: String => Some(x, x+x, x+x+x)
+ case _ => None
+ }
+ }
+
+ object Extractor3 {
+ def unapply(x: Any) = x match {
+ case x: String => Some(x, x, x)
+ case _ => None
+ }
+ }
+}
diff --git a/test/files/pos/t5029.flags b/test/files/pos/t5029.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/pos/t5029.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/t5029.scala b/test/files/pos/t5029.scala
new file mode 100644
index 0000000000..6f9a329b80
--- /dev/null
+++ b/test/files/pos/t5029.scala
@@ -0,0 +1,3 @@
+object Test {
+ (Vector(): Seq[_]) match { case List() => true; case Nil => false }
+} \ No newline at end of file
diff --git a/test/files/pos/t5137.scala b/test/files/pos/t5137.scala
new file mode 100644
index 0000000000..bb72cf378f
--- /dev/null
+++ b/test/files/pos/t5137.scala
@@ -0,0 +1,17 @@
+object Test {
+
+ // okay
+ (1 * (List[BigInt]().map(((x0) => x0 match {
+ case x => x
+ })).sum))
+
+ // okay
+ ((1: BigInt) * (List[BigInt]().map({
+ case x => x
+ }).sum))
+
+ // fail
+ (1 * (List[BigInt]().map({
+ case x => x
+ }).sum))
+} \ No newline at end of file
diff --git a/test/files/pos/t5626.scala b/test/files/pos/t5626.scala
new file mode 100644
index 0000000000..c501dfbe60
--- /dev/null
+++ b/test/files/pos/t5626.scala
@@ -0,0 +1,12 @@
+class C {
+ val blob = {
+ new { case class Foo() }
+ }
+ val blub = {
+ class Inner { case class Foo() }
+ new Inner
+ }
+
+ val foo = blob.Foo()
+ val bar = blub.Foo()
+}
diff --git a/test/files/pos/t5720-ownerous.scala b/test/files/pos/t5720-ownerous.scala
index 3a12499612..ad4d4c171d 100644
--- a/test/files/pos/t5720-ownerous.scala
+++ b/test/files/pos/t5720-ownerous.scala
@@ -28,10 +28,10 @@ class C {
//def model = Option(M("foo")()).getOrElse(M("bar")()).copy(currentUser = "")()
// the bug
- def model = Option(m).getOrElse(M("bar")()).copy("baz")()
+ def model = Option(m).getOrElse(M("bar")()).copy("baz")("empty")
// style points for this version
- def modish = ((null: Option[M]) getOrElse new M()()).copy()()
+ def modish = ((null: Option[M]) getOrElse new M()()).copy()("empty")
// various simplifications are too simple
case class N(currentUser: String = "anon")
diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check
index 5656d1a276..f253de71d6 100644
--- a/test/files/run/names-defaults.check
+++ b/test/files/run/names-defaults.check
@@ -92,7 +92,7 @@ test5
test5
5
10: 2
-slkdfj1
+slkdfj2
1
lskfdjlk
11
diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala
index e1bc7cbf59..220414f02a 100644
--- a/test/files/run/names-defaults.scala
+++ b/test/files/run/names-defaults.scala
@@ -176,7 +176,7 @@ object Test extends App {
println(Fact2()("jyp"))
println(Fact2(x = 1)())
- println(Fact2(10)().copy(y = "blabla")())
+ println(Fact2(10)().copy(y = "blabla")(3))
// assignment to var <-> named argument
@@ -195,7 +195,7 @@ object Test extends App {
// dependent types and copy method
val a11 = new A2
val b11 = a11.B2(new a11.C2)(1)
- println(b11.copy()())
+ println(b11.copy()(2))
diff --git a/test/files/run/t4025.check b/test/files/run/t4025.check
new file mode 100644
index 0000000000..6715003cb6
--- /dev/null
+++ b/test/files/run/t4025.check
@@ -0,0 +1,19 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> class Color(val red: Int)
+defined class Color
+
+scala>
+
+scala> case class Red(r:Int) extends Color(r)
+defined class Red
+
+scala>
+
+scala> def f(c: Any) = c match { case Red(_) => () }
+f: (c: Any)Unit
+
+scala>
diff --git a/test/files/run/t4025.scala b/test/files/run/t4025.scala
new file mode 100644
index 0000000000..5db0093970
--- /dev/null
+++ b/test/files/run/t4025.scala
@@ -0,0 +1,12 @@
+import scala.tools.nsc.Settings
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+class Color(val red: Int)
+
+case class Red(r:Int) extends Color(r)
+
+def f(c: Any) = c match { case Red(_) => () }
+"""
+}
diff --git a/test/files/run/t5009.check b/test/files/run/t5009.check
new file mode 100644
index 0000000000..cc9df54b34
--- /dev/null
+++ b/test/files/run/t5009.check
@@ -0,0 +1,4 @@
+C(1,true)
+10
+C(7283,20)
+100
diff --git a/test/files/run/t5009.scala b/test/files/run/t5009.scala
new file mode 100644
index 0000000000..b4fe1bc894
--- /dev/null
+++ b/test/files/run/t5009.scala
@@ -0,0 +1,17 @@
+object Test extends App {
+
+ case class C[T, U <: String, O >: Object](x: Int, y: T)(z: U, b: Boolean)(s: O, val l: Int)
+
+ val c = C(1, true)("dlkfj", true)("dlkfjlk", 10)
+ println(c)
+ println(c.l)
+
+ val f1a = c.copy(y = 20, x = 7283)
+
+ val f1b = c.copy[Int, String, Object](y = 20, x = 7283)
+ val f2b = f1b("lkdjen", false)
+ val res = f2b(new Object, 100)
+ println(res)
+ println(res.l)
+
+}
diff --git a/test/files/run/t5037.check b/test/files/run/t5037.check
new file mode 100644
index 0000000000..da29283aaa
--- /dev/null
+++ b/test/files/run/t5037.check
@@ -0,0 +1,2 @@
+true
+false
diff --git a/test/files/run/t5037.scala b/test/files/run/t5037.scala
new file mode 100644
index 0000000000..7b1fce7a82
--- /dev/null
+++ b/test/files/run/t5037.scala
@@ -0,0 +1,18 @@
+object Test {
+ def main(args: Array[String]) {
+ val t = new Test
+ t.inner.foo()
+ }
+}
+
+class Test {
+ class Inner {
+ def foo() {
+ println(bar)
+ bar = false
+ println(bar)
+ }
+ }
+ val inner = new Inner
+ private[this] final var bar = true
+}
diff --git a/test/files/run/t5407.check b/test/files/run/t5407.check
new file mode 100644
index 0000000000..51993f072d
--- /dev/null
+++ b/test/files/run/t5407.check
@@ -0,0 +1,2 @@
+2
+2
diff --git a/test/files/run/t5407.scala b/test/files/run/t5407.scala
new file mode 100644
index 0000000000..35a8ec6a45
--- /dev/null
+++ b/test/files/run/t5407.scala
@@ -0,0 +1,17 @@
+case class Foo(private val x: Int, y: Option[Int], z: Boolean)
+
+object Test extends App {
+ def foo(x: Foo) = x match {
+ case Foo(x, Some(y), z) => y
+ case Foo(x, y, z) => 0
+ }
+ val x = Foo(1, Some(2), false)
+ println(foo(x))
+
+
+ def bar(x: Foo) = x match {
+ case Foo(x, Some(y), z) => y
+ case Foo(x, None, z) => 0
+ }
+ println(bar(x))
+} \ No newline at end of file
diff --git a/test/files/run/t5527.check b/test/files/run/t5527.check
index bb13928fd8..1518168c51 100644
--- a/test/files/run/t5527.check
+++ b/test/files/run/t5527.check
@@ -1,4 +1,4 @@
-[[syntax trees at end of parser]]// Scala source: newSource1
+[[syntax trees at end of parser]] // newSource1
package <empty> {
object UselessComments extends scala.AnyRef {
def <init>() = {
diff --git a/test/files/specialized/SI-5005.check b/test/files/specialized/SI-5005.check
index 9fc63a2b1d..81e8342dad 100644
--- a/test/files/specialized/SI-5005.check
+++ b/test/files/specialized/SI-5005.check
@@ -1,4 +1,4 @@
-[[syntax trees at end of specialize]]// Scala source: newSource1
+[[syntax trees at end of specialize]] // newSource1
package <empty> {
class C2[@specialized(scala.Boolean) U >: Nothing <: Any] extends Object {
def <init>(): C2[U] = {