summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/shader/validation/parse/source.spec.ts
blob: 40da5d2baf8f4d929c743f1e5b79f1033cf33709 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
export const description = `Validation tests for source parsing`;

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { ShaderValidationTest } from '../shader_validation_test.js';

export const g = makeTestGroup(ShaderValidationTest);

g.test('valid_source')
  .desc(`Tests that a valid source is consumed successfully.`)
  .fn(t => {
    const code = `
    @fragment
    fn main() -> @location(0) vec4<f32> {
      return vec4<f32>(.4, .2, .3, .1);
    }`;
    t.expectCompileResult(true, code);
  });

g.test('empty')
  .desc(`Test that an empty source is consumed successfully.`)
  .fn(t => {
    t.expectCompileResult(true, '');
  });

g.test('invalid_source')
  .desc(`Tests that a source which does not match the grammar fails.`)
  .fn(t => {
    t.expectCompileResult(false, 'invalid_source');
  });