mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
add a test
This commit is contained in:
3
integration/bunjs-only-snippets/inline.macro.js
Normal file
3
integration/bunjs-only-snippets/inline.macro.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export function whatDidIPass(expr, ctx) {
|
||||
return ctx;
|
||||
}
|
||||
@@ -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;`,
|
||||
|
||||
Reference in New Issue
Block a user