summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2018-09-24 15:42:09 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-09-24 15:42:09 -0400
commitbe8f49b33263238f17d8cbb334a36db6385fced2 (patch)
tree2dc1e1294aa6ec22ce9fe0f47e235ec4c2bffd4b
parent3fe4be07ca19b40a2444b714f5927ff155d66fed (diff)
Add `toString` for CallSite of eval origin (#809)
-rw-r--r--js/unit_tests.ts2
-rw-r--r--js/v8_source_maps.ts1
-rw-r--r--js/v8_source_maps_test.ts17
3 files changed, 19 insertions, 1 deletions
diff --git a/js/unit_tests.ts b/js/unit_tests.ts
index 103e89d89..ae9db2a28 100644
--- a/js/unit_tests.ts
+++ b/js/unit_tests.ts
@@ -17,5 +17,5 @@ import "./symlink_test.ts";
import "./platform_test.ts";
import "./text_encoding_test.ts";
import "./trace_test.ts";
-
+import "./v8_source_maps_test.ts";
import "../website/app_test.js";
diff --git a/js/v8_source_maps.ts b/js/v8_source_maps.ts
index 1852a8982..bb7424f0b 100644
--- a/js/v8_source_maps.ts
+++ b/js/v8_source_maps.ts
@@ -88,6 +88,7 @@ export function wrapCallSite(frame: CallSite): CallSite {
origin = mapEvalOrigin(origin);
frame = cloneCallSite(frame);
frame.getEvalOrigin = () => origin;
+ frame.toString = () => CallSiteToString(frame);
return frame;
}
diff --git a/js/v8_source_maps_test.ts b/js/v8_source_maps_test.ts
new file mode 100644
index 000000000..90c123431
--- /dev/null
+++ b/js/v8_source_maps_test.ts
@@ -0,0 +1,17 @@
+// Copyright 2018 the Deno authors. All rights reserved. MIT license.
+import { test, assert, assertEqual } from "./test_util.ts";
+
+// This test demonstrates a bug:
+// https://github.com/denoland/deno/issues/808
+test(function evalErrorFormatted() {
+ let err;
+ try {
+ eval("boom");
+ } catch (e) {
+ err = e;
+ }
+ assert(!!err);
+ // tslint:disable-next-line:no-unused-expression
+ err.stack; // This would crash if err.stack is malformed
+ assertEqual(err.name, "ReferenceError");
+});