-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that constructable objects are actually constructable
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
export const description = ` | ||
Test that constructable WebGPU objects are actually constructable. | ||
`; | ||
|
||
import { keysOf } from '../../common/util/data_tables.js'; | ||
|
||
import { makeTestGroup } from './../../common/framework/test_group.js'; | ||
import { IDLTest } from './idl_test.js'; | ||
|
||
export const g = makeTestGroup(IDLTest); | ||
|
||
const errors = { | ||
GPUInternalError: globalThis.GPUInternalError, | ||
GPUOutOfMemoryError: globalThis.GPUOutOfMemoryError, | ||
GPUValidationError: globalThis.GPUValidationError, | ||
}; | ||
|
||
g.test('gpu_errors') | ||
.desc('tests that GPUErrors are constructable') | ||
.params(u => u.combine('errorType', keysOf(errors))) | ||
.fn(t => { | ||
const { errorType } = t.params; | ||
const Ctor = errors[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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters