diff options
author | Burak Emir <emir@epfl.ch> | 2007-02-02 10:29:43 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2007-02-02 10:29:43 +0000 |
commit | 6a440b960c00c01f3653385417a246e359d82e01 (patch) | |
tree | 195c8b3d506d37c5ba049f3495cd43bdf3a3e575 /test/files/neg/patmatexhaust.scala | |
parent | df3c09479ed116752324839ccf2ca4a1e9890d9a (diff) | |
download | scala-6a440b960c00c01f3653385417a246e359d82e01.tar.gz scala-6a440b960c00c01f3653385417a246e359d82e01.tar.bz2 scala-6a440b960c00c01f3653385417a246e359d82e01.zip |
matching: + exhaustivity check, warnings
Iterator: gets mkString method
Iterable: only whitespace
Definitions: value classes no longer SEALED
test cases for exhaustivity + unapply/array
Diffstat (limited to 'test/files/neg/patmatexhaust.scala')
-rw-r--r-- | test/files/neg/patmatexhaust.scala | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala new file mode 100644 index 0000000000..0416749b88 --- /dev/null +++ b/test/files/neg/patmatexhaust.scala @@ -0,0 +1,59 @@ +class TestSealedExhaustive { // compile only + + sealed class Foo + + case class Bar(x:Int) extends Foo + case object Baz extends Foo + + def ma1(x:Foo) = x match { + case Bar(_) => // not exhaustive + } + + def ma2(x:Foo) = x match { + case Baz => // not exhaustive + } + + sealed class Mult + case class Kult(s:Mult) extends Mult + case class Qult() extends Mult + + def ma33(x:Kult) = x match { // exhaustive + case Kult(_) => // exhaustive + } + def ma3(x:Mult) = {x,x} match { // not exhaustive + case {Kult(_), Qult()} => // Kult missing + //case {Kult(_), Kult(_)} => + case {Qult(), Kult(_)} => // Qult missing + //case {Qult(), Qult()} => + } + + + sealed class Deep + + case object Ga extends Deep + sealed class Gp extends Deep + case object Gu extends Gp + + def zma3(x:Deep) = x match { // exhaustive! + case _ => + } + def zma4(x:Deep) = x match { // exhaustive! + case Ga => + case _ => + } + + def ma4(x:Deep) = x match { // missing cases: Gu + case Ga => + } + + def zma5(x:Deep) = x match { // exhaustive + case Gu => + case _ if 1 == 0 => + case Ga => + } + + def redundant = 1 match { // include this otherwise script won't test this in files/neg + case 1 => + case 1 => + } +} |