fix attachComment typo, add comment tests

This commit is contained in:
Henry Zhu 2015-09-14 14:26:21 -04:00
parent 742b1cb65d
commit c0a7ebf51b

View File

@ -63,7 +63,7 @@ function parseAndAssertSame(code) {
loc: true, loc: true,
range: true, range: true,
comment: true, comment: true,
attachComments: true attachComment: true
}); });
var acornAST = babelEslint.parse(code); var acornAST = babelEslint.parse(code);
try { try {
@ -302,4 +302,29 @@ describe("acorn-to-esprima", function () {
it("empty", function () { it("empty", function () {
parseAndAssertSame(""); parseAndAssertSame("");
}); });
it("jsdoc", function () {
parseAndAssertSame([
"/**",
"* @param {object} options",
"* @return {number}",
"*/",
"const test = function({ a, b, c }) {",
"return a + b + c;",
"};",
"module.exports = test;"
].join("\n"));
})
it("empty block with comment", function () {
parseAndAssertSame([
"function a () {",
"try {",
"b();",
"} catch (e) {",
"// asdf",
"}",
"}"
].join("\n"));
})
}); });