2021-04-09 11:55:33 -04:00
|
|
|
import { assertStringIncludes, unitTest, unreachable } from "./test_util.ts";
|
2021-03-18 09:10:27 -04:00
|
|
|
|
2021-04-09 11:55:33 -04:00
|
|
|
unitTest(async function sendAsyncStackTrace() {
|
2021-03-18 09:10:27 -04:00
|
|
|
const buf = new Uint8Array(10);
|
|
|
|
const rid = 10;
|
|
|
|
try {
|
|
|
|
await Deno.read(rid, buf);
|
|
|
|
unreachable();
|
|
|
|
} catch (error) {
|
2021-04-09 11:55:33 -04:00
|
|
|
const s = error.stack.toString();
|
|
|
|
console.log(s);
|
2021-04-12 15:55:05 -04:00
|
|
|
assertStringIncludes(s, "dispatch_test.ts");
|
2021-04-09 11:55:33 -04:00
|
|
|
assertStringIncludes(s, "read");
|
2021-03-18 09:10:27 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
namespace Deno {
|
|
|
|
// deno-lint-ignore no-explicit-any
|
|
|
|
var core: any; // eslint-disable-line no-var
|
|
|
|
}
|
|
|
|
}
|
2021-04-08 12:04:02 -04:00
|
|
|
|
2021-04-12 15:55:05 -04:00
|
|
|
unitTest(async function opsAsyncBadResource(): Promise<void> {
|
2021-04-08 12:04:02 -04:00
|
|
|
try {
|
|
|
|
const nonExistingRid = 9999;
|
2021-04-12 15:55:05 -04:00
|
|
|
await Deno.core.opAsync(
|
2021-04-08 12:04:02 -04:00
|
|
|
"op_read_async",
|
|
|
|
nonExistingRid,
|
|
|
|
new Uint8Array(0),
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
if (!(e instanceof Deno.errors.BadResource)) {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-04-12 15:55:05 -04:00
|
|
|
unitTest(function opsSyncBadResource(): void {
|
2021-04-08 12:04:02 -04:00
|
|
|
try {
|
|
|
|
const nonExistingRid = 9999;
|
2021-04-12 15:55:05 -04:00
|
|
|
Deno.core.opSync("op_read_sync", nonExistingRid, new Uint8Array(0));
|
2021-04-08 12:04:02 -04:00
|
|
|
} catch (e) {
|
|
|
|
if (!(e instanceof Deno.errors.BadResource)) {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|