aboutsummaryrefslogtreecommitdiff
path: root/tests/patmat/enum
diff options
context:
space:
mode:
authorliu fengyun <liufengyunchina@gmail.com>2016-07-21 10:45:14 +0200
committerliu fengyun <liufengyunchina@gmail.com>2016-08-24 10:26:59 +0200
commitcc02243fbe8b7290265e1bdf540e4c2f256df199 (patch)
treebd83dcabb8de09fa48b9373b9431ef8c481da5ed /tests/patmat/enum
parent1a7618f32c6d8060c3a87ce633645440d500aa7a (diff)
downloaddotty-cc02243fbe8b7290265e1bdf540e4c2f256df199.tar.gz
dotty-cc02243fbe8b7290265e1bdf540e4c2f256df199.tar.bz2
dotty-cc02243fbe8b7290265e1bdf540e4c2f256df199.zip
add test set for exhaustivity and redundancy check
Diffstat (limited to 'tests/patmat/enum')
-rw-r--r--tests/patmat/enum/Day.java4
-rw-r--r--tests/patmat/enum/expected.check9
-rw-r--r--tests/patmat/enum/patmat-enum.scala21
3 files changed, 34 insertions, 0 deletions
diff --git a/tests/patmat/enum/Day.java b/tests/patmat/enum/Day.java
new file mode 100644
index 000000000..eedb9a72b
--- /dev/null
+++ b/tests/patmat/enum/Day.java
@@ -0,0 +1,4 @@
+public enum Day {
+ SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
+ THURSDAY, FRIDAY, SATURDAY
+} \ No newline at end of file
diff --git a/tests/patmat/enum/expected.check b/tests/patmat/enum/expected.check
new file mode 100644
index 000000000..b3dafa8bd
--- /dev/null
+++ b/tests/patmat/enum/expected.check
@@ -0,0 +1,9 @@
+./tests/patmat/enum/patmat-enum.scala:4: warning: match may not be exhaustive.
+It would fail on the following input: SATURDAY, FRIDAY, THURSDAY, SUNDAY
+ day match {
+ ^
+./tests/patmat/enum/patmat-enum.scala:15: warning: match may not be exhaustive.
+It would fail on the following input: SATURDAY, FRIDAY, THURSDAY
+ day match {
+ ^
+two warnings found \ No newline at end of file
diff --git a/tests/patmat/enum/patmat-enum.scala b/tests/patmat/enum/patmat-enum.scala
new file mode 100644
index 000000000..ec5c90255
--- /dev/null
+++ b/tests/patmat/enum/patmat-enum.scala
@@ -0,0 +1,21 @@
+object Test1 {
+ val day: Day = ???
+
+ day match {
+ case Day.MONDAY => true
+ case Day.TUESDAY => true
+ case Day.WEDNESDAY => true
+ }
+}
+
+object Test2 {
+ import Day._
+ val day: Day = ???
+
+ day match {
+ case MONDAY => true
+ case TUESDAY => true
+ case WEDNESDAY => true
+ case SUNDAY => true
+ }
+} \ No newline at end of file