mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Another test for macros
This commit is contained in:
@@ -995,6 +995,14 @@ export var ComponentThatHasSpreadCausesDeopt = jsx(Hello, {
|
||||
});
|
||||
|
||||
it("macros can return a Response body", () => {
|
||||
// "promiseReturningCtx" is this:
|
||||
// export function promiseReturningCtx(expr, ctx) {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// setTimeout(() => {
|
||||
// resolve(ctx);
|
||||
// }, 1);
|
||||
// });
|
||||
// }
|
||||
var object = Response.json({ hello: "world" });
|
||||
|
||||
const input = `
|
||||
@@ -1014,6 +1022,34 @@ export function foo() {
|
||||
expect(bunTranspiler.transformSync(input, object).trim()).toBe(output);
|
||||
});
|
||||
|
||||
it("macros get dead code eliminated", () => {
|
||||
var object = Response.json({
|
||||
big: {
|
||||
object: {
|
||||
beep: "boop",
|
||||
huge: 123,
|
||||
},
|
||||
blobby: {
|
||||
beep: "boop",
|
||||
huge: 123,
|
||||
},
|
||||
},
|
||||
dead: "hello world!",
|
||||
});
|
||||
|
||||
const input = `
|
||||
import {promiseReturningCtx} from 'inline';
|
||||
|
||||
export const {dead} = promiseReturningCtx();
|
||||
`.trim();
|
||||
|
||||
const output = `
|
||||
export const { dead } = { dead: "hello world!" };
|
||||
`.trim();
|
||||
|
||||
expect(bunTranspiler.transformSync(input, object).trim()).toBe(output);
|
||||
});
|
||||
|
||||
it("rewrite string to length", () => {
|
||||
expectPrinted_(
|
||||
`export const foo = "a".length + "b".length;`,
|
||||
|
||||
Reference in New Issue
Block a user