summaryrefslogtreecommitdiff
path: root/deno2/js/mock_runtime.js
blob: cdb6031e317f6b53c185412838d76246d37670ec (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 recvabc() {
  deno_recv((msg) => {
    assert(msg instanceof ArrayBuffer);
    assert(msg.byteLength === 3);
  });
}