summaryrefslogtreecommitdiff
path: root/cli/tests/unit/opcall_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/opcall_test.ts')
-rw-r--r--cli/tests/unit/opcall_test.ts33
1 files changed, 28 insertions, 5 deletions
diff --git a/cli/tests/unit/opcall_test.ts b/cli/tests/unit/opcall_test.ts
index 8985c9780..3b37f8c09 100644
--- a/cli/tests/unit/opcall_test.ts
+++ b/cli/tests/unit/opcall_test.ts
@@ -1,20 +1,18 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+import { assertEquals } from "https://deno.land/std@v0.42.0/testing/asserts.ts";
import { assert, assertStringIncludes, unreachable } from "./test_util.ts";
Deno.test(async function sendAsyncStackTrace() {
- const buf = new Uint8Array(10);
- const rid = 10;
try {
- await Deno.read(rid, buf);
+ await core.ops.op_error_async();
unreachable();
} catch (error) {
assert(error instanceof Error);
const s = error.stack?.toString();
assert(s);
- console.log(s);
assertStringIncludes(s, "opcall_test.ts");
- assertStringIncludes(s, "read");
+ assertStringIncludes(s, "sendAsyncStackTrace");
assert(
!s.includes("ext:core"),
"opcall stack traces should NOT include ext:core internals such as unwrapOpResult",
@@ -22,6 +20,31 @@ Deno.test(async function sendAsyncStackTrace() {
}
});
+Deno.test(async function sendAsyncStackTraceDeferred() {
+ try {
+ await core.ops.op_error_async_deferred();
+ unreachable();
+ } catch (error) {
+ assert(error instanceof Error);
+ const s = error.stack?.toString();
+ assert(s);
+ assertStringIncludes(s, "opcall_test.ts");
+ assertStringIncludes(s, "sendAsyncStackTraceDeferred");
+ assert(
+ !s.includes("ext:core"),
+ "opcall stack traces should NOT include ext:core internals such as unwrapOpResult",
+ );
+ }
+});
+
+Deno.test(function syncAdd() {
+ assertEquals(30, core.ops.op_add(10, 20));
+});
+
+Deno.test(async function asyncAdd() {
+ assertEquals(30, await core.ops.op_add_async(10, 20));
+});
+
// @ts-ignore This is not publicly typed namespace, but it's there for sure.
const core = Deno[Deno.internal].core;