summaryrefslogtreecommitdiff
path: root/test/files/run/patmatnew.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-07-07 17:42:06 +0000
committerPaul Phillips <paulp@improving.org>2009-07-07 17:42:06 +0000
commitac4542b356cc918da5e94dd11616c6d9f0d455cf (patch)
tree881a3c9ad7e3ad42ae0df4810d486bd55fea3188 /test/files/run/patmatnew.scala
parent99ede604a0a16dc0a63383cd90f8b7d38c4f8fd3 (diff)
downloadscala-ac4542b356cc918da5e94dd11616c6d9f0d455cf.tar.gz
scala-ac4542b356cc918da5e94dd11616c6d9f0d455cf.tar.bz2
scala-ac4542b356cc918da5e94dd11616c6d9f0d455cf.zip
Lots of work hardening matching on sequences.
one long-standing bug which actually had a test case testing its bugginess (which is to say, when I fixed the bug, the test case failed.) This: - def doMatch4(xs:Seq[Char]) = xs match { - case Seq(x, y, _*) => x::y::Nil - case Seq(x, y, z, w) => List(z,w) // redundant! - } ...should never have compiled - which must have been recognized on some level given the "redundant!" comment, but it never made it into neg/.
Diffstat (limited to 'test/files/run/patmatnew.scala')
-rw-r--r--test/files/run/patmatnew.scala26
1 files changed, 15 insertions, 11 deletions
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index 0ab5e92099..34bd024b29 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -273,10 +273,14 @@ object Test extends TestConsoleMain {
//def doMatch3(xs:List[char]) = xs match {
// case List(_*, z, w) => w::Nil
//}
- def doMatch4(xs:Seq[Char]) = xs match {
- case Seq(x, y, _*) => x::y::Nil
- case Seq(x, y, z, w) => List(z,w) // redundant!
- }
+ //
+ // Since the second case should have been unreachable all along,
+ // let's just comment this one out.
+ //
+ // def doMatch4(xs:Seq[Char]) = xs match {
+ // case Seq(x, y, _*) => x::y::Nil
+ // case Seq(x, y, z, w) => List(z,w) // redundant!
+ // }
def doMatch5(xs:Seq[Char]) = xs match {
case Seq(x, y, 'c', w @ _*) => x::y::Nil
case Seq(x, y, z @ _*) => z
@@ -289,8 +293,8 @@ object Test extends TestConsoleMain {
override def runTest() {
assertEquals(List('a','b'), doMatch1(List('a','b','c','d')))
assertEquals(List('c','d'), doMatch2(List('a','b','c','d')))
- //assertEquals(doMatch3(List('a','b','c','d')), List('d'))
- assertEquals(List('a','b'), doMatch4(List('a','b','c','d')))
+ // assertEquals(doMatch3(List('a','b','c','d')), List('d'))
+ // assertEquals(List('a','b'), doMatch4(List('a','b','c','d')))
assertEquals(List('a','b'), doMatch5(List('a','b','c','d')))
assertEquals(List('c','d'), doMatch6(List('a','b','c','d')))
}
@@ -315,7 +319,7 @@ object Test extends TestConsoleMain {
case Stream.cons(hd, tl) => hd + sum(tl)
}
- val str: Stream[int] = Stream.fromIterator(List(1,2,3).iterator)
+ val str: Stream[Int] = List(1,2,3).iterator.toStream
def runTest() = assertEquals(sum(str), 6)
}
@@ -500,8 +504,8 @@ object Test extends TestConsoleMain {
object Bug1261 {
sealed trait Elem
- case class Foo extends Elem
- case class Bar extends Elem
+ case class Foo() extends Elem
+ case class Bar() extends Elem
trait Row extends Elem
object Row {
def unapply(r: Row) = true
@@ -924,8 +928,8 @@ override def runTest() {
object Ticket710 { // compile-only
def method {
- sealed case class Parent
- case object Child extends Parent
+ sealed case class Parent()
+ case object Child extends Parent()
val x: Parent = Child
x match {
case Child => ()