Skip to content

Commit

Permalink
wgsl: validate floor negative test cases (#3492)
Browse files Browse the repository at this point in the history
- use without parens
- bad arguments
- @must_use

Issue: #3283
  • Loading branch information
dneto0 authored Mar 13, 2024
1 parent 7b9db48 commit f1aa942
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,9 @@
"webgpu:shader,validation,expression,call,builtin,exp2:values:*": { "subcaseMS": 0.410 },
"webgpu:shader,validation,expression,call,builtin,exp:integer_argument:*": { "subcaseMS": 1.356 },
"webgpu:shader,validation,expression,call,builtin,exp:values:*": { "subcaseMS": 0.311 },
"webgpu:shader,validation,expression,call,builtin,floor:bad_args:*": { "subcaseMS": 14.467 },
"webgpu:shader,validation,expression,call,builtin,floor:integer_argument:*": { "subcaseMS": 48.400 },
"webgpu:shader,validation,expression,call,builtin,floor:must_use:*": { "subcaseMS": 0.170 },
"webgpu:shader,validation,expression,call,builtin,floor:values:*": { "subcaseMS": 29.668 },
"webgpu:shader,validation,expression,call,builtin,inverseSqrt:integer_argument:*": { "subcaseMS": 1.356 },
"webgpu:shader,validation,expression,call,builtin,inverseSqrt:values:*": { "subcaseMS": 0.315 },
Expand Down
29 changes: 29 additions & 0 deletions src/webgpu/shader/validation/expression/call/builtin/floor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,32 @@ Validates that scalar and vector integer arguments are rejected by ${builtin}()
'constant'
);
});

const kGoodArgs = '(1.1)';
const kBadArgs = {
no_parens: '',
// Bad number of args
'0args': '()',
'2args': '(1.0,2.0)',
// Bad value for arg 0
'0aint': '(1)',
'0i32': '(1i)',
'0u32': '(1u)',
'0bool': '(false)',
'0vec2u': '(vec2u())',
'0array': '(array(1.1,2.2))',
'0struct': '(modf(2.2))',
};

g.test('bad_args')
.desc(`Test compilation failure of ${builtin} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
.fn(t => {
t.expectCompileResult(false, `const c = ${builtin}${kBadArgs[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${builtin} must be used`)
.fn(t => {
t.expectCompileResult(false, `fn f() { ${builtin}${kGoodArgs}; }`);
});

0 comments on commit f1aa942

Please sign in to comment.