diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-03-06 20:48:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 20:48:46 -0500 |
commit | c42a9d737081fb8ee768c7178dae0e1f19c0f343 (patch) | |
tree | 9ffb7e502da62793ea099c34bd7b29c8a7a19b19 /js/net_test.ts | |
parent | de1a10e5f7afe793a66b2349642ea135fc066104 (diff) |
Upgrade deno_std (#1892)
A major API change was that asserts are imported from testing/asserts.ts
now rather than testing/mod.ts and assertEqual as renamed to
assertEquals to conform to what is most common in JavaScript.
Diffstat (limited to 'js/net_test.ts')
-rw-r--r-- | js/net_test.ts | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/js/net_test.ts b/js/net_test.ts index f20bb9ddb..5b8b80bea 100644 --- a/js/net_test.ts +++ b/js/net_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { testPerm, assert, assertEqual } from "./test_util.ts"; +import { testPerm, assert, assertEquals } from "./test_util.ts"; testPerm({ net: true }, function netListenClose() { const listener = Deno.listen("tcp", "127.0.0.1:4500"); @@ -17,17 +17,17 @@ testPerm({ net: true }, async function netCloseWhileAccept() { err = e; } assert(!!err); - assertEqual(err.kind, Deno.ErrorKind.Other); - assertEqual(err.message, "Listener has been closed"); + assertEquals(err.kind, Deno.ErrorKind.Other); + assertEquals(err.message, "Listener has been closed"); }); testPerm({ net: true }, async function netConcurrentAccept() { const listener = Deno.listen("tcp", ":4502"); let acceptErrCount = 0; const checkErr = e => { - assertEqual(e.kind, Deno.ErrorKind.Other); + assertEquals(e.kind, Deno.ErrorKind.Other); if (e.message === "Listener has been closed") { - assertEqual(acceptErrCount, 1); + assertEquals(acceptErrCount, 1); } else if (e.message === "Another accept task is ongoing") { acceptErrCount++; } else { @@ -39,7 +39,7 @@ testPerm({ net: true }, async function netConcurrentAccept() { await Promise.race([p, p1]); listener.close(); await [p, p1]; - assertEqual(acceptErrCount, 1); + assertEquals(acceptErrCount, 1); }); testPerm({ net: true }, async function netDialListen() { @@ -51,20 +51,20 @@ testPerm({ net: true }, async function netDialListen() { const conn = await Deno.dial("tcp", "127.0.0.1:4500"); const buf = new Uint8Array(1024); const readResult = await conn.read(buf); - assertEqual(3, readResult.nread); - assertEqual(1, buf[0]); - assertEqual(2, buf[1]); - assertEqual(3, buf[2]); + assertEquals(3, readResult.nread); + assertEquals(1, buf[0]); + assertEquals(2, buf[1]); + assertEquals(3, buf[2]); assert(conn.rid > 0); // TODO Currently ReadResult does not properly transmit EOF in the same call. // it requires a second call to get the EOF. Either ReadResult to be an // integer in which 0 signifies EOF or the handler should be modified so that // EOF is properly transmitted. - assertEqual(false, readResult.eof); + assertEquals(false, readResult.eof); const readResult2 = await conn.read(buf); - assertEqual(true, readResult2.eof); + assertEquals(true, readResult2.eof); listener.close(); conn.close(); @@ -81,10 +81,10 @@ testPerm({ net: true }, async function netCloseReadSuccess() { await conn.write(new Uint8Array([1, 2, 3])); const buf = new Uint8Array(1024); const readResult = await conn.read(buf); - assertEqual(3, readResult.nread); - assertEqual(4, buf[0]); - assertEqual(5, buf[1]); - assertEqual(6, buf[2]); + assertEquals(3, readResult.nread); + assertEquals(4, buf[0]); + assertEquals(5, buf[1]); + assertEquals(6, buf[2]); conn.close(); closeDeferred.resolve(); }); @@ -93,8 +93,8 @@ testPerm({ net: true }, async function netCloseReadSuccess() { closeReadDeferred.resolve(); const buf = new Uint8Array(1024); const readResult = await conn.read(buf); - assertEqual(0, readResult.nread); // No error, read nothing - assertEqual(true, readResult.eof); // with immediate EOF + assertEquals(0, readResult.nread); // No error, read nothing + assertEquals(true, readResult.eof); // with immediate EOF // Ensure closeRead does not impact write await conn.write(new Uint8Array([4, 5, 6])); await closeDeferred.promise; @@ -123,8 +123,8 @@ testPerm({ net: true }, async function netDoubleCloseRead() { err = e; } assert(!!err); - assertEqual(err.kind, Deno.ErrorKind.NotConnected); - assertEqual(err.name, "NotConnected"); + assertEquals(err.kind, Deno.ErrorKind.NotConnected); + assertEquals(err.name, "NotConnected"); closeDeferred.resolve(); listener.close(); conn.close(); @@ -146,10 +146,10 @@ testPerm({ net: true }, async function netCloseWriteSuccess() { const buf = new Uint8Array(1024); // Check read not impacted const readResult = await conn.read(buf); - assertEqual(3, readResult.nread); - assertEqual(1, buf[0]); - assertEqual(2, buf[1]); - assertEqual(3, buf[2]); + assertEquals(3, readResult.nread); + assertEquals(1, buf[0]); + assertEquals(2, buf[1]); + assertEquals(3, buf[2]); // Check write should be closed let err; try { @@ -158,8 +158,8 @@ testPerm({ net: true }, async function netCloseWriteSuccess() { err = e; } assert(!!err); - assertEqual(err.kind, Deno.ErrorKind.BrokenPipe); - assertEqual(err.name, "BrokenPipe"); + assertEquals(err.kind, Deno.ErrorKind.BrokenPipe); + assertEquals(err.name, "BrokenPipe"); closeDeferred.resolve(); listener.close(); conn.close(); @@ -185,8 +185,8 @@ testPerm({ net: true }, async function netDoubleCloseWrite() { err = e; } assert(!!err); - assertEqual(err.kind, Deno.ErrorKind.NotConnected); - assertEqual(err.name, "NotConnected"); + assertEquals(err.kind, Deno.ErrorKind.NotConnected); + assertEquals(err.name, "NotConnected"); closeDeferred.resolve(); listener.close(); conn.close(); |