From c43cfedeba5d6ac96e1b1febed8549e750606e3f Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 26 Mar 2019 23:22:07 +1100 Subject: namespace reorg: libdeno and DenoCore to Deno.core (#1998) --- libdeno/libdeno_test.js | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'libdeno/libdeno_test.js') diff --git a/libdeno/libdeno_test.js b/libdeno/libdeno_test.js index 8b1ad2e04..b0040025d 100644 --- a/libdeno/libdeno_test.js +++ b/libdeno/libdeno_test.js @@ -10,7 +10,7 @@ function assert(cond) { } global.CanCallFunction = () => { - libdeno.print("Hello world from foo"); + Deno.core.print("Hello world from foo"); return "foo"; }; @@ -28,15 +28,15 @@ global.TypedArraySnapshots = () => { global.RecvReturnEmpty = () => { const m1 = new Uint8Array("abc".split("").map(c => c.charCodeAt(0))); const m2 = m1.slice(); - const r1 = libdeno.send(m1); + const r1 = Deno.core.send(m1); assert(r1 == null); - const r2 = libdeno.send(m2); + const r2 = Deno.core.send(m2); assert(r2 == null); }; global.RecvReturnBar = () => { const m = new Uint8Array("abc".split("").map(c => c.charCodeAt(0))); - const r = libdeno.send(m); + const r = Deno.core.send(m); assert(r instanceof Uint8Array); assert(r.byteLength === 3); const rstr = String.fromCharCode(...r); @@ -44,10 +44,10 @@ global.RecvReturnBar = () => { }; global.DoubleRecvFails = () => { - // libdeno.recv is an internal function and should only be called once from the + // Deno.core.recv is an internal function and should only be called once from the // runtime. - libdeno.recv((channel, msg) => assert(false)); - libdeno.recv((channel, msg) => assert(false)); + Deno.core.recv((channel, msg) => assert(false)); + Deno.core.recv((channel, msg) => assert(false)); }; global.SendRecvSlice = () => { @@ -58,7 +58,7 @@ global.SendRecvSlice = () => { buf[0] = 100 + i; buf[buf.length - 1] = 100 - i; // On the native side, the slice is shortened by 19 bytes. - buf = libdeno.send(buf); + buf = Deno.core.send(buf); assert(buf.byteOffset === i * 11); assert(buf.byteLength === abLen - i * 30 - 19); assert(buf.buffer.byteLength == abLen); @@ -78,17 +78,17 @@ global.JSSendArrayBufferViewTypes = () => { const ab1 = new ArrayBuffer(4321); const u8 = new Uint8Array(ab1, 2468, 1000); u8[0] = 1; - libdeno.send(u8); + Deno.core.send(u8); // Send Uint32Array. const ab2 = new ArrayBuffer(4321); const u32 = new Uint32Array(ab2, 2468, 1000 / Uint32Array.BYTES_PER_ELEMENT); u32[0] = 0x02020202; - libdeno.send(u32); + Deno.core.send(u32); // Send DataView. const ab3 = new ArrayBuffer(4321); const dv = new DataView(ab3, 2468, 1000); dv.setUint8(0, 3); - libdeno.send(dv); + Deno.core.send(dv); }; // The following join has caused SnapshotBug to segfault when using kKeep. @@ -110,7 +110,7 @@ global.ZeroCopyBuf = () => { const b = zeroCopyBuf; // The second parameter of send should modified by the // privileged side. - const r = libdeno.send(a, b); + const r = Deno.core.send(a, b); assert(r == null); // b is different. assert(b[0] === 4); @@ -129,15 +129,15 @@ global.CheckPromiseErrors = () => { try { await fn(); } catch (e) { - libdeno.send(new Uint8Array([42])); + Deno.core.send(new Uint8Array([42])); } })(); }; global.Shared = () => { - const ab = libdeno.shared; + const ab = Deno.core.shared; assert(ab instanceof SharedArrayBuffer); - assert(libdeno.shared != undefined); + assert(Deno.core.shared != undefined); assert(ab.byteLength === 3); const ui8 = new Uint8Array(ab); assert(ui8[0] === 0); @@ -149,45 +149,46 @@ global.Shared = () => { }; global.LibDenoEvalContext = () => { - const [result, errInfo] = libdeno.evalContext("let a = 1; a"); + const [result, errInfo] = Deno.core.evalContext("let a = 1; a"); assert(result === 1); assert(!errInfo); - const [result2, errInfo2] = libdeno.evalContext("a = a + 1; a"); + const [result2, errInfo2] = Deno.core.evalContext("a = a + 1; a"); assert(result2 === 2); assert(!errInfo2); }; global.LibDenoEvalContextError = () => { - const [result, errInfo] = libdeno.evalContext("not_a_variable"); + const [result, errInfo] = Deno.core.evalContext("not_a_variable"); assert(!result); assert(!!errInfo); assert(errInfo.isNativeError); // is a native error (ReferenceError) assert(!errInfo.isCompileError); // is NOT a compilation error assert(errInfo.thrown.message === "not_a_variable is not defined"); - const [result2, errInfo2] = libdeno.evalContext("throw 1"); + const [result2, errInfo2] = Deno.core.evalContext("throw 1"); assert(!result2); assert(!!errInfo2); assert(!errInfo2.isNativeError); // is NOT a native error assert(!errInfo2.isCompileError); // is NOT a compilation error assert(errInfo2.thrown === 1); - const [result3, errInfo3] = - libdeno.evalContext("class AError extends Error {}; throw new AError('e')"); + const [result3, errInfo3] = Deno.core.evalContext( + "class AError extends Error {}; throw new AError('e')" + ); assert(!result3); assert(!!errInfo3); assert(errInfo3.isNativeError); // extend from native error, still native error assert(!errInfo3.isCompileError); // is NOT a compilation error assert(errInfo3.thrown.message === "e"); - const [result4, errInfo4] = libdeno.evalContext("{"); + const [result4, errInfo4] = Deno.core.evalContext("{"); assert(!result4); assert(!!errInfo4); assert(errInfo4.isNativeError); // is a native error (SyntaxError) assert(errInfo4.isCompileError); // is a compilation error! (braces not closed) assert(errInfo4.thrown.message === "Unexpected end of input"); - const [result5, errInfo5] = libdeno.evalContext("eval('{')"); + const [result5, errInfo5] = Deno.core.evalContext("eval('{')"); assert(!result5); assert(!!errInfo5); assert(errInfo5.isNativeError); // is a native error (SyntaxError) -- cgit v1.2.3