Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ljqx authored and Unknown committed Jun 16, 2017
1 parent 9bff9ac commit 399471c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,8 @@ class Parser extends Tapable {
renames: Object.create(oldScope.renames)
};

this.scope.renames.$this = undefined;

for(let paramIndex = 0, len = params.length; paramIndex < len; paramIndex++) {
const param = params[paramIndex];

Expand Down
15 changes: 12 additions & 3 deletions test/Parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,22 @@ describe("Parser", () => {
abc: ["test"]
}
],
"renaming with IIFE (called)": [
"renaming arguments with IIFE (called)": [
function() {
! function(xyz) {
xyz("test");
}.call(fgh, abc);
}, {
abc: ["test"],
fgh: [""]
abc: ["test"]
}
],
"renaming this's properties with IIFE (called)": [
function() {
! function() {
this.sub;
}.call(fgh);
}, {
fghsub: ["notry"]
}
],
};
Expand All @@ -181,6 +189,7 @@ describe("Parser", () => {

const testParser = new Parser({});
testParser.plugin("can-rename abc", (expr) => true);
testParser.plugin("can-rename fgh", (expr) => true);
testParser.plugin("call abc", (expr) => {
if(!testParser.state.abc) testParser.state.abc = [];
testParser.state.abc.push(testParser.parseString(expr.arguments[0]));
Expand Down

0 comments on commit 399471c

Please sign in to comment.