diff --git a/test/regression/issue/sourcemap-lessThan-fix.test.ts b/test/regression/issue/sourcemap-lessThan-fix.test.ts index 0509023ea8..0de3f86499 100644 --- a/test/regression/issue/sourcemap-lessThan-fix.test.ts +++ b/test/regression/issue/sourcemap-lessThan-fix.test.ts @@ -1,10 +1,5 @@ -import { test, expect } from "bun:test"; -import { - bunEnv, - bunExe, - normalizeBunSnapshot, - tempDirWithFiles, -} from "harness"; +import { expect, test } from "bun:test"; +import { bunEnv, bunExe, normalizeBunSnapshot, tempDirWithFiles } from "harness"; test("sourcemap lessThan fix - should handle duplicate positions correctly", async () => { // Test that the fixed lessThan function handles duplicate line/column positions @@ -24,14 +19,17 @@ try { test2(); } catch(e) { console.error(e.message); } sources: ["duplicate-positions.ts"], names: ["test1", "test2", "console", "log", "Error"], // Mappings that could create duplicate positions during sorting - mappings: "AAAA;AACA,SAASA,MAAM;AACb,UAAQC,QAAQ,GAAG,OAAO;AAC1B,QAAM,IAAI,MAAM,QAAQ;AAC1B;AACA,SAASD,MAAM;AACb,UAAQC,QAAQ,GAAG,OAAO;AAC1B,QAAM,IAAI,MAAM,QAAQ;AAC1B;AAEA;AACA,IAAI;AAAE,QAAM;AAAE,EAAE,OAAO,GAAG;AAAE,UAAQC,QAAQ,EAAE,OAAO;AAAE;AACvD,IAAI;AAAE,QAAM;AAAE,EAAE,OAAO,GAAG;AAAE,UAAQA,QAAQ,EAAE,OAAO;AAAE", - sourcesContent: [` + mappings: + "AAAA;AACA,SAASA,MAAM;AACb,UAAQC,QAAQ,GAAG,OAAO;AAC1B,QAAM,IAAI,MAAM,QAAQ;AAC1B;AACA,SAASD,MAAM;AACb,UAAQC,QAAQ,GAAG,OAAO;AAC1B,QAAM,IAAI,MAAM,QAAQ;AAC1B;AAEA;AACA,IAAI;AAAE,QAAM;AAAE,EAAE,OAAO,GAAG;AAAE,UAAQC,QAAQ,EAAE,OAAO;AAAE;AACvD,IAAI;AAAE,QAAM;AAAE,EAAE,OAAO,GAAG;AAAE,UAAQA,QAAQ,EAAE,OAAO;AAAE", + sourcesContent: [ + ` function test1() { console.log("test1"); throw new Error("error1"); } function test2() { console.log("test2"); throw new Error("error2"); } try { test1(); } catch(e) { console.error(e.message); } try { test2(); } catch(e) { console.error(e.message); } -`] +`, + ], }), }); @@ -43,11 +41,7 @@ try { test2(); } catch(e) { console.error(e.message); } stdout: "pipe", }); - const [stdout, stderr, exitCode] = await Promise.all([ - proc.stdout.text(), - proc.stderr.text(), - proc.exited, - ]); + const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); expect(normalizeBunSnapshot(stdout, dir)).toMatchInlineSnapshot(` "test1 @@ -72,14 +66,17 @@ for (let i = 0; i < 10; i++) { version: 3, sources: ["stable-sort.ts"], names: ["i", "Error"], - mappings: "AAAA;AACA,KAAK,IAAIA,IAAI,GAAGA,IAAI,IAAIA,KAAK;AAC3B,MAAIA,MAAM,GAAG;AACX,UAAM,IAAI,MAAM,wBAAwBA,CAAC;AAC3C;AACF", - sourcesContent: [` + mappings: + "AAAA;AACA,KAAK,IAAIA,IAAI,GAAGA,IAAI,IAAIA,KAAK;AAC3B,MAAIA,MAAM,GAAG;AACX,UAAM,IAAI,MAAM,wBAAwBA,CAAC;AAC3C;AACF", + sourcesContent: [ + ` for (let i = 0; i < 10; i++) { if (i === 5) { throw new Error("error at iteration " + i); } } -`] +`, + ], }), }); @@ -91,11 +88,7 @@ for (let i = 0; i < 10; i++) { stdout: "pipe", }); - const [stdout, stderr, exitCode] = await Promise.all([ - proc.stdout.text(), - proc.stderr.text(), - proc.exited, - ]); + const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); expect(normalizeBunSnapshot(stderr, dir)).toMatchInlineSnapshot(` "1 | @@ -115,4 +108,4 @@ Bun v+29068c211 (Linux arm64)" `); expect(exitCode).toBe(1); -}); \ No newline at end of file +});