mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
fix: dev mode kernel to be added to GPU.kernels fix: Array switching with array type is not defined in single precision mode fix: GPU.destroy when no context is set
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
const { assert, skip, test, module: describe } = require('qunit');
|
|
const { GPU } = require('../../src');
|
|
const sinon = require('sinon');
|
|
|
|
describe('features: destroy');
|
|
|
|
function testWithoutDestroyContext(done, mode) {
|
|
const gpu = new GPU({ mode });
|
|
const destroyKernel = sinon.spy();
|
|
gpu.kernels.push({
|
|
kernel: {
|
|
constructor: {
|
|
destroyContext: null
|
|
}
|
|
},
|
|
destroy: destroyKernel
|
|
});
|
|
gpu.destroy();
|
|
gpu.destroy();
|
|
setTimeout(() => {
|
|
assert.equal(destroyKernel.callCount, 2);
|
|
assert.ok(true);
|
|
done();
|
|
}, 2);
|
|
}
|
|
|
|
test('without destroy context', (t) => {
|
|
const done = t.async();
|
|
testWithoutDestroyContext(done);
|
|
});
|
|
|
|
function testWithDestroyContext(done, mode) {
|
|
const gpu = new GPU({ mode });
|
|
const destroyKernel = sinon.spy();
|
|
const destroyContextSpy = sinon.spy();
|
|
gpu.kernels.push({
|
|
kernel: {
|
|
constructor: {
|
|
destroyContext: destroyContextSpy
|
|
}
|
|
},
|
|
destroy: destroyKernel
|
|
});
|
|
gpu.destroy();
|
|
gpu.destroy();
|
|
setTimeout(() => {
|
|
assert.equal(destroyKernel.callCount, 2);
|
|
assert.equal(destroyContextSpy.callCount, 2);
|
|
assert.ok(true);
|
|
done();
|
|
}, 2);
|
|
}
|
|
|
|
test('with destroy context', (t) => {
|
|
const done = t.async();
|
|
testWithDestroyContext(done);
|
|
});
|