aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-debug-adapter-protocol/debugger/sourcemap.test.ts
diff options
context:
space:
mode:
authorGravatar Ashcon Partovi <ashcon@partovi.net> 2023-08-26 02:34:25 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-26 02:34:25 -0700
commit2a9e967fd1c766a718808d5a7fa779d74d44e62c (patch)
tree3bf4c059c03b9b561bc565ecf7cf21eaceae5353 /packages/bun-debug-adapter-protocol/debugger/sourcemap.test.ts
parent910daeff27ead119e15f35f6c1e0aa09d2aa7562 (diff)
downloadbun-2a9e967fd1c766a718808d5a7fa779d74d44e62c.tar.gz
bun-2a9e967fd1c766a718808d5a7fa779d74d44e62c.tar.zst
bun-2a9e967fd1c766a718808d5a7fa779d74d44e62c.zip
More improvements to debugger support (#4345)
* More fixes for dap * More changes * More changes 2 * More fixes * Fix debugger.ts * Bun Terminal
Diffstat (limited to 'packages/bun-debug-adapter-protocol/debugger/sourcemap.test.ts')
-rw-r--r--packages/bun-debug-adapter-protocol/debugger/sourcemap.test.ts31
1 files changed, 0 insertions, 31 deletions
diff --git a/packages/bun-debug-adapter-protocol/debugger/sourcemap.test.ts b/packages/bun-debug-adapter-protocol/debugger/sourcemap.test.ts
deleted file mode 100644
index 44d9ca362..000000000
--- a/packages/bun-debug-adapter-protocol/debugger/sourcemap.test.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { test, expect } from "bun:test";
-import { readFileSync } from "node:fs";
-import { SourceMap } from "./sourcemap";
-
-test("works without source map", () => {
- const sourceMap = getSourceMap("without-sourcemap.js");
- expect(sourceMap.generatedLocation({ line: 7 })).toEqual({ line: 7, column: 0, verified: true });
- expect(sourceMap.generatedLocation({ line: 7, column: 2 })).toEqual({ line: 7, column: 2, verified: true });
- expect(sourceMap.originalLocation({ line: 11 })).toEqual({ line: 11, column: 0, verified: true });
- expect(sourceMap.originalLocation({ line: 11, column: 2 })).toEqual({ line: 11, column: 2, verified: true });
-});
-
-test("works with source map", () => {
- const sourceMap = getSourceMap("with-sourcemap.js");
- // FIXME: Columns don't appear to be accurate for `generatedLocation`
- expect(sourceMap.generatedLocation({ line: 3 })).toMatchObject({ line: 4, verified: true });
- expect(sourceMap.generatedLocation({ line: 27 })).toMatchObject({ line: 20, verified: true });
- expect(sourceMap.originalLocation({ line: 32 })).toEqual({ line: 43, column: 4, verified: true });
- expect(sourceMap.originalLocation({ line: 13 })).toEqual({ line: 13, column: 6, verified: true });
-});
-
-function getSourceMap(filename: string): SourceMap {
- const { pathname } = new URL(`./fixtures/${filename}`, import.meta.url);
- const source = readFileSync(pathname, "utf-8");
- const match = source.match(/\/\/# sourceMappingURL=(.*)$/m);
- if (match) {
- const [, url] = match;
- return SourceMap(url);
- }
- return SourceMap();
-}