gpu.js/test/features/infinity.js
Robert Plummer b9f7d7bff0 fix: Move varWarn to and unit test that all FunctionNode's use it
fix: Test that getExtension is set to be able to use on TravisCI
fix: Remove wraparound, is no longer being used anywhere
fix: add getMemoryOptimizedPackedTextureSize to string kernel
fix: Remove console.log() usage
fix: Move addFunction functionality into new utils method `functionToIFunction`
fix: Fix mergeSettings to use `functions` settings and use `functionToIFunction`
fix: Remove the spread operator for now, for compatibility with safari
fix: Add typings for `setFunctions`
fix; Failing unit tests for sarafi
feat: Add CONTRIBUTING.md
feat: Add ISSUE_TEMPLATE.md
fix: Remove typescript from dependencies
fix: Document, document, document
fix: Bump version and build
2019-04-23 22:03:14 -04:00

71 lines
2.4 KiB
JavaScript

const { assert, skip, test, module: describe } = require('qunit');
const { GPU } = require('../../src');
describe('infinity');
function inputWithoutFloat(checks, mode) {
const gpu = new GPU({ mode });
checks(gpu.createKernel(function() {
return Infinity;
}, { precision: 'unsigned' })
.setOutput([1])());
gpu.destroy();
}
test("Infinity without float auto", () => {
inputWithoutFloat((v) => assert.deepEqual(v[0], NaN));
});
test("Infinity without float cpu", () => {
inputWithoutFloat((v) => assert.deepEqual(v[0], Infinity), 'cpu');
});
test("Infinity without float gpu", () => {
inputWithoutFloat((v) => assert.deepEqual(v[0], NaN), 'gpu');
});
(GPU.isWebGLSupported ? test : skip)("Infinity without float webgl", () => {
inputWithoutFloat((v) => assert.deepEqual(v[0], NaN), 'webgl');
});
(GPU.isWebGL2Supported ? test : skip)("Infinity without float webgl2", () => {
inputWithoutFloat((v) => assert.deepEqual(v[0], NaN), 'webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)("Infinity without float headlessgl", () => {
inputWithoutFloat((v) => assert.deepEqual(v[0], NaN), 'headlessgl');
});
function inputWithFloat(checks, mode) {
const gpu = new GPU({ mode });
checks(gpu.createKernel(function() {
return Infinity;
}, { precision: 'single' })
.setOutput([1])());
gpu.destroy();
}
(GPU.isSinglePrecisionSupported ? test : skip)("Infinity with float auto", () => {
inputWithFloat((v) => assert.deepEqual(v[0], 3.4028234663852886e+38));
});
(GPU.isSinglePrecisionSupported ? test : skip)("Infinity with float cpu", () => {
inputWithFloat((v) => assert.deepEqual(v[0], Infinity), 'cpu');
});
(GPU.isSinglePrecisionSupported ? test : skip)("Infinity with float gpu", () => {
inputWithFloat((v) => assert.deepEqual(v[0], 3.4028234663852886e+38), 'gpu');
});
(GPU.isSinglePrecisionSupported && GPU.isWebGLSupported ? test : skip)("Infinity with float webgl", () => {
inputWithFloat((v) => assert.deepEqual(v[0], 3.4028234663852886e+38), 'webgl');
});
(GPU.isSinglePrecisionSupported && GPU.isWebGL2Supported ? test : skip)("Infinity with float webgl2", () => {
inputWithFloat((v) => assert.deepEqual(v[0], 3.4028234663852886e+38), 'webgl2');
});
(GPU.isSinglePrecisionSupported && GPU.isHeadlessGLSupported ? test : skip)("Infinity with float headlessgl", () => {
inputWithFloat((v) => assert.deepEqual(v[0], 3.4028234663852886e+38), 'headlessgl');
});