Skip to content

Commit 007e101

Browse files
authored
Refactor const parse tests (gpuweb#3752)
Refs gpuweb#3741 * Move parse/const tests into decl/const
1 parent be240b9 commit 007e101

File tree

3 files changed

+52
-58
lines changed

3 files changed

+52
-58
lines changed

src/webgpu/listing_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,7 @@
19031903
"webgpu:shader,validation,decl,const:no_indirect_recursion:*": { "subcaseMS": 0.950 },
19041904
"webgpu:shader,validation,decl,const:no_indirect_recursion_via_array_size:*": { "subcaseMS": 2.601 },
19051905
"webgpu:shader,validation,decl,const:no_indirect_recursion_via_struct_attribute:*": { "subcaseMS": 1.034 },
1906+
"webgpu:shader,validation,decl,const:placement:*": { "subcaseMS": 1.167 },
19061907
"webgpu:shader,validation,decl,const:type:*": { "subcaseMS": 10.651 },
19071908
"webgpu:shader,validation,decl,context_dependent_resolution:attribute_names:*": { "subcaseMS": 533.132 },
19081909
"webgpu:shader,validation,decl,context_dependent_resolution:builtin_value_names:*": { "subcaseMS": 25.538 },
@@ -2502,7 +2503,6 @@
25022503
"webgpu:shader,validation,parse,comments:line_comment_eof:*": { "subcaseMS": 4.500 },
25032504
"webgpu:shader,validation,parse,comments:line_comment_terminators:*": { "subcaseMS": 1.021 },
25042505
"webgpu:shader,validation,parse,comments:unterminated_block_comment:*": { "subcaseMS": 8.950 },
2505-
"webgpu:shader,validation,parse,const:placement:*": { "subcaseMS": 1.167 },
25062506
"webgpu:shader,validation,parse,diagnostic:after_other_directives:*": { "subcaseMS": 1.000 },
25072507
"webgpu:shader,validation,parse,diagnostic:conflicting_attribute_different_location:*": { "subcaseMS": 2.257 },
25082508
"webgpu:shader,validation,parse,diagnostic:conflicting_directive:*": { "subcaseMS": 1.244 },

src/webgpu/shader/validation/decl/const.spec.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,54 @@ g.test('assert')
250250
const_assert x == 0;`;
251251
t.expectCompileResult(true, code);
252252
});
253+
254+
g.test('placement')
255+
.desc('Tests @const is not allowed to appear')
256+
.params(u =>
257+
u.combine('scope', [
258+
'private-var',
259+
'storage-var',
260+
'struct-member',
261+
'fn-decl',
262+
'fn-param',
263+
'fn-var',
264+
'fn-return',
265+
'while-stmt',
266+
undefined,
267+
] as const)
268+
)
269+
.fn(t => {
270+
const scope = t.params.scope;
271+
272+
const attr = '@const';
273+
const code = `
274+
${scope === 'private-var' ? attr : ''}
275+
var<private> priv_var : i32;
276+
277+
${scope === 'storage-var' ? attr : ''}
278+
@group(0) @binding(0)
279+
var<storage> stor_var : i32;
280+
281+
struct A {
282+
${scope === 'struct-member' ? attr : ''}
283+
a : i32,
284+
}
285+
286+
@vertex
287+
${scope === 'fn-decl' ? attr : ''}
288+
fn f(
289+
${scope === 'fn-param' ? attr : ''}
290+
@location(0) b : i32,
291+
) -> ${scope === 'fn-return' ? attr : ''} @builtin(position) vec4f {
292+
${scope === 'fn-var' ? attr : ''}
293+
var<function> func_v : i32;
294+
295+
${scope === 'while-stmt' ? attr : ''}
296+
while false {}
297+
298+
return vec4(1, 1, 1, 1);
299+
}
300+
`;
301+
302+
t.expectCompileResult(scope === undefined, code);
303+
});

src/webgpu/shader/validation/parse/const.spec.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)