gpu.js/test/issues/147-missing-constant.js
Robert Plummer b2df0ab604 fix #316
Change `HTMLImageArray` render strategy to `gl.NEAREST`, like all the others
Let `WebGL2FunctionNode` extend `WebGLFunctionNode` and lighten
Remove all the different html pages associated with tests, and just use one file to handle them and use qunit for filtering them
Bump version number
2018-06-12 14:07:41 -04:00

42 lines
1.2 KiB
JavaScript

(function() {
function getValue(mode) {
var gpu = new GPU({ mode: mode });
const kernel = gpu.createKernel(function() {
return getPi();
})
.setOutput([1])
.setConstants({ pi: Math.PI });
gpu.addFunction(function getPi() {
return this.constants.pi;
});
return kernel();
}
QUnit.test( "Issue #130 - missing constant (cpu)", function() {
var value = getValue('cpu');
QUnit.assert.equal((value[0]).toFixed(7), Math.PI.toFixed(7));
});
QUnit.test( "Issue #130 - missing constant (auto)", function() {
var value = getValue(null);
QUnit.assert.equal((value[0]).toFixed(7), Math.PI.toFixed(7));
});
QUnit.test( "Issue #130 - missing constant (gpu)", function() {
var value = getValue('gpu');
QUnit.assert.equal((value[0]).toFixed(7), Math.PI.toFixed(7));
});
QUnit.test( "Issue #130 - missing constant (webgl)", function() {
var value = getValue('webgl');
QUnit.assert.equal((value[0]).toFixed(7), Math.PI.toFixed(7));
});
QUnit.test( "Issue #130 - missing constant (webgl2)", function() {
var value = getValue('webgl2');
QUnit.assert.equal((value[0]).toFixed(7), Math.PI.toFixed(7));
});
})();