summaryrefslogtreecommitdiff
path: root/test/files/run
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/files/run
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/files/run')
-rw-r--r--test/files/run/bug2800.check14
-rw-r--r--test/files/run/bug2800.scala36
-rw-r--r--test/files/run/bug3050.scala9
-rw-r--r--test/files/run/bug3530.check13
-rw-r--r--test/files/run/bug3530.scala36
5 files changed, 102 insertions, 6 deletions
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/files/run/bug3050.scala b/test/files/run/bug3050.scala
new file mode 100644
index 0000000000..d1f3f13bec
--- /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)
+ }
+}
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