gpu.js/test/features/json.js
Robert Plummer ef3f0cf001 feat: support for boolean as variable, argument, and constant
fix: implied else issue discovered, and fixed when testing boolean using leading and following return statements
fix: Added a section in documentation about types and added reference to boolean
fix: Bump and build
2019-04-29 08:45:43 -04:00

45 lines
873 B
JavaScript

const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('json serialize');
function testJSONSerialize(mode) {
const gpu = new GPU({mode});
const kernel = gpu.createKernel(function (value) {
return value;
}, {output: [1]});
kernel(1);
const json = kernel.toJSON();
const jsonKernel = gpu.createKernel(json);
assert.equal(jsonKernel(3)[0], 3);
}
test('auto', () => {
testJSONSerialize();
});
test('gpu', () => {
testJSONSerialize('gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
testJSONSerialize('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
testJSONSerialize('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
testJSONSerialize('headlessgl');
});
test('cpu', () => {
testJSONSerialize('cpu');
});