[validation] add cts tests for switch

This CL adds wgsl tests for the following rules:
v-switch01: switch statement selector expression must be of a scalar integer type
v-0008: switch statement must have exactly one default clause
v-switch03: the case selector values must have the same type as the selector expression the case selectors for a switch statement
v-switch04: a literal value must not appear more than once in the case selectors for a switch statement
v-switch05: a fallthrough statement must not appear as the last statement in last clause of a switch

Bug: tint: 6
Change-Id: Ia12b7d13d47b01e970a5a1e58d61ef05dd9f3830
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28320
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
diff --git a/test/switch-case-selector-must-have-the-same-type-as-the-selector-expression-2.fail.wgsl b/test/switch-case-selector-must-have-the-same-type-as-the-selector-expression-2.fail.wgsl
new file mode 100644
index 0000000..288dede
--- /dev/null
+++ b/test/switch-case-selector-must-have-the-same-type-as-the-selector-expression-2.fail.wgsl
@@ -0,0 +1,12 @@
+# v-switch03: line 7: the case selector values must have the same type as the selector expression
+
+entry_point vertex = main;
+fn main() -> void {
+  var a: i32 = -2;
+  switch (a) {
+    case 2u:{}
+    default: {}
+  }
+  return;
+}
+
diff --git a/test/switch-case-selector-must-have-the-same-type-as-the-selector-expression.fail.wgsl b/test/switch-case-selector-must-have-the-same-type-as-the-selector-expression.fail.wgsl
new file mode 100644
index 0000000..3bee45b
--- /dev/null
+++ b/test/switch-case-selector-must-have-the-same-type-as-the-selector-expression.fail.wgsl
@@ -0,0 +1,12 @@
+# v-switch03: line 7: the case selector values must have the same type as the selector expression
+
+entry_point vertex = main;
+fn main() -> void {
+  var a: u32 = 2;
+  switch (a) {
+    case -1:{}
+    default: {}
+  }
+  return;
+}
+
diff --git a/test/switch-case-selector-value-must-be-unique.fail.wgsl b/test/switch-case-selector-value-must-be-unique.fail.wgsl
new file mode 100644
index 0000000..36efdc2
--- /dev/null
+++ b/test/switch-case-selector-value-must-be-unique.fail.wgsl
@@ -0,0 +1,15 @@
+# v-switch04: line 9: a literal value must not appear more than once in the case selectors for a
+# switch statement: '0'
+
+entry_point vertex = main;
+fn main() -> void {
+  var a: u32 = 2;
+  switch (a) {
+    case 10u: {}
+    case 10u: {}
+    case 10u: {}
+    default: {}
+  }
+  return;
+}
+
diff --git a/test/switch-fallthrough-must-not-be-last-stmt-of-last-clause.fail.wgsl b/test/switch-fallthrough-must-not-be-last-stmt-of-last-clause.fail.wgsl
new file mode 100644
index 0000000..99c1a53
--- /dev/null
+++ b/test/switch-fallthrough-must-not-be-last-stmt-of-last-clause.fail.wgsl
@@ -0,0 +1,13 @@
+# v-switch05: line 9: a fallthrough statement must not appear as the last statement in last clause
+# of a switch
+
+entry_point vertex = main;
+fn main() -> void {
+  var a: i32 = -2;
+  switch (a) {
+    default: {
+      fallthrough;
+    }
+  }
+  return;
+}
diff --git a/test/switch-must-have-exactly-one-default-clause-2.fail.wgsl b/test/switch-must-have-exactly-one-default-clause-2.fail.wgsl
new file mode 100644
index 0000000..b3178e1
--- /dev/null
+++ b/test/switch-must-have-exactly-one-default-clause-2.fail.wgsl
@@ -0,0 +1,13 @@
+# v-0008: line 6: switch statement must have exactly one default clause
+
+entry_point vertex = main;
+fn main() -> void {
+  var a: i32 = 2;
+  switch (a) {
+    case 2: {}
+    default: {}
+    default: {}
+  }
+  return;
+}
+
diff --git a/test/switch-must-have-exactly-one-default-clause.fail.wgsl b/test/switch-must-have-exactly-one-default-clause.fail.wgsl
new file mode 100644
index 0000000..b0cfd2d
--- /dev/null
+++ b/test/switch-must-have-exactly-one-default-clause.fail.wgsl
@@ -0,0 +1,11 @@
+# v-0008: line 6: switch statement must have exactly one default clause
+
+entry_point vertex = main;
+fn main() -> void {
+  var a: i32 = 2;
+  switch (a) {
+    case 2: {}
+  }
+  return;
+}
+
diff --git a/test/switch-selector-expression-must-be-scalar-integer-type.fail.wgsl b/test/switch-selector-expression-must-be-scalar-integer-type.fail.wgsl
new file mode 100644
index 0000000..da49514
--- /dev/null
+++ b/test/switch-selector-expression-must-be-scalar-integer-type.fail.wgsl
@@ -0,0 +1,11 @@
+# v-switch01: line 6: switch statement selector expression must be of a scalar integer type
+
+entry_point vertex = main;
+fn main() -> void {
+  var a: f32 = 3.14;
+  switch (a) {
+    default: {}
+  }
+  return;
+}
+