Skip to content

Commit

Permalink
Add same_object test
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed Nov 4, 2024
1 parent 5b2d7b4 commit 5a23afd
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions src/webgpu/api/operation/adapter/info.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"`
);
}
});

0 comments on commit 5a23afd

Please sign in to comment.