Skip to content

Commit 1631ef2

Browse files
committed
feat: release 2.0
Fixes #16 Fixes #5 Fixes #3
1 parent 606a3ae commit 1631ef2

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "loop-protect",
44
"description": "Prevent infinite loops in dynamically eval'd JavaScript.",
55
"main": "lib/",
6-
"version": "2.0.0-beta.2",
6+
"version": "2.0.0",
77
"homepage": "https://github.com/jsbin/loop-protect",
88
"repository": {
99
"type": "git",

test/loop-protect.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,40 @@ describe('loop', function() {
7373
spy = sinon.spy(run);
7474
});
7575

76+
// https://github.com/jsbin/loop-protect/issues/16
77+
it('should handle nested for', () => {
78+
const code = `for (var i = 0; i < 10; i = i + 1) {
79+
for (var j = 0; j < 10; i = i + 1) {
80+
}
81+
}
82+
return true`;
83+
84+
const compiled = loopProtect(code);
85+
assert(run(compiled) === true);
86+
});
87+
88+
// https://github.com/jsbin/loop-protect/issues/5
89+
it('blank line', () => {
90+
const code = `const log = () => {};while (1)
91+
92+
log('Hello')
93+
return true`;
94+
95+
const compiled = loopProtect(code);
96+
assert(run(compiled) === true);
97+
});
98+
99+
it('with if', () => {
100+
const code = `if (false) for (var i = 1; i--;) {
101+
throw Error;
102+
}
103+
104+
return true;`;
105+
106+
const compiled = loopProtect(code);
107+
assert(run(compiled) === true);
108+
});
109+
76110
it('should ignore comments', function() {
77111
var c = code.ignorecomments;
78112
var compiled = loopProtect(c);

0 commit comments

Comments
 (0)