mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
### What does this PR do? Fixes accessing the wrong union field. Resolves BUN-WQF ### How did you verify your code works? Added a regression test --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
22 lines
613 B
TypeScript
22 lines
613 B
TypeScript
import { build, file } from "bun";
|
|
import { expect, test } from "bun:test";
|
|
import { tempDir } from "harness";
|
|
import { join } from "path";
|
|
|
|
test("minifying new Array(if (0) 1 else 2) works", async () => {
|
|
using testDir = tempDir("minify-new-array-with-if", {
|
|
"entry.js": "console.log(new Array(Math.random() > -1 ? 1 : 2));",
|
|
});
|
|
|
|
await build({
|
|
entrypoints: [join(testDir, "entry.js")],
|
|
minify: true,
|
|
outdir: join(testDir, "outdir"),
|
|
});
|
|
|
|
expect(await file(join(testDir, "outdir/entry.js")).text()).toMatchInlineSnapshot(`
|
|
"console.log(Array(Math.random()>-1?1:2));
|
|
"
|
|
`);
|
|
});
|