Skip to content

Commit

Permalink
test: [naga wgsl-in] add tests for @must_use
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocrime committed Dec 21, 2024
1 parent 150a204 commit b3f5e81
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions naga/tests/in/5186-must-use.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
fn main() { }

@must_use
fn a() -> i32 { return 10; }

@must_use
fn b() -> bool { return false; }

// use as return
fn z() -> i32 {
return a();
}

// use in expression
fn y() -> bool {
return a() == 10;
}

// use in short circuited expression
fn x() -> bool {
return false && a() == 10;
}

// assignment and use as return
fn w() -> i32 {
let called_a = a();
return called_a;
}

// assignment and use before return
fn v() -> i32 {
let called_a = a();
let used_a = 1 + called_a;
return used_a;
}

// use in condition
fn u() -> i32 {
if(b()) {
return 1;
} else {
return 2;
}
}

// use in skipped branch
fn t() -> i32 {
if(true) {
return 1;
} else {
return a();
}
}

0 comments on commit b3f5e81

Please sign in to comment.