diff options
author | Burak Emir <emir@epfl.ch> | 2006-07-12 10:52:31 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-07-12 10:52:31 +0000 |
commit | e0c336f21b47973c7f99f5ccdfde0dc04077dd70 (patch) | |
tree | fa7978a37130c4fc79228891562efc62c948f23f /test | |
parent | ac87e36fddc684ce42e574063e0ead2ee029edb6 (diff) | |
download | scala-e0c336f21b47973c7f99f5ccdfde0dc04077dd70.tar.gz scala-e0c336f21b47973c7f99f5ccdfde0dc04077dd70.tar.bz2 scala-e0c336f21b47973c7f99f5ccdfde0dc04077dd70.zip |
fixed bug #647 / right ignoring patterns, added...
fixed bug #647 / right ignoring patterns, added test cases
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/regularpatmatnew.check | 0 | ||||
-rw-r--r-- | test/files/run/regularpatmatnew.scala | 74 |
2 files changed, 74 insertions, 0 deletions
diff --git a/test/files/run/regularpatmatnew.check b/test/files/run/regularpatmatnew.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/regularpatmatnew.check diff --git a/test/files/run/regularpatmatnew.scala b/test/files/run/regularpatmatnew.scala new file mode 100644 index 0000000000..af2dd65d2e --- /dev/null +++ b/test/files/run/regularpatmatnew.scala @@ -0,0 +1,74 @@ +object Test { + import scala.testing.SUnit._ + + def main(args:Array[String]): Unit = { + val tr = new TestResult + new TestSuite( + + new Test01, + new Test02, + new Test03 + + ).run(tr) + + for(val f <- tr.failures()) + Console println f + } + + class Test01 extends TestCase("numero uno (all ignoring patterns on List)") { + def doMatch(l:List[String]):String = l match { + case List(_*) => "ok" + } + override def runTest() = { + val list1 = List(); + assertEquals(doMatch(list1), "ok"); + val list2 = List("1","2","3"); + assertEquals(doMatch(list2), "ok"); + } + } + + /* these are not allowed, for strange reasons I will never figure out + + def doMatch(l:Seq[String]):String = l match { + case List(_*) => "ok" + case _ => "not ok" + } + + def doMatch(l:Seq[String]):String = l match { + case Array(_*) => "ok" + case _ => "not ok" + } + */ + + class Test02 extends TestCase("numero due (all ignoring patterns on Seq)") { + def doMatch(l:Seq[String]):String = l match { + case Seq(_*) => "ok" + } + override def runTest() = { + val list1 = List(); + assertEquals(doMatch(list1), "ok"); + val list2 = List("1","2","3"); + assertEquals(doMatch(list2), "ok"); + val array3 = Array[String](); + assertEquals(doMatch(array3), "ok"); + val array4 = Array[String]("ga","gu"); + assertEquals(doMatch(array4), "ok"); + } + } + + class Test03 extends TestCase("numero tre (right-ignoring patterns on List, defaults)") { + def doMatch(l:List[String]):String = l match { + case List(_,_,_,_*) => "ok" + case _ => "not ok" + } + override def runTest() = { + val list1 = List(); + assertEquals(doMatch(list1), "not ok"); + val list2 = List("1","2","3"); + assertEquals(doMatch(list2), "ok"); + val list3 = List("1","2","3","4"); + assertEquals(doMatch(list3), "ok"); + } + } + +} |