add a test

This commit is contained in:
Jarred Sumner
2022-05-16 23:05:21 -07:00
parent 4f72021007
commit 07e695da03
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
export function whatDidIPass(expr, ctx) {
return ctx;
}

View File

@@ -132,6 +132,9 @@ describe("Bun.Transpiler", () => {
},
platform: "bun",
macro: {
inline: {
whatDidIPass: `${import.meta.dir}/inline.macro.js`,
},
react: {
bacon: `${import.meta.dir}/macro-check.js`,
},
@@ -618,6 +621,35 @@ describe("Bun.Transpiler", () => {
expectBunPrinted_("export const foo = 1 * 2", "export const foo = 2");
});
it("pass objects to macros", () => {
var object = {
helloooooooo: {
message: [12345],
},
};
const output = bunTranspiler.transformSync(
`
import {whatDidIPass} from 'inline';
export function foo() {
return whatDidIPass();
}
`,
object
);
expect(output).toBe(`export function foo() {
return {
helloooooooo: {
message: [
12345
]
}
};
}
`);
});
it("rewrite string to length", () => {
expectPrinted_(
`export const foo = "a".length + "b".length;`,