mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 10:51:35 +00:00
[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>
This commit is contained in:
parent
2e9f1f54c8
commit
aff58c6cac
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
15
test/switch-case-selector-value-must-be-unique.fail.wgsl
Normal file
15
test/switch-case-selector-value-must-be-unique.fail.wgsl
Normal file
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
13
test/switch-must-have-exactly-one-default-clause-2.fail.wgsl
Normal file
13
test/switch-must-have-exactly-one-default-clause-2.fail.wgsl
Normal file
@ -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;
|
||||
}
|
||||
|
11
test/switch-must-have-exactly-one-default-clause.fail.wgsl
Normal file
11
test/switch-must-have-exactly-one-default-clause.fail.wgsl
Normal file
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user