Skip to content

Commit

Permalink
feat: release 2.0
Browse files Browse the repository at this point in the history
Fixes #16
Fixes #5
Fixes #3
  • Loading branch information
remy committed Jan 11, 2018
1 parent 606a3ae commit 1631ef2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "loop-protect",
"description": "Prevent infinite loops in dynamically eval'd JavaScript.",
"main": "lib/",
"version": "2.0.0-beta.2",
"version": "2.0.0",
"homepage": "https://github.com/jsbin/loop-protect",
"repository": {
"type": "git",
Expand Down
34 changes: 34 additions & 0 deletions test/loop-protect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,40 @@ describe('loop', function() {
spy = sinon.spy(run);
});

// https://github.com/jsbin/loop-protect/issues/16
it('should handle nested for', () => {
const code = `for (var i = 0; i < 10; i = i + 1) {
for (var j = 0; j < 10; i = i + 1) {
}
}
return true`;

const compiled = loopProtect(code);
assert(run(compiled) === true);
});

// https://github.com/jsbin/loop-protect/issues/5
it('blank line', () => {
const code = `const log = () => {};while (1)
log('Hello')
return true`;

const compiled = loopProtect(code);
assert(run(compiled) === true);
});

it('with if', () => {
const code = `if (false) for (var i = 1; i--;) {
throw Error;
}
return true;`;

const compiled = loopProtect(code);
assert(run(compiled) === true);
});

it('should ignore comments', function() {
var c = code.ignorecomments;
var compiled = loopProtect(c);
Expand Down

0 comments on commit 1631ef2

Please sign in to comment.