forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path470-modulus-wrong.js
More file actions
53 lines (44 loc) · 1.21 KB
/
470-modulus-wrong.js
File metadata and controls
53 lines (44 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const { assert, skip, test, module: describe } = require('qunit');
const { GPU } = require('../../src');
describe('issue #470 - modulus wrong');
function testModulusWrong(mode) {
const gpu = new GPU({ mode });
const kernel = gpu.createKernel(function(mod) {
return this.thread.x % mod;
}, {
output: [10],
argumentTypes: {
mod: 'Integer',
},
});
const result = kernel(6);
assert.equal(kernel.argumentTypes[0], 'Integer');
assert.equal(result[0], 0 % 6);
assert.equal(result[1], 1 % 6);
assert.equal(result[2], 2 % 6);
assert.equal(result[3], 3 % 6);
assert.equal(result[4], 4 % 6);
assert.equal(result[5], 5 % 6);
assert.equal(result[6], 6 % 6);
assert.equal(result[7], 7 % 6);
assert.equal(result[8], 8 % 6);
assert.equal(result[9], 9 % 6);
}
test('auto', () => {
testModulusWrong();
});
test('gpu', () => {
testModulusWrong('gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
testModulusWrong('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
testModulusWrong('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
testModulusWrong('headlessgl');
});
test('cpu', () => {
testModulusWrong('cpu');
});