-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Bool pattern matching to be exhaustive (#461)
Fixes #456
- Loading branch information
Showing
4 changed files
with
39 additions
and
2 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
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
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
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,32 @@ | ||
package upack | ||
|
||
import utest._ | ||
|
||
object BoolTests extends TestSuite { | ||
def tests = Tests{ | ||
test("upack.Bool apply") { | ||
upack.Bool(true) ==> upack.True | ||
upack.Bool(false) ==> upack.False | ||
} | ||
|
||
test("upack.Bool.value") { | ||
upack.Bool(true).value ==> true | ||
upack.Bool(false).value ==> false | ||
} | ||
test("upack.Bool unapply") { | ||
for(bool <- Seq(true, false)){ | ||
val jsb = upack.Bool(bool) | ||
assertMatch(jsb) { | ||
case upack.Bool(value) | ||
if value == bool | ||
&& jsb.value == value => | ||
} | ||
} | ||
} | ||
test("upack.Bool pattern matching should be exhaustive") { | ||
upack.Bool(true) match { | ||
case upack.Bool(value) => | ||
} | ||
} | ||
} | ||
} |