Skip to content

Commit

Permalink
Update escope to use new esrecurse with fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Mar 11, 2016
1 parent 5b6a2ba commit f1e15a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"es6-map": "^0.1.3",
"es6-weak-map": "^2.0.1",
"esrecurse": "^4.0.0",
"esrecurse": "^4.1.0",
"estraverse": "^4.1.1"
},
"devDependencies": {
Expand Down
12 changes: 11 additions & 1 deletion test/fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('fallback option', function() {
}).to.throw("Unknown node type NumericLiteral");
});

it('should not raise an error even if it encountered an unknown node.', function() {
it('should not raise an error even if it encountered an unknown node when fallback is iteration.', function() {
const ast = esprima.parse(`
var foo = 0;
`);
Expand All @@ -48,6 +48,16 @@ describe('fallback option', function() {
analyze(ast); // default is `fallback: 'iteration'`
analyze(ast, {fallback: 'iteration'});
});

it('should not raise an error even if it encountered an unknown node when fallback is a function.', function() {
const ast = esprima.parse(`
var foo = 0;
`);

ast.body[0].declarations[0].init.type = 'NumericLiteral';

analyze(ast, {fallback: node => Object.keys(node)});
});
});

// vim: set sw=4 ts=4 et tw=80 :

0 comments on commit f1e15a3

Please sign in to comment.