forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path567-wrong-modulus.js
More file actions
76 lines (63 loc) · 1.57 KB
/
567-wrong-modulus.js
File metadata and controls
76 lines (63 loc) · 1.57 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('issue #567 - wrong modulus');
function testWrongModulus(mode) {
const gpu = new GPU({ mode });
const kernel1 = gpu.createKernel(function () {
return 91 % 7;
}, {
output: [1]
});
assert.equal(kernel1()[0], 91 % 7);
const kernel2 = gpu.createKernel(function (value1, value2) {
return value1 % value2;
}, {
output: [1],
});
assert.equal(kernel2(91, 7)[0], 91 % 7);
const kernel3 = gpu.createKernel(function (value1, value2) {
return value1 % value2;
}, {
output: [1],
});
assert.equal(kernel3(91, 7)[0], 91 % 7);
const kernel4 = gpu.createKernel(function () {
return this.constants.value1 % this.constants.value2;
}, {
output: [1],
constants: {
value1: 91,
value2: 7,
}
});
assert.equal(kernel4()[0].toFixed(2), 91 % 7);
const kernel5 = gpu.createKernel(function () {
return 91 % this.constants.value;
}, {
output: [1],
constants: {
value: 7
},
strictIntegers: true
});
assert.equal(kernel5()[0], 91 % 7);
gpu.destroy();
}
test('auto', () => {
testWrongModulus();
});
test('gpu', () => {
testWrongModulus('gpu');
});
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
testWrongModulus('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
testWrongModulus('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
testWrongModulus('headlessgl');
});
test('cpu', () => {
testWrongModulus('cpu');
});