Skip to content

Commit

Permalink
Refactor const parse tests (gpuweb#3752)
Browse files Browse the repository at this point in the history
Refs gpuweb#3741

* Move parse/const tests into decl/const
  • Loading branch information
alan-baker authored May 17, 2024
1 parent be240b9 commit 007e101
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,7 @@
"webgpu:shader,validation,decl,const:no_indirect_recursion:*": { "subcaseMS": 0.950 },
"webgpu:shader,validation,decl,const:no_indirect_recursion_via_array_size:*": { "subcaseMS": 2.601 },
"webgpu:shader,validation,decl,const:no_indirect_recursion_via_struct_attribute:*": { "subcaseMS": 1.034 },
"webgpu:shader,validation,decl,const:placement:*": { "subcaseMS": 1.167 },
"webgpu:shader,validation,decl,const:type:*": { "subcaseMS": 10.651 },
"webgpu:shader,validation,decl,context_dependent_resolution:attribute_names:*": { "subcaseMS": 533.132 },
"webgpu:shader,validation,decl,context_dependent_resolution:builtin_value_names:*": { "subcaseMS": 25.538 },
Expand Down Expand Up @@ -2502,7 +2503,6 @@
"webgpu:shader,validation,parse,comments:line_comment_eof:*": { "subcaseMS": 4.500 },
"webgpu:shader,validation,parse,comments:line_comment_terminators:*": { "subcaseMS": 1.021 },
"webgpu:shader,validation,parse,comments:unterminated_block_comment:*": { "subcaseMS": 8.950 },
"webgpu:shader,validation,parse,const:placement:*": { "subcaseMS": 1.167 },
"webgpu:shader,validation,parse,diagnostic:after_other_directives:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,parse,diagnostic:conflicting_attribute_different_location:*": { "subcaseMS": 2.257 },
"webgpu:shader,validation,parse,diagnostic:conflicting_directive:*": { "subcaseMS": 1.244 },
Expand Down
51 changes: 51 additions & 0 deletions src/webgpu/shader/validation/decl/const.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,54 @@ g.test('assert')
const_assert x == 0;`;
t.expectCompileResult(true, code);
});

g.test('placement')
.desc('Tests @const is not allowed to appear')
.params(u =>
u.combine('scope', [
'private-var',
'storage-var',
'struct-member',
'fn-decl',
'fn-param',
'fn-var',
'fn-return',
'while-stmt',
undefined,
] as const)
)
.fn(t => {
const scope = t.params.scope;

const attr = '@const';
const code = `
${scope === 'private-var' ? attr : ''}
var<private> priv_var : i32;
${scope === 'storage-var' ? attr : ''}
@group(0) @binding(0)
var<storage> stor_var : i32;
struct A {
${scope === 'struct-member' ? attr : ''}
a : i32,
}
@vertex
${scope === 'fn-decl' ? attr : ''}
fn f(
${scope === 'fn-param' ? attr : ''}
@location(0) b : i32,
) -> ${scope === 'fn-return' ? attr : ''} @builtin(position) vec4f {
${scope === 'fn-var' ? attr : ''}
var<function> func_v : i32;
${scope === 'while-stmt' ? attr : ''}
while false {}
return vec4(1, 1, 1, 1);
}
`;

t.expectCompileResult(scope === undefined, code);
});
57 changes: 0 additions & 57 deletions src/webgpu/shader/validation/parse/const.spec.ts

This file was deleted.

0 comments on commit 007e101

Please sign in to comment.