summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-04-23 22:04:36 +0000
committerPaul Phillips <paulp@improving.org>2011-04-23 22:04:36 +0000
commit63c7c9d857568879bfda146dd31bfc4ee38cb9fb (patch)
treef11372dc3d38c1eb0a327b33afb9fb25a0a7a658 /test
parent21121ff62ea72523ed5ea6a906b2ce42e9e47f69 (diff)
downloadscala-63c7c9d857568879bfda146dd31bfc4ee38cb9fb.tar.gz
scala-63c7c9d857568879bfda146dd31bfc4ee38cb9fb.tar.bz2
scala-63c7c9d857568879bfda146dd31bfc4ee38cb9fb.zip
Working my way through pattern matcher sequence...
Working my way through pattern matcher sequence issues mostly caused by the special handling of Lists. Also deleting all kinds of useless or almost useless code which is presently only clutter. Closes #2756, #2800, #3050, #3530, #3972, no review.
Diffstat (limited to 'test')
-rw-r--r--test/files/pos/bug3972.scala11
-rw-r--r--test/files/run/bug2800.check14
-rw-r--r--test/files/run/bug2800.scala36
-rw-r--r--test/files/run/bug3050.scala (renamed from test/pending/run/bug3050.scala)2
-rw-r--r--test/files/run/bug3530.check13
-rw-r--r--test/files/run/bug3530.scala36
6 files changed, 105 insertions, 7 deletions
diff --git a/test/files/pos/bug3972.scala b/test/files/pos/bug3972.scala
new file mode 100644
index 0000000000..5dfc10fcef
--- /dev/null
+++ b/test/files/pos/bug3972.scala
@@ -0,0 +1,11 @@
+object CompilerCrash {
+ def main(args: Array[String]) {
+ args match {
+ case Array("a", a @ _*) => { } // The code compiles fine if this line is commented out or "@ _*" is deleted or this line is swapped for the next line
+ case Array("b") => { } // The code compiles fine if this line is commented out
+ case Array("c", c) => {
+ 0 // The code compiles fine if this line is commented out
+ }
+ }
+ }
+}
diff --git a/test/files/run/bug2800.check b/test/files/run/bug2800.check
new file mode 100644
index 0000000000..546ee52413
--- /dev/null
+++ b/test/files/run/bug2800.check
@@ -0,0 +1,14 @@
+false
+false
+List()
+false
+false
+false
+false
+Vector(1)
+false
+false
+true
+false
+false
+false
diff --git a/test/files/run/bug2800.scala b/test/files/run/bug2800.scala
new file mode 100644
index 0000000000..84d1de0507
--- /dev/null
+++ b/test/files/run/bug2800.scala
@@ -0,0 +1,36 @@
+object Test {
+ def f1 = ("": Any) match { case List(x @ _*) => x ; case _ => false }
+ def f2 = (5: Any) match { case List(x @ _*) => x ; case _ => false }
+ def f3 = (Nil: Any) match { case List(x @ _*) => x ; case _ => false }
+ def f4 = (Array(1): Any) match { case List(x @ _*) => x ; case _ => false }
+
+ def f5 = ("": Any) match { case Array(x @ _*) => x ; case _ => false }
+ def f6 = (5: Any) match { case Array(x @ _*) => x ; case _ => false }
+ def f7 = (Nil: Any) match { case Array(x @ _*) => x ; case _ => false }
+ def f8 = (Array(1): Any) match { case Array(x @ _*) => x ; case _ => false }
+
+ def f9 = ("": Any) match { case x @ List(_*) => x ; case _ => false }
+ def f10 = ("": Any) match { case List(_*) => true ; case _ => false }
+ def f11 = (Nil: Any) match { case List(_*) => true ; case _ => false }
+ def f12 = ("": Any) match { case x @ Array(_*) => x ; case _ => false }
+ def f13 = ("": Any) match { case Array(_*) => true ; case _ => false }
+ def f14 = (Nil: Any) match { case Array(_*) => true ; case _ => false }
+
+
+ def main(args: Array[String]): Unit = {
+ println(f1)
+ println(f2)
+ println(f3)
+ println(f4)
+ println(f5)
+ println(f6)
+ println(f7)
+ println(f8)
+ println(f9)
+ println(f10)
+ println(f11)
+ println(f12)
+ println(f13)
+ println(f14)
+ }
+}
diff --git a/test/pending/run/bug3050.scala b/test/files/run/bug3050.scala
index aaec99ec14..d1f3f13bec 100644
--- a/test/pending/run/bug3050.scala
+++ b/test/files/run/bug3050.scala
@@ -4,6 +4,6 @@ object Test {
try { ("": Any) match { case List(_*) => true } }
catch { case _ => false }
- assert(x == false)
+ assert(!x)
}
}
diff --git a/test/files/run/bug3530.check b/test/files/run/bug3530.check
index 633c15d9d7..1f906680e9 100644
--- a/test/files/run/bug3530.check
+++ b/test/files/run/bug3530.check
@@ -1 +1,12 @@
-Some List
+two
+three
+list: 4
+list: 0
+list: 5
+not a list
+
+two
+three
+list: 4
+list: 0
+list: 5
diff --git a/test/files/run/bug3530.scala b/test/files/run/bug3530.scala
index f2c0034691..f6f7fb4229 100644
--- a/test/files/run/bug3530.scala
+++ b/test/files/run/bug3530.scala
@@ -1,9 +1,35 @@
object Test {
+ def f(x: Any) = println(x match {
+ case List(_, _) => "two"
+ case List(_, _, _) => "three"
+ case xs @ List(_*) => "list: " + xs.length
+ case _ => "not a list"
+ })
+
+ def f2[T](x: List[T]) = println(x match {
+ case List(_, _) => "two"
+ case List(_, _, _) => "three"
+ case List(xs @ _*) => "list: " + xs.length
+ // bug: the default case is marked unreachable
+ // case _ => "not a list"
+ })
+
def main(args: Array[String]) {
- val list = List(1,2,3)
- list match {
- case List(_, _) => println("List with two elements")
- case List(_*) => println("Some List")
- }
+ f(List(1, 2))
+ f(List('a', 'b', 'c'))
+ f(List('a', 'b', 'c', 'd'))
+ f(Nil)
+ f(List(1,2,3,4,5))
+ f(null)
+
+ println
+
+ f2(List(1, 2))
+ f2(List('a', 'b', 'c'))
+ f2(List('a', 'b', 'c', 'd'))
+ f2(Nil)
+ f2(List(1,2,3,4,5))
+ // bug: this NPEs on xs.length
+ // f2(null)
}
} \ No newline at end of file