gpu.js/test/issues/313-variable-lookup.js
Robert Plummer 2b45882c58 feat: Raw output
feat: Consolidate subKernels rendering code as part of the renderStrategy
fix: remove tabs, replace with spaces
fix: make FunctionBuilder.fromKernel typing static
fix: Add missing FunctionBuilder.getPrototypeString definition
fix: Move building logic to kernelRunShortcut as well as exec method
2019-05-17 18:42:35 -04:00

48 lines
1.3 KiB
JavaScript

const { assert, skip, test, module: describe } = require('qunit');
const { GPU } = require('../../src');
describe('issue #313');
function variableLookup(mode) {
function mult2(scale) {
return 2*scale;
}
const gpu = new GPU({
mode,
functions: [mult2]
});
const render1 = gpu.createKernel(function(input) {
return (mult2(input) + mult2(input*2) + mult2(input*1)) // RIGHT
})
.setOutput([1]);
const render2 = gpu.createKernel(function(input) {
return (mult2(input) + mult2(input*2) + mult2(input)); // WRONG
})
.setOutput([1]);
assert.equal(render1(1)[0], 8, 'render1 equals 8');
assert.equal(render2(1)[0], 8, 'render2 equals 8');
gpu.destroy();
}
test('Issue #313 Mismatch argument lookup - auto', () => {
variableLookup();
});
test('Issue #313 Mismatch argument lookup - gpu', () => {
variableLookup('gpu');
});
(GPU.isWebGLSupported ? test : skip)('Issue #313 Mismatch argument lookup - webgl', () => {
variableLookup('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('Issue #313 Mismatch argument lookup - webgl2', () => {
variableLookup('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('Issue #313 Mismatch argument lookup - headlessgl', () => {
variableLookup('headlessgl');
});
test('Issue #313 Mismatch argument lookup - cpu', () => {
variableLookup('cpu');
});