Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Looks like I got that irrefutability bug too.
- Loading branch information
Showing
2 changed files
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
I hereby refute null! | ||
I denounce null as unListLike! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
object Test { | ||
val xs: List[(Int, Int)] = List((2, 2), null) | ||
|
||
def expectMatchError[T](msg: String)(body: => T) { | ||
try { body ; assert(false, "Should not succeed.") } | ||
catch { case _: MatchError => println(msg) } | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
expectMatchError("I hereby refute null!")( for ((x, y) <- xs) yield x ) | ||
expectMatchError("I denounce null as unListLike!")( (null: Any) match { case List(_*) => true } ) | ||
} | ||
} |