diff options
Diffstat (limited to 'Libraries/LibJS/Tests/for-head-errors.js')
-rw-r--r-- | Libraries/LibJS/Tests/for-head-errors.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/for-head-errors.js b/Libraries/LibJS/Tests/for-head-errors.js new file mode 100644 index 0000000000..20ed79c07e --- /dev/null +++ b/Libraries/LibJS/Tests/for-head-errors.js @@ -0,0 +1,36 @@ +load("test-common.js"); + +try { + assertThrowsError(() => { + for (var i = foo; i < 100; ++i) { + assertNotReached(); + } + }, { + error: ReferenceError, + message: "'foo' not known" + }); + + assertThrowsError(() => { + for (var i = 0; i < foo; ++i) { + assertNotReached(); + } + }, { + error: ReferenceError, + message: "'foo' not known" + }); + + var loopCount = 0; + assertThrowsError(() => { + for (var i = 0; i < 100; ++foo) { + loopCount++; + } + }, { + error: ReferenceError, + message: "'foo' not known" + }); + assert(loopCount === 1); + + console.log("PASS"); +} catch (e) { + console.log("FAIL: " + e); +} |