Skip to content

Commit

Permalink
test(valid): cover select arg. mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler authored and cwfitzgerald committed Dec 20, 2024
1 parent 2587db1 commit 9ea464b
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions naga/tests/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -621,7 +622,7 @@ fn validation_error_messages() {
foo();
}
"#,
"\
"\
error: Function [1] 'main' is invalid
┌─ wgsl:7:17
\n7 │ ╭ fn main() {
Expand All @@ -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();
Expand Down

0 comments on commit 9ea464b

Please sign in to comment.