summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/unittests/params_builder_toplevel.spec.ts
blob: 08a84b23e7f28e50eeb2868cff8a0f7f3250df03 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
export const description = `
Unit tests for parameterization.
`;

import { TestParams } from '../common/framework/fixture.js';
import { kUnitCaseParamsBuilder } from '../common/framework/params_builder.js';
import { makeTestGroup } from '../common/framework/test_group.js';
import { makeTestGroupForUnitTesting } from '../common/internal/test_group.js';

import { TestGroupTest } from './test_group_test.js';
import { UnitTest } from './unit_test.js';

export const g = makeTestGroup(TestGroupTest);

g.test('combine_none,arg_unit')
  .params(u => u.combineWithParams([]))
  .fn(t => {
    t.fail("this test shouldn't run");
  });

g.test('combine_none,arg_ignored')
  .params(() => kUnitCaseParamsBuilder.combineWithParams([]))
  .fn(t => {
    t.fail("this test shouldn't run");
  });

g.test('combine_none,plain_builder')
  .params(kUnitCaseParamsBuilder.combineWithParams([]))
  .fn(t => {
    t.fail("this test shouldn't run");
  });

g.test('combine_none,plain_array')
  .paramsSimple([])
  .fn(t => {
    t.fail("this test shouldn't run");
  });

g.test('combine_one,case')
  .params(u =>
    u //
      .combineWithParams([{ x: 1 }])
  )
  .fn(t => {
    t.expect(t.params.x === 1);
  });

g.test('combine_one,subcase')
  .paramsSubcasesOnly(u =>
    u //
      .combineWithParams([{ x: 1 }])
  )
  .fn(t => {
    t.expect(t.params.x === 1);
  });

g.test('filter')
  .params(u =>
    u
      .combineWithParams([
        { a: true, x: 1 }, //
        { a: false, y: 2 },
      ])
      .filter(p => p.a)
  )
  .fn(t => {
    t.expect(t.params.a);
  });

g.test('unless')
  .params(u =>
    u
      .combineWithParams([
        { a: true, x: 1 }, //
        { a: false, y: 2 },
      ])
      .unless(p => p.a)
  )
  .fn(t => {
    t.expect(!t.params.a);
  });

g.test('generator').fn(t0 => {
  const g = makeTestGroupForUnitTesting(UnitTest);

  const ran: TestParams[] = [];

  g.test('generator')
    .params(u =>
      u.combineWithParams({
        *[Symbol.iterator]() {
          for (let x = 0; x < 3; ++x) {
            for (let y = 0; y < 2; ++y) {
              yield { x, y };
            }
          }
        },
      })
    )
    .fn(t => {
      ran.push(t.params);
    });

  t0.expectCases(g, [
    { test: ['generator'], params: { x: 0, y: 0 } },
    { test: ['generator'], params: { x: 0, y: 1 } },
    { test: ['generator'], params: { x: 1, y: 0 } },
    { test: ['generator'], params: { x: 1, y: 1 } },
    { test: ['generator'], params: { x: 2, y: 0 } },
    { test: ['generator'], params: { x: 2, y: 1 } },
  ]);
});