gpu.js/test/features/constants-integer.js
Robert Plummer 8bf362ad9a feat: No failing tests locally, only skipping and passing
Also:
feat: Typescript typings
feat: api cleanup and exports
feat: removal of building for node, only browser
2019-01-29 21:41:21 -05:00

47 lines
1.0 KiB
JavaScript

const { assert, skip, test, module: describe } = require('qunit');
const { GPU } = require('../../src');
describe('features: constants integer');
function integerConstantTest(mode) {
const gpu = new GPU({ mode });
const int = 200;
const tryConst = gpu.createKernel(
function() {
return this.constants.int;
},
{
constants: { int }
}
).setOutput([2]);
const result = tryConst();
const match = new Float32Array([200, 200]);
const test = (result[0] === match[0] && result[1] === match[1]);
assert.ok(test, 'int constant passed test');
gpu.destroy();
}
test('auto', () => {
integerConstantTest(null);
});
test('gpu', () => {
integerConstantTest('gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
integerConstantTest('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
integerConstantTest('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
integerConstantTest('headlessgl');
});
test('cpu', () => {
integerConstantTest('cpu');
});