mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
test(valid): cover select arg. mismatches
This commit is contained in:
committed by
Connor Fitzgerald
parent
2587db1c9b
commit
9ea464b85b
@@ -610,8 +610,9 @@ fn binding_arrays_cannot_hold_scalars() {
|
||||
#[cfg(feature = "wgsl-in")]
|
||||
#[test]
|
||||
fn validation_error_messages() {
|
||||
let cases = [(
|
||||
r#"@group(0) @binding(0) var my_sampler: sampler;
|
||||
let cases = [
|
||||
(
|
||||
r#"@group(0) @binding(0) var my_sampler: sampler;
|
||||
|
||||
fn foo(tex: texture_2d<f32>) -> vec4<f32> {
|
||||
return textureSampleLevel(tex, my_sampler, vec2f(0, 0), 0.0);
|
||||
@@ -621,7 +622,7 @@ fn validation_error_messages() {
|
||||
foo();
|
||||
}
|
||||
"#,
|
||||
"\
|
||||
"\
|
||||
error: Function [1] 'main' is invalid
|
||||
┌─ wgsl:7:17
|
||||
│ \n7 │ ╭ fn main() {
|
||||
@@ -632,7 +633,48 @@ error: Function [1] 'main' is invalid
|
||||
= Requires 1 arguments, but 0 are provided
|
||||
|
||||
",
|
||||
)];
|
||||
),
|
||||
(
|
||||
"\
|
||||
@compute @workgroup_size(1, 1)
|
||||
fn main() {
|
||||
// Bad: `9001` isn't a `bool`.
|
||||
_ = select(1, 2, 9001);
|
||||
}
|
||||
",
|
||||
"\
|
||||
error: Entry point main at Compute is invalid
|
||||
┌─ wgsl:4:9
|
||||
│
|
||||
4 │ _ = select(1, 2, 9001);
|
||||
│ ^^^^^^ naga::Expression [3]
|
||||
│
|
||||
= Expression [3] is invalid
|
||||
= Selecting is not possible
|
||||
|
||||
",
|
||||
),
|
||||
(
|
||||
"\
|
||||
@compute @workgroup_size(1, 1)
|
||||
fn main() {
|
||||
// Bad: `bool` and abstract int args. don't match.
|
||||
_ = select(true, 1, false);
|
||||
}
|
||||
",
|
||||
"\
|
||||
error: Entry point main at Compute is invalid
|
||||
┌─ wgsl:4:9
|
||||
│
|
||||
4 │ _ = select(true, 1, false);
|
||||
│ ^^^^^^ naga::Expression [3]
|
||||
│
|
||||
= Expression [3] is invalid
|
||||
= Selecting is not possible
|
||||
|
||||
",
|
||||
),
|
||||
];
|
||||
|
||||
for (source, expected_err) in cases {
|
||||
let module = naga::front::wgsl::parse_str(source).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user