summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/patmatnew.scala20
-rw-r--r--test/files/run/regularpatmatnew.scala20
2 files changed, 37 insertions, 3 deletions
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index 377e89a267..10b0021f0f 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -20,8 +20,8 @@ object Test {
val tr = new TestResult
new TestSuite(
- new Test717
-
+ new Test717,
+ new TestGuards
).run(tr)
for(val f <- tr.failures())
@@ -44,6 +44,22 @@ object Test {
}
}
+ class TestGuards extends TestCase("multiple guards for same pattern") with Shmeez {
+ val tree:Tree = Beez(2)
+ override def runTest = {
+ val res = tree match {
+ case Beez(x) if x == 3 => false
+ case Beez(x) if x == 2 => true
+ }
+ assertTrue("ok", res);
+ val ret = (Beez(3):Tree) match {
+ case Beez(x) if x == 3 => true
+ case Beez(x) if x == 2 => false
+ }
+ assertTrue("ok", ret);
+ }
+ }
+
class Test806_818 { // #806, #811 compile only -- type of bind
// bug811
trait Core {
diff --git a/test/files/run/regularpatmatnew.scala b/test/files/run/regularpatmatnew.scala
index 9e056af9f8..a12ed5dfc6 100644
--- a/test/files/run/regularpatmatnew.scala
+++ b/test/files/run/regularpatmatnew.scala
@@ -10,7 +10,8 @@ object Test {
new Test03,
new Test04,
new Test05,
- new Test06
+ new Test06,
+ new Test07
).run(tr)
@@ -131,4 +132,21 @@ object Test {
}
}
+
+ class Test07 extends TestCase("sette List of chars") {
+ def doMatch1(xs:List[char]) = xs match {
+ case List(x, y, _*) => x::y::Nil
+ }
+ def doMatch2(xs:List[char]) = xs match {
+ case List(x, y, z, w) => List(z,w)
+ }
+ //def doMatch3(xs:List[char]) = xs match {
+ // case List(_*, z, w) => w::Nil
+ //}
+ override def runTest() {
+ assertEquals(doMatch1(List('a','b','c','d')), List('a','b'))
+ assertEquals(doMatch2(List('a','b','c','d')), List('c','d'))
+ //assertEquals(doMatch3(List('a','b','c','d')), List('d'))
+ }
+ }
}