summaryrefslogtreecommitdiff
path: root/cli/tests/unit/error_stack_test.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-12-10 14:45:41 +0100
committerGitHub <noreply@github.com>2020-12-10 14:45:41 +0100
commitf91fa16661fa10fd029e6cf26008faee95233143 (patch)
tree3d45e2ebb3e93e0947ac382b944bf2600b9c36c4 /cli/tests/unit/error_stack_test.ts
parentb7faa27704458b4bbb0b43b15bcb16b13e7c3c4f (diff)
refactor(core): stack trace mapping (#8660)
This commit adds "Deno.core.createPrepareStackTrace". This function was moved from "cli/rt/40_error_stack.js" to unify handling of stack frames in core (before this PR there was implicit dependency on logic in "core/error.rs::JsError"). Unfortunately formatting logic must still be duplicated in "cli/error.js::PrettyJsError" to provide coloring, but currently there's no solution to this problem. "createPrepareStackTrace" can accept a single argument; a function that takes a location and provides source mapped location back.
Diffstat (limited to 'cli/tests/unit/error_stack_test.ts')
-rw-r--r--cli/tests/unit/error_stack_test.ts99
1 files changed, 0 insertions, 99 deletions
diff --git a/cli/tests/unit/error_stack_test.ts b/cli/tests/unit/error_stack_test.ts
index a5fe13796..ad5f2e093 100644
--- a/cli/tests/unit/error_stack_test.ts
+++ b/cli/tests/unit/error_stack_test.ts
@@ -1,87 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals, assertMatch, unitTest } from "./test_util.ts";
-// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
-const { setPrepareStackTrace } = Deno[Deno.internal];
-
-interface CallSite {
- getThis(): unknown;
- getTypeName(): string | null;
- // deno-lint-ignore ban-types
- getFunction(): Function | null;
- getFunctionName(): string | null;
- getMethodName(): string | null;
- getFileName(): string | null;
- getLineNumber(): number | null;
- getColumnNumber(): number | null;
- getEvalOrigin(): string | null;
- isToplevel(): boolean | null;
- isEval(): boolean;
- isNative(): boolean;
- isConstructor(): boolean;
- isAsync(): boolean;
- isPromiseAll(): boolean;
- getPromiseIndex(): number | null;
-}
-
-function getMockCallSite(
- fileName: string,
- lineNumber: number | null,
- columnNumber: number | null,
-): CallSite {
- return {
- getThis(): unknown {
- return undefined;
- },
- getTypeName(): string {
- return "";
- },
- // deno-lint-ignore ban-types
- getFunction(): Function {
- return (): void => {};
- },
- getFunctionName(): string {
- return "";
- },
- getMethodName(): string {
- return "";
- },
- getFileName(): string {
- return fileName;
- },
- getLineNumber(): number | null {
- return lineNumber;
- },
- getColumnNumber(): number | null {
- return columnNumber;
- },
- getEvalOrigin(): null {
- return null;
- },
- isToplevel(): false {
- return false;
- },
- isEval(): false {
- return false;
- },
- isNative(): false {
- return false;
- },
- isConstructor(): false {
- return false;
- },
- isAsync(): false {
- return false;
- },
- isPromiseAll(): false {
- return false;
- },
- getPromiseIndex(): null {
- return null;
- },
- };
-}
-
unitTest(function errorStackMessageLine(): void {
const e1 = new Error();
e1.name = "Foo";
@@ -122,24 +41,6 @@ unitTest(function errorStackMessageLine(): void {
assertMatch(e6.stack!, /^null: null\n/);
});
-// FIXME(bartlomieju): no longer works after migrating
-// to JavaScript runtime code
-unitTest({ ignore: true }, function prepareStackTrace(): void {
- // deno-lint-ignore no-explicit-any
- const MockError = {} as any;
- setPrepareStackTrace(MockError);
- assert(typeof MockError.prepareStackTrace === "function");
- const prepareStackTrace: (
- error: Error,
- structuredStackTrace: CallSite[],
- ) => string = MockError.prepareStackTrace;
- const result = prepareStackTrace(new Error("foo"), [
- getMockCallSite("CLI_SNAPSHOT.js", 23, 0),
- ]);
- assert(result.startsWith("Error: foo\n"));
- assert(result.includes(".ts:"), "should remap to something in 'js/'");
-});
-
unitTest(function captureStackTrace(): void {
function foo(): void {
const error = new Error();