Skip to content

Commit f204e05

Browse files
committed
increase test coverage on ast helper
1 parent d9fd8b9 commit f204e05

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/ast.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,6 @@ AST.prototype.prepare = function(kind, docs, parser) {
356356
let location = null;
357357
const args = Array.prototype.slice.call(arguments);
358358
args.push(docs);
359-
if (typeof result.preBuild === "function") {
360-
result.preBuild(arguments);
361-
}
362359
if (self.withPositions || self.withSource) {
363360
let src = null;
364361
if (self.withSource) {

test/ast.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const parser = require("./main");
2+
3+
describe("Test AST class (edge cases)", function() {
4+
it("test source without location", function() {
5+
const test = parser.create({
6+
ast: {
7+
withPositions: false,
8+
withSource: true
9+
}
10+
});
11+
const ast = test.parseEval('echo $foo;');
12+
const echo = ast.children[0];
13+
expect(echo.loc.source).toBe("echo $foo;");
14+
expect(echo.loc.start).toBeNull();
15+
expect(echo.loc.end).toBeNull();
16+
17+
const variable = echo.expressions[0];
18+
expect(variable.loc.source).toBe("$foo");
19+
});
20+
it("test undefined node", function() {
21+
const test = parser.create();
22+
expect(() => {
23+
const node = test.parser.node('foo');
24+
node();
25+
}).toThrow(/foo/);
26+
});
27+
});

0 commit comments

Comments
 (0)