-
Notifications
You must be signed in to change notification settings - Fork 664
/
Copy pathfunctions-as-strings.js
45 lines (37 loc) · 1.08 KB
/
functions-as-strings.js
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
const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('internal: functions-as-atrings');
function functionsAsStrings(mode) {
const gpu = new GPU({ mode });
const kernel = gpu.createKernel(`function() {
let x = frodo(0)
return x;
}`, {
output: [1],
});
kernel.addFunction(`function frodo(a){
return a + 1
}`)
const result = kernel();
console.log('result',result)
assert.equal(result[0],1);
gpu.destroy();
}
test('boolean expression false auto', () => {
functionsAsStrings();
});
test('boolean expression false gpu', () => {
functionsAsStrings('gpu');
});
(GPU.isWebGLSupported ? test : skip)('boolean expression false webgl', () => {
functionsAsStrings('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('boolean expression false webgl2', () => {
functionsAsStrings('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('boolean expression false headlessgl', () => {
functionsAsStrings('headlessgl');
});
test('boolean expression false cpu', () => {
functionsAsStrings('cpu');
});