blob: 61c3c884919330e1c3b7091c0b5e795aa34ccf0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
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);
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");
assert(
!s.includes("deno:core"),
"opcall stack traces should NOT include deno:core internals such as unwrapOpResult",
);
}
});
declare global {
namespace Deno {
// deno-lint-ignore no-explicit-any, no-var
var core: any;
}
}
Deno.test(async function opsAsyncBadResource() {
try {
const nonExistingRid = 9999;
await Deno.core.read(
nonExistingRid,
new Uint8Array(0),
);
} catch (e) {
if (!(e instanceof Deno.errors.BadResource)) {
throw e;
}
}
});
Deno.test(function opsSyncBadResource() {
try {
const nonExistingRid = 9999;
Deno.core.ops.op_read_sync(nonExistingRid, new Uint8Array(0));
} catch (e) {
if (!(e instanceof Deno.errors.BadResource)) {
throw e;
}
}
});
|