Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
108 lines (88 loc) · 2.9 KB

File metadata and controls

108 lines (88 loc) · 2.9 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
///
/// Test the various basic functionality of functionNode
///
/// Test the creation of a hello_world function
QUnit.test( "hello_world: just return magic 42", function( assert ) {
assert.notEqual( GPU.CPUFunctionNode, null, "script include check" );
// Create a function hello node
var node = new GPU.WebGLFunctionNode(
"hello_world",
function() {
return 42;
}
);
assert.notEqual( node, null, "class creation check" );
assert.notEqual( node.getJsAST(), null, "AST fetch check" );
assert.equal(
node.getFunctionString().replace(/\s+/g,' '),
"float hello_world() { return 42.0; }",
"webgl function conversion check"
);
});
/// Test creation of function, that calls another function
QUnit.test( "hello_inner: call a function inside a function", function( assert ) {
assert.notEqual( GPU.CPUFunctionNode, null, "script include check" );
function inner() {
return 42;
}
// Create a function hello node
var node = new GPU.WebGLFunctionNode(
"hello_inner",
function() {
return inner();
}
);
assert.notEqual( node, null, "class creation check" );
assert.notEqual( node.getJsAST(), null, "AST fetch check" );
assert.equal(
node.getFunctionString().replace(/\s+/g,' '),
"float hello_inner() { return inner(); }",
"webgl function conversion check"
);
assert.deepEqual( node.calledFunctions, ["inner"] );
});
/// Test creation of function, that calls another function, with ARGS
QUnit.test( "Math.round implementation: A function with arguments", function( assert ) {
// Math.round node
var node = new GPU.WebGLFunctionNode(
"round",
function(a) {
return Math.floor( a + 0.5 );
}
);
assert.notEqual( node, null, "class creation check" );
assert.notEqual( node.getJsAST(), null, "AST fetch check" );
assert.equal(
node.getFunctionString().replace(/\s+/g,' ').replace(/user_/g,''),
"float round(float a) { return floor((a+0.5)); }",
"webgl function conversion check"
);
assert.deepEqual( node.calledFunctions, ["floor"] );
});
/// Test creation of function, that calls another function, with ARGS
QUnit.test( "Two arguments test", function( assert ) {
var node = new GPU.WebGLFunctionNode(
"add_together",
function(a,b) {
return a+b;
}
);
assert.notEqual( node, null, "class creation check" );
assert.notEqual( node.getJsAST(), null, "AST fetch check" );
assert.equal(
node.getFunctionString().replace(/\s+/g,' ').replace(/user_/g,''),
"float add_together(float a, float b) { return (a+b); }",
"webgl function conversion check"
);
});
/// Test the creation of a hello_world function
QUnit.test( "Automatic naming support", function( assert ) {
assert.notEqual( GPU.CPUFunctionNode, null, "script include check" );
function hello_world() {
return 42;
}
// Create a function hello node
var node = new GPU.CPUFunctionNode(null, hello_world);
assert.notEqual( node, null, "class creation check" );
assert.equal( node.functionName, "hello_world" );
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.