2020-09-27 06:22:32 -04:00
|
|
|
import { assertMatch, assertStrictEquals, unitTest } from "./test_util.ts";
|
2019-08-27 16:33:39 +01:00
|
|
|
|
2020-06-02 14:24:44 +10:00
|
|
|
declare global {
|
2020-11-03 16:19:29 +01:00
|
|
|
// deno-lint-ignore no-namespace
|
2020-06-02 14:24:44 +10:00
|
|
|
namespace Deno {
|
2020-11-03 16:19:29 +01:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-19 02:05:37 -07:00
|
|
|
var core: any; // eslint-disable-line no-var
|
2020-06-02 14:24:44 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-20 14:38:34 +01:00
|
|
|
unitTest(function malformedJsonControlBuffer(): void {
|
2020-08-18 14:07:57 +02: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 18:20:22 +02:00
|
|
|
assertStrictEquals(resObj.err.className, "SyntaxError");
|
2020-08-18 14:07:57 +02: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 14:07:57 +02:00
|
|
|
const resText = new TextDecoder().decode(resBuf);
|
|
|
|
const resObj = JSON.parse(resText);
|
|
|
|
console.error(resText);
|
|
|
|
assertStrictEquals(resObj.ok, undefined);
|
2020-08-26 18:20:22 +02:00
|
|
|
assertStrictEquals(resObj.err.className, "TypeError");
|
2020-08-18 14:07:57 +02:00
|
|
|
assertMatch(resObj.err.message, /\bpromiseId\b/);
|
2019-10-25 19:23:16 +02:00
|
|
|
});
|