aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-05-16 23:05:21 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-05-16 23:05:21 -0700
commit07e695da031ae9638684e6f1bd2e4e29ca14d098 (patch)
tree6b570e6a3297a9899de235c2a7daa998c154725e /integration/bunjs-only-snippets
parent4f720210073a9377001f07f9a07696040504514a (diff)
downloadbun-07e695da031ae9638684e6f1bd2e4e29ca14d098.tar.gz
bun-07e695da031ae9638684e6f1bd2e4e29ca14d098.tar.zst
bun-07e695da031ae9638684e6f1bd2e4e29ca14d098.zip
add a test
Diffstat (limited to 'integration/bunjs-only-snippets')
-rw-r--r--integration/bunjs-only-snippets/inline.macro.js3
-rw-r--r--integration/bunjs-only-snippets/transpiler.test.js32
2 files changed, 35 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/inline.macro.js b/integration/bunjs-only-snippets/inline.macro.js
new file mode 100644
index 000000000..ff0292d0a
--- /dev/null
+++ b/integration/bunjs-only-snippets/inline.macro.js
@@ -0,0 +1,3 @@
+export function whatDidIPass(expr, ctx) {
+ return ctx;
+}
diff --git a/integration/bunjs-only-snippets/transpiler.test.js b/integration/bunjs-only-snippets/transpiler.test.js
index 61024e400..dd0ffdc8f 100644
--- a/integration/bunjs-only-snippets/transpiler.test.js
+++ b/integration/bunjs-only-snippets/transpiler.test.js
@@ -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;`,