tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

uniformity_snippet.spec.ts (1218B)


      1 export const description = `
      2 Test for shader uniformity code snippet generation.
      3 `;
      4 
      5 import { makeTestGroup } from '../common/framework/test_group.js';
      6 import { specToCode } from '../webgpu/shader/validation/uniformity/snippet.js';
      7 
      8 import { UnitTest } from './unit_test.js';
      9 
     10 class F extends UnitTest {
     11  test(spec: string, expect: string): void {
     12    const got = specToCode(spec);
     13    this.expect(
     14      expect === got,
     15      `
     16 expected: ${expect}
     17 got:      ${got}`
     18    );
     19  }
     20 }
     21 
     22 export const g = makeTestGroup(F);
     23 
     24 g.test('strings').fn(t => {
     25  t.test(
     26    'loop-end',
     27    `  loop {
     28  }
     29 `
     30  ),
     31    t.test(
     32      'loop-cond-break-op',
     33      `  loop {
     34    if <cond> {break;}
     35    <op>
     36  }
     37 `
     38    ),
     39    t.test(
     40      'for-unif-always-return-op',
     41      `  for (;<uniform_cond>;) {
     42    return;
     43    <op>
     44  }
     45 `
     46    ),
     47    t.test(
     48      'loop-op-continuing-cond-break',
     49      `  loop {
     50    <op>
     51    continuing {
     52      break if <cond>;
     53    }
     54  }
     55 `
     56    ),
     57    t.test(
     58      // This is the case suggested in https://github.com/gpuweb/cts/pull/4477#issuecomment-3408419425
     59      'loop-always-return-continuing-cond-break-end-op',
     60      `  loop {
     61    return;
     62    continuing {
     63      break if <cond>;
     64    }
     65  }
     66  <op>
     67 `
     68    );
     69 });