Skip to content

Commit be3f065

Browse files
committed
Created the test case
1 parent dc38a63 commit be3f065

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

test/html/test-all.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
<script src="../src/internal/GPUUtils_test.js"></script>
3838
<script src="../src/internal/functionNode_test.js"></script>
3939
<script src="../src/internal/functionBuilder_test.js"></script>
40-
40+
41+
<!-- bug issues -->
42+
<script src="../src/issues/31-nested-var-declare_test.js"></script>
4143
</body>
4244
</html>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// See: https://github.com/gpujs/gpu.js/issues/31
3+
//
4+
function nestedVarDeclare( mode ) {
5+
var gpu = new GPU();
6+
var f = gpu.createKernel(function() {
7+
var ret = 0.0;
8+
9+
// outer loop limit is effectively skipped in CPU
10+
for(var i=0; i<10; ++i) {
11+
// inner loop limit should be higher, to avoid infinite loops
12+
for(var i=0; i<20; ++i) {
13+
ret += 1;
14+
}
15+
}
16+
17+
return ret;
18+
}, {
19+
dimensions : [1],
20+
mode : mode
21+
});
22+
23+
QUnit.ok( f !== null, "function generated test");
24+
QUnit.close(f(), 20, 0.00, "basic return function test");
25+
}
26+
27+
QUnit.test( "Issue #31 - nestedVarDeclare (auto)", function() {
28+
nestedVarDeclare(null);
29+
});
30+
31+
QUnit.test( "Issue #31 - nestedVarDeclare (GPU)", function() {
32+
nestedVarDeclare("gpu");
33+
});
34+
35+
QUnit.test( "Issue #31 - nestedVarDeclare (CPU)", function() {
36+
nestedVarDeclare("cpu");
37+
});

0 commit comments

Comments
 (0)