From 314f08672157a0977d7c3eeb72010eb0f717d889 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 11 Jun 2018 21:30:58 +0200 Subject: Better function names in mock_runtime.js --- deno2/js/mock_runtime.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'deno2/js') diff --git a/deno2/js/mock_runtime.js b/deno2/js/mock_runtime.js index 97688a08d..538174f79 100644 --- a/deno2/js/mock_runtime.js +++ b/deno2/js/mock_runtime.js @@ -1,27 +1,34 @@ // A simple runtime that doesn't involve typescript or protobufs to test -// libdeno. +// libdeno. Invoked by mock_runtime_test.cc 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() { +function typedArrayToArrayBuffer(ta) { + return ta.buffer.slice(ta.byteOffset, ta.byteOffset + ta.byteLength); +} + +function CanCallFunction() { + deno_print("Hello world from foo"); + return "foo"; +} + +function PubSuccess() { deno_sub(msg => { - assert(msg instanceof ArrayBuffer); - assert(msg.byteLength === 3); + deno_print("PubSuccess: ok"); }); } -function typedArrayToArrayBuffer(ta) { - return ta.buffer.slice(ta.byteOffset, ta.byteOffset + ta.byteLength); +function PubByteLength() { + deno_sub(msg => { + assert(msg instanceof ArrayBuffer); + assert(msg.byteLength === 3); + }); } -function pubReturnEmpty() { +function SubReturnEmpty() { const ui8 = new Uint8Array("abc".split("").map(c => c.charCodeAt(0))); const ab = typedArrayToArrayBuffer(ui8); let r = deno_pub(ab); @@ -30,7 +37,7 @@ function pubReturnEmpty() { assert(r == null); } -function pubReturnBar() { +function SubReturnBar() { const ui8 = new Uint8Array("abc".split("").map(c => c.charCodeAt(0))); const ab = typedArrayToArrayBuffer(ui8); const r = deno_pub(ab); -- cgit v1.2.3