diff options
author | Burak Emir <emir@epfl.ch> | 2007-02-05 17:17:17 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2007-02-05 17:17:17 +0000 |
commit | 2f4f3d3db7c2eb9ed535065ffed8098a99de0278 (patch) | |
tree | d3d8c20356bd8f76d1b4b7aa298507232ae028cb /test/files/run | |
parent | 912077c5f8d59b2585a3a5014c193a8399b672d1 (diff) | |
download | scala-2f4f3d3db7c2eb9ed535065ffed8098a99de0278.tar.gz scala-2f4f3d3db7c2eb9ed535065ffed8098a99de0278.tar.bz2 scala-2f4f3d3db7c2eb9ed535065ffed8098a99de0278.zip |
exhaustivity reworked
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/patmatnew.scala | 37 | ||||
-rw-r--r-- | test/files/run/regularpatmatnew.scala | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 10b0021f0f..749b0bc21d 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -14,6 +14,7 @@ trait Shmeez extends AnyRef with Treez { } object Test { +/* import scala.testing.SUnit._ def main(args:Array[String]): Unit = { @@ -81,4 +82,40 @@ object Test { } } } + + + // these are exhaustive matches + // should not generate any warnings + def f[A](z:{Option[A],Option[A]}) = z match { + case {None,Some(x)} => 1 + case {Some(x),None } => 2 + case {Some(x),Some(y)} => 3 + case _ => 4 + } + + def g1[A](z:Option[List[A]]) = z match { + case Some(Nil) => true + case Some(x::Nil) => true + case _ => true + } + + def g2[A](z:Option[List[A]]) = z match { + case Some(x::Nil) => true + case Some(_) => false + case _ => true + } + + def h[A](x:{Option[A],Option[A]}) = x match { + case {None,_:Some[_]} => 1 + case {_:Some[_],None } => 2 + case {_:Some[_],_:Some[_]} => 3 + case _ => 4 + } +*/ + def i = List(1,2) match { + case List(1) => + case List(1,2,xs @ _*) => + case Nil => + } } + diff --git a/test/files/run/regularpatmatnew.scala b/test/files/run/regularpatmatnew.scala index a12ed5dfc6..a3401b2b7e 100644 --- a/test/files/run/regularpatmatnew.scala +++ b/test/files/run/regularpatmatnew.scala @@ -107,6 +107,7 @@ object Test { override def runTest() = { val res = (Bar(Foo()):Con) match { case Bar(xs@_*) => xs // this should be optimized away to a pattern Bar(xs) + case _ => Nil } assertEquals("res instance"+res.isInstanceOf[Seq[Con]]+" res(0)="+res(0), true, res.isInstanceOf[Seq[Foo]] && res(0) == Foo() ) } |