-
Notifications
You must be signed in to change notification settings - Fork 77
/
constructable.spec.ts
54 lines (48 loc) · 1.51 KB
/
constructable.spec.ts
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
export const description = `
Test that constructable WebGPU objects are actually constructable.
`;
import { makeTestGroup } from './../../common/framework/test_group.js';
import { IDLTest } from './idl_test.js';
export const g = makeTestGroup(IDLTest);
g.test('gpu_errors')
.desc('tests that GPUErrors are constructable')
.params(u =>
u.combine('errorType', [
'GPUInternalError',
'GPUOutOfMemoryError',
'GPUValidationError',
] as const)
)
.fn(t => {
const { errorType } = t.params;
const Ctor = globalThis[errorType];
const msg = 'this is a test';
const error = new Ctor(msg);
t.expect(error.message === msg);
});
const pipelineErrorOptions: GPUPipelineErrorInit[] = [
{ reason: 'validation' },
{ reason: 'internal' },
];
g.test('pipeline_errors')
.desc('tests that GPUPipelineError is constructable')
.params(u =>
u //
.combine('msg', [undefined, 'some msg'])
.combine('options', pipelineErrorOptions)
)
.fn(t => {
const { msg, options } = t.params;
const error = new GPUPipelineError(msg, options);
const expectedMsg = msg || '';
t.expect(error.message === expectedMsg);
t.expect(error.reason === options.reason);
});
g.test('uncaptured_error_event')
.desc('tests that GPUUncapturedErrorEvent is constructable')
.fn(t => {
const msg = 'this is a test';
const error = new GPUValidationError(msg);
const event = new GPUUncapturedErrorEvent('uncapturedError', { error });
t.expect(event.error === error);
});