summaryrefslogtreecommitdiff
path: root/deno2/js/mock_runtime.js
blob: b3ec7f03487206c750271f36f7e267c8c1d116b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// A simple runtime that doesn't involve typescript or protobufs to test
// libdeno.
const window = eval("this");
window['foo'] = () => {
  deno_print("Hello world from foo");
  return "foo";
}

function assert(cond) {
  if (!cond) throw Error("mock_runtime.js assert failed");
}

function subabc() {
  deno_sub((msg) => {
    assert(msg instanceof ArrayBuffer);
    assert(msg.byteLength === 3);
  });
}