2020-09-27 06:22:32 -04:00
|
|
|
import { assertMatch, assertStrictEquals, unitTest } from "./test_util.ts";
|
2019-08-27 11:33:39 -04:00
|
|
|
|
2020-06-02 00:24:44 -04:00
|
|
|
declare global {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-namespace
|
2020-06-02 00:24:44 -04:00
|
|
|
namespace Deno {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-19 05:05:37 -04:00
|
|
|
var core: any; // eslint-disable-line no-var
|
2020-06-02 00:24:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-20 09:38:34 -04:00
|
|
|
unitTest(function malformedJsonControlBuffer(): void {
|
2020-08-18 08:07:57 -04:00
|
|
|
const opId = Deno.core.ops()["op_open_sync"];
|
|
|
|
const argsBuf = new Uint8Array([1, 2, 3, 4, 5]);
|
|
|
|
const resBuf = Deno.core.send(opId, argsBuf);
|
|
|
|
const resText = new TextDecoder().decode(resBuf);
|
|
|
|
const resObj = JSON.parse(resText);
|
|
|
|
assertStrictEquals(resObj.ok, undefined);
|
2020-08-26 12:20:22 -04:00
|
|
|
assertStrictEquals(resObj.err.className, "SyntaxError");
|
2020-08-18 08:07:57 -04:00
|
|
|
assertMatch(resObj.err.message, /\bexpected value\b/);
|
|
|
|
});
|
|
|
|
|
|
|
|
unitTest(function invalidPromiseId(): void {
|
|
|
|
const opId = Deno.core.ops()["op_open_async"];
|
2021-02-13 11:56:56 -05:00
|
|
|
const reqBuf = new Uint8Array([0, 0, 0, 0, 0, 0, 0]);
|
|
|
|
const resBuf = Deno.core.send(opId, reqBuf);
|
2020-08-18 08:07:57 -04:00
|
|
|
const resText = new TextDecoder().decode(resBuf);
|
|
|
|
const resObj = JSON.parse(resText);
|
|
|
|
console.error(resText);
|
|
|
|
assertStrictEquals(resObj.ok, undefined);
|
2020-08-26 12:20:22 -04:00
|
|
|
assertStrictEquals(resObj.err.className, "TypeError");
|
2020-08-18 08:07:57 -04:00
|
|
|
assertMatch(resObj.err.message, /\bpromiseId\b/);
|
2019-10-25 13:23:16 -04:00
|
|
|
});
|