Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that constructible objects are actually constructible #3220

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/webgpu/idl/constructable.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
});
3 changes: 3 additions & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@
"webgpu:idl,constants,flags:ShaderStage,values:*": { "subcaseMS": 0.034 },
"webgpu:idl,constants,flags:TextureUsage,count:*": { "subcaseMS": 0.101 },
"webgpu:idl,constants,flags:TextureUsage,values:*": { "subcaseMS": 0.040 },
"webgpu:idl,constructable:gpu_errors:*": { "subcaseMS": 0.101 },
"webgpu:idl,constructable:pipeline_errors:*": { "subcaseMS": 0.101 },
"webgpu:idl,constructable:uncaptured_error_event:*": { "subcaseMS": 0.101 },
"webgpu:shader,execution,expression,binary,af_addition:scalar:*": { "subcaseMS": 815.300 },
"webgpu:shader,execution,expression,binary,af_addition:scalar_vector:*": { "subcaseMS": 1803.434 },
"webgpu:shader,execution,expression,binary,af_addition:vector:*": { "subcaseMS": 719.600 },
Expand Down