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-23 11:50:45 -04:00
|
|
|
assertStringIncludes(s, "opcall_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
|
2021-05-18 11:24:01 -04:00
|
|
|
var core: any;
|
2021-03-18 09:10:27 -04:00
|
|
|
}
|
|
|
|
}
|
2021-04-08 12:04:02 -04:00
|
|
|
|
2021-08-05 07:08:58 -04:00
|
|
|
unitTest(async function opsAsyncBadResource() {
|
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-08-05 07:08:58 -04:00
|
|
|
unitTest(function opsSyncBadResource() {
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|