From 5a23afd91e395125ece1ae940f228929b1989438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Mon, 4 Nov 2024 18:14:12 +0100 Subject: [PATCH] Add same_object test --- src/webgpu/api/operation/adapter/info.spec.ts | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/src/webgpu/api/operation/adapter/info.spec.ts b/src/webgpu/api/operation/adapter/info.spec.ts index 94048d050a9..1758e0127e0 100644 --- a/src/webgpu/api/operation/adapter/info.spec.ts +++ b/src/webgpu/api/operation/adapter/info.spec.ts @@ -40,26 +40,41 @@ g.test('adapter_info') ); }); +g.test('same_object') + .desc( + ` +GPUAdapter.info provides the same object each time it's accessed` + ) + .fn(async t => { + const gpu = getGPU(t.rec); + const adapter = await gpu.requestAdapter(); + assert(adapter !== null); + + const adapterInfo1 = adapter.info; + const adapterInfo2 = adapter.info; + t.expect(adapterInfo1 === adapterInfo2); + }); + g.test('device_matches_adapter') -.desc( - ` + .desc( + ` Test that GPUDevice.adapterInfo matches GPUAdapter.info` -) -.fn(async t => { - const gpu = getGPU(t.rec); - const adapter = await gpu.requestAdapter(); - assert(adapter !== null); + ) + .fn(async t => { + const gpu = getGPU(t.rec); + const adapter = await gpu.requestAdapter(); + assert(adapter !== null); - const device = await t.requestDeviceTracked(adapter); - assert(device !== null); + const device = await t.requestDeviceTracked(adapter); + assert(device !== null); - assert(device.adapterInfo instanceof GPUAdapterInfo); - assert(adapter.info instanceof GPUAdapterInfo); + assert(device.adapterInfo instanceof GPUAdapterInfo); + assert(adapter.info instanceof GPUAdapterInfo); - for (const k of Object.keys(GPUAdapterInfo.prototype)) { - t.expect( - objectEquals(device.adapterInfo[k], adapter.info[k]), - `device.adapterInfo.${k} is "${device.adapterInfo[k]}". Expected "${adapter.info[k]}"` - ); - } -}); + for (const k of Object.keys(GPUAdapterInfo.prototype)) { + t.expect( + objectEquals(device.adapterInfo[k], adapter.info[k]), + `device.adapterInfo.${k} is "${device.adapterInfo[k]}". Expected "${adapter.info[k]}"` + ); + } + });