diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-23 17:50:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-23 11:50:45 -0400 |
commit | dd156e886b0d0f7d67538539bf7f3624b817d80a (patch) | |
tree | 01022d4993b8590fc7ab78ca9a2e6efe35974fd3 /cli/tests/unit/opcall_test.ts | |
parent | 8074d8bcf3cdcc7e9a08df147e0082798a7c2760 (diff) |
refactor(core): rename send() to opcall() (#10307)
I think it's a better fit since recv() was killed and opcall <> syscall (send/recv
was too reminiscent of request/response and custom payloads)
Diffstat (limited to 'cli/tests/unit/opcall_test.ts')
-rw-r--r-- | cli/tests/unit/opcall_test.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/cli/tests/unit/opcall_test.ts b/cli/tests/unit/opcall_test.ts new file mode 100644 index 000000000..6bade6545 --- /dev/null +++ b/cli/tests/unit/opcall_test.ts @@ -0,0 +1,48 @@ +import { assertStringIncludes, unitTest, unreachable } from "./test_util.ts"; + +unitTest(async function sendAsyncStackTrace() { + const buf = new Uint8Array(10); + const rid = 10; + try { + await Deno.read(rid, buf); + unreachable(); + } catch (error) { + const s = error.stack.toString(); + console.log(s); + assertStringIncludes(s, "opcall_test.ts"); + assertStringIncludes(s, "read"); + } +}); + +declare global { + namespace Deno { + // deno-lint-ignore no-explicit-any + var core: any; // eslint-disable-line no-var + } +} + +unitTest(async function opsAsyncBadResource(): Promise<void> { + try { + const nonExistingRid = 9999; + await Deno.core.opAsync( + "op_read_async", + nonExistingRid, + new Uint8Array(0), + ); + } catch (e) { + if (!(e instanceof Deno.errors.BadResource)) { + throw e; + } + } +}); + +unitTest(function opsSyncBadResource(): void { + try { + const nonExistingRid = 9999; + Deno.core.opSync("op_read_sync", nonExistingRid, new Uint8Array(0)); + } catch (e) { + if (!(e instanceof Deno.errors.BadResource)) { + throw e; + } + } +}); |