diff options
author | buraq <buraq@epfl.ch> | 2003-10-06 17:48:04 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2003-10-06 17:48:04 +0000 |
commit | 185bb897da1e638fdb6b8b4d11bab43cf32090c7 (patch) | |
tree | 279396ff4856889a8e9253cc1197edc8fda82726 | |
parent | f1d658c71e64cb81bd3f40cf23f25426de8900a9 (diff) | |
download | scala-185bb897da1e638fdb6b8b4d11bab43cf32090c7.tar.gz scala-185bb897da1e638fdb6b8b4d11bab43cf32090c7.tar.bz2 scala-185bb897da1e638fdb6b8b4d11bab43cf32090c7.zip |
added test case for #133b
-rw-r--r-- | test/files/run/regularpatmat.check | 3 | ||||
-rw-r--r-- | test/files/run/regularpatmat.scala | 16 |
2 files changed, 15 insertions, 4 deletions
diff --git a/test/files/run/regularpatmat.check b/test/files/run/regularpatmat.check index 992ff45a58..99ebce5ab5 100644 --- a/test/files/run/regularpatmat.check +++ b/test/files/run/regularpatmat.check @@ -99,7 +99,8 @@ passed ok passed ok passed ok passed ok -testMZ - bug#132 +testMZ - bug#132 bug#133b +passed ok passed ok passed ok passed ok diff --git a/test/files/run/regularpatmat.scala b/test/files/run/regularpatmat.scala index 473c4d47c8..21a7141c32 100644 --- a/test/files/run/regularpatmat.scala +++ b/test/files/run/regularpatmat.scala @@ -24,7 +24,7 @@ object values { // test values reused in nearly all test cases } -// not tests matching without binding +// matching without binding // 2do case [ 'a'; x; y ] => 100 // case [ z @ ('a'; x; y) ] => 100 @@ -60,6 +60,9 @@ object testBK { } } + +// tests with binding + object testBL { import scala.testing.UnitTest._ ; @@ -573,19 +576,26 @@ object testMZ { class Expr; case class One(xs: List[Expr]) extends Expr; case class Two() extends Expr; - def testFoo(xs: List[Expr]) = xs match { + def testFoo(xs: List[Expr]) = xs match { //bug#132 case List(Two()?,a,Two()?) => "a = " + a; case List(Two()*,b,Two()*) => "b = " + b; case List(_*) => "no match"; } + case class OneN(); + def bind(xs: List[Any]):String = xs match { // bug#133b + case List(x@(OneN()*), y@(OneN())) => "case"; + case _ => "default"; + } def main:Unit = { - System.out.println("testMZ - bug#132"); + System.out.println("testMZ - bug#132 bug#133b"); test[List[Expr],String](testFoo, List(Two(),Two(),Two(),Two()), "b = Two"); test[List[Expr],String](testFoo, List(Two(),Two(),Two()), "a = Two"); test[List[Expr],String](testFoo, List(Two(),Two()), "a = Two"); test[List[Expr],String](testFoo, List(Two()), "a = Two"); test[List[Expr],String](testFoo, List(), "no match"); + test[List[Any],String](bind, List(OneN(),OneN()), "case"); + () } |