Skip to content

Commit 3c53df7

Browse files
committed
Added unit tests for new Foo (...) parser feature
1 parent 5ab6972 commit 3c53df7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/Parser.unittest.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ describe("Parser", () => {
191191
ijksub: ["test"]
192192
}
193193
],
194+
"new Foo(...)": [
195+
function() {
196+
new xyz("membertest");
197+
}, {
198+
xyz: ["membertest"]
199+
}
200+
],
194201
};
195202

196203
Object.keys(testCases).forEach((name) => {
@@ -237,6 +244,11 @@ describe("Parser", () => {
237244
testParser.state.expressions.push(expr.name);
238245
return true;
239246
});
247+
testParser.plugin("new xyz", (expr) => {
248+
if(!testParser.state.xyz) testParser.state.xyz = [];
249+
testParser.state.xyz.push(testParser.parseString(expr.arguments[0]));
250+
return true;
251+
});
240252
const actual = testParser.parse(source);
241253
should.strictEqual(typeof actual, "object");
242254
actual.should.be.eql(state);

0 commit comments

Comments
 (0)