attach auxiliary comment to function declaration helpers - fixes #1476

This commit is contained in:
Sebastian McKenzie 2015-05-07 20:11:02 +01:00
parent 8a4a76000d
commit c3a08d413f
2 changed files with 11 additions and 0 deletions

View File

@ -337,6 +337,7 @@ export default class File {
ref._generated = true; ref._generated = true;
ref.id = uid; ref.id = uid;
ref.type = "FunctionDeclaration"; ref.type = "FunctionDeclaration";
this.attachAuxiliaryComment(ref);
this.path.unshiftContainer("body", ref); this.path.unshiftContainer("body", ref);
} else { } else {
ref._compact = true; ref._compact = true;

View File

@ -18,6 +18,16 @@ suite("api", function () {
assert.ok(!result.ast); assert.ok(!result.ast);
}); });
test("{ auxiliaryComment }", function () {
assert.ok(transform("class Foo {}", {
auxiliaryComment: "foobar"
}).code.indexOf("foobar") >= 0);
assert.ok(transform("for (let i in bar) { foo(function () { i; }); break; continue; }", {
auxiliaryComment: "foobar"
}).code.indexOf("foobar") >= 0);
});
suite("getModuleId() {} option", function () { suite("getModuleId() {} option", function () {
// As of this commit, `getModuleId` is the only option that isn't JSON // As of this commit, `getModuleId` is the only option that isn't JSON
// compatible which is why it's not inside /test/core/fixtures/transformation // compatible which is why it's not inside /test/core/fixtures/transformation