summaryrefslogtreecommitdiff
path: root/io
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-03-06 19:42:24 -0500
committerGitHub <noreply@github.com>2019-03-06 19:42:24 -0500
commitcaa383a5835c167bf6657120ad3c1c5009670785 (patch)
tree2f350928e23e472278b9c3ebd798f13169b6d581 /io
parente36edfdb3fd4709358a5f499f13cfe3d53c2b4f7 (diff)
Rename assertEq to assertEquals (denoland/deno_std#242)
After some discussion it was found that assertEquals is more common in JS (vs assertEqual, assertEq) and sounds better in the negated form: assertNotEquals vs assertNE. Original: https://github.com/denoland/deno_std/commit/4cf39d4a1420b8153cd78d03d03ef843607ae506
Diffstat (limited to 'io')
-rw-r--r--io/bufio_test.ts62
-rw-r--r--io/ioutil_test.ts22
-rw-r--r--io/readers_test.ts24
-rw-r--r--io/util_test.ts12
-rw-r--r--io/writers_test.ts6
5 files changed, 63 insertions, 63 deletions
diff --git a/io/bufio_test.ts b/io/bufio_test.ts
index e291ebfec..aed58d9ed 100644
--- a/io/bufio_test.ts
+++ b/io/bufio_test.ts
@@ -6,7 +6,7 @@
const { Buffer } = Deno;
import { Reader, ReadResult } from "deno";
import { test } from "../testing/mod.ts";
-import { assert, assertEq } from "../testing/asserts.ts";
+import { assert, assertEquals } from "../testing/asserts.ts";
import { BufReader, BufWriter } from "./bufio.ts";
import * as iotest from "./iotest.ts";
import { charCode, copyBytes, stringsReader } from "./util.ts";
@@ -32,7 +32,7 @@ test(async function bufioReaderSimple() {
const data = "hello world";
const b = new BufReader(stringsReader(data));
const s = await readBytes(b);
- assertEq(s, data);
+ assertEquals(s, data);
});
interface ReadMaker {
@@ -114,7 +114,7 @@ test(async function bufioBufReader() {
const debugStr =
`reader=${readmaker.name} ` +
`fn=${bufreader.name} bufsize=${bufsize} want=${text} got=${s}`;
- assertEq(s, text, debugStr);
+ assertEquals(s, text, debugStr);
}
}
}
@@ -129,12 +129,12 @@ test(async function bufioBufferFull() {
const decoder = new TextDecoder();
let actual = decoder.decode(line);
- assertEq(err, "BufferFull");
- assertEq(actual, "And now, hello, ");
+ assertEquals(err, "BufferFull");
+ assertEquals(actual, "And now, hello, ");
[line, err] = await buf.readSlice(charCode("!"));
actual = decoder.decode(line);
- assertEq(actual, "world!");
+ assertEquals(actual, "world!");
assert(err == null);
});
@@ -178,20 +178,20 @@ async function testReadLine(input: Uint8Array): Promise<void> {
if (line.byteLength > 0 && err != null) {
throw Error("readLine returned both data and error");
}
- assertEq(isPrefix, false);
+ assertEquals(isPrefix, false);
if (err == "EOF") {
break;
}
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
let want = testOutput.subarray(done, done + line.byteLength);
- assertEq(
+ assertEquals(
line,
want,
`Bad line at stride ${stride}: want: ${want} got: ${line}`
);
done += line.byteLength;
}
- assertEq(
+ assertEquals(
done,
testOutput.byteLength,
`readLine didn't return everything: got: ${done}, ` +
@@ -215,54 +215,54 @@ test(async function bufioPeek() {
);
let [actual, err] = await buf.peek(1);
- assertEq(decoder.decode(actual), "a");
+ assertEquals(decoder.decode(actual), "a");
assert(err == null);
[actual, err] = await buf.peek(4);
- assertEq(decoder.decode(actual), "abcd");
+ assertEquals(decoder.decode(actual), "abcd");
assert(err == null);
[actual, err] = await buf.peek(32);
- assertEq(decoder.decode(actual), "abcdefghijklmnop");
- assertEq(err, "BufferFull");
+ assertEquals(decoder.decode(actual), "abcdefghijklmnop");
+ assertEquals(err, "BufferFull");
await buf.read(p.subarray(0, 3));
- assertEq(decoder.decode(p.subarray(0, 3)), "abc");
+ assertEquals(decoder.decode(p.subarray(0, 3)), "abc");
[actual, err] = await buf.peek(1);
- assertEq(decoder.decode(actual), "d");
+ assertEquals(decoder.decode(actual), "d");
assert(err == null);
[actual, err] = await buf.peek(1);
- assertEq(decoder.decode(actual), "d");
+ assertEquals(decoder.decode(actual), "d");
assert(err == null);
[actual, err] = await buf.peek(1);
- assertEq(decoder.decode(actual), "d");
+ assertEquals(decoder.decode(actual), "d");
assert(err == null);
[actual, err] = await buf.peek(2);
- assertEq(decoder.decode(actual), "de");
+ assertEquals(decoder.decode(actual), "de");
assert(err == null);
let { eof } = await buf.read(p.subarray(0, 3));
- assertEq(decoder.decode(p.subarray(0, 3)), "def");
+ assertEquals(decoder.decode(p.subarray(0, 3)), "def");
assert(!eof);
assert(err == null);
[actual, err] = await buf.peek(4);
- assertEq(decoder.decode(actual), "ghij");
+ assertEquals(decoder.decode(actual), "ghij");
assert(err == null);
await buf.read(p);
- assertEq(decoder.decode(p), "ghijklmnop");
+ assertEquals(decoder.decode(p), "ghijklmnop");
[actual, err] = await buf.peek(0);
- assertEq(decoder.decode(actual), "");
+ assertEquals(decoder.decode(actual), "");
assert(err == null);
[actual, err] = await buf.peek(1);
- assertEq(decoder.decode(actual), "");
+ assertEquals(decoder.decode(actual), "");
assert(err == "EOF");
/* TODO
// Test for issue 3022, not exposing a reader's error on a successful Peek.
@@ -302,15 +302,15 @@ test(async function bufioWriter() {
const context = `nwrite=${nwrite} bufsize=${bs}`;
const n = await buf.write(data.subarray(0, nwrite));
- assertEq(n, nwrite, context);
+ assertEquals(n, nwrite, context);
await buf.flush();
const written = w.bytes();
- assertEq(written.byteLength, nwrite);
+ assertEquals(written.byteLength, nwrite);
for (let l = 0; l < written.byteLength; l++) {
- assertEq(written[l], data[l]);
+ assertEquals(written[l], data[l]);
}
}
}
@@ -325,15 +325,15 @@ test(async function bufReaderReadFull() {
{
const buf = new Uint8Array(6);
const [nread, err] = await bufr.readFull(buf);
- assertEq(nread, 6);
+ assertEquals(nread, 6);
assert(!err);
- assertEq(dec.decode(buf), "Hello ");
+ assertEquals(dec.decode(buf), "Hello ");
}
{
const buf = new Uint8Array(6);
const [nread, err] = await bufr.readFull(buf);
- assertEq(nread, 5);
- assertEq(err, "EOF");
- assertEq(dec.decode(buf.subarray(0, 5)), "World");
+ assertEquals(nread, 5);
+ assertEquals(err, "EOF");
+ assertEquals(dec.decode(buf.subarray(0, 5)), "World");
}
});
diff --git a/io/ioutil_test.ts b/io/ioutil_test.ts
index aabdf015b..72adfcec2 100644
--- a/io/ioutil_test.ts
+++ b/io/ioutil_test.ts
@@ -2,7 +2,7 @@
const { Buffer } = Deno;
import { Reader, ReadResult } from "deno";
import { test } from "../testing/mod.ts";
-import { assertEq } from "../testing/asserts.ts";
+import { assertEquals } from "../testing/asserts.ts";
import {
copyN,
readInt,
@@ -28,13 +28,13 @@ class BinaryReader implements Reader {
test(async function testReadShort() {
const r = new BinaryReader(new Uint8Array([0x12, 0x34]));
const short = await readShort(new BufReader(r));
- assertEq(short, 0x1234);
+ assertEquals(short, 0x1234);
});
test(async function testReadInt() {
const r = new BinaryReader(new Uint8Array([0x12, 0x34, 0x56, 0x78]));
const int = await readInt(new BufReader(r));
- assertEq(int, 0x12345678);
+ assertEquals(int, 0x12345678);
});
test(async function testReadLong() {
@@ -42,7 +42,7 @@ test(async function testReadLong() {
new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78])
);
const long = await readLong(new BufReader(r));
- assertEq(long, 0x1234567812345678);
+ assertEquals(long, 0x1234567812345678);
});
test(async function testReadLong2() {
@@ -50,7 +50,7 @@ test(async function testReadLong2() {
new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78])
);
const long = await readLong(new BufReader(r));
- assertEq(long, 0x12345678);
+ assertEquals(long, 0x12345678);
});
test(async function testSliceLongToBytes() {
@@ -63,26 +63,26 @@ test(async function testSliceLongToBytes() {
)
)
);
- assertEq(actual, expected);
+ assertEquals(actual, expected);
});
test(async function testSliceLongToBytes2() {
const arr = sliceLongToBytes(0x12345678);
- assertEq(arr, [0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]);
+ assertEquals(arr, [0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]);
});
test(async function testCopyN1() {
const w = new Buffer();
const r = stringsReader("abcdefghij");
const n = await copyN(w, r, 3);
- assertEq(n, 3);
- assertEq(w.toString(), "abc");
+ assertEquals(n, 3);
+ assertEquals(w.toString(), "abc");
});
test(async function testCopyN2() {
const w = new Buffer();
const r = stringsReader("abcdefghij");
const n = await copyN(w, r, 11);
- assertEq(n, 10);
- assertEq(w.toString(), "abcdefghij");
+ assertEquals(n, 10);
+ assertEquals(w.toString(), "abcdefghij");
});
diff --git a/io/readers_test.ts b/io/readers_test.ts
index 17410804f..35616ace2 100644
--- a/io/readers_test.ts
+++ b/io/readers_test.ts
@@ -1,6 +1,6 @@
const { copy } = Deno;
import { test } from "../testing/mod.ts";
-import { assertEq } from "../testing/asserts.ts";
+import { assertEquals } from "../testing/asserts.ts";
import { MultiReader, StringReader } from "./readers.ts";
import { StringWriter } from "./writers.ts";
import { copyN } from "./ioutil.ts";
@@ -9,29 +9,29 @@ import { decode } from "../strings/strings.ts";
test(async function ioStringReader() {
const r = new StringReader("abcdef");
const { nread, eof } = await r.read(new Uint8Array(6));
- assertEq(nread, 6);
- assertEq(eof, true);
+ assertEquals(nread, 6);
+ assertEquals(eof, true);
});
test(async function ioStringReader() {
const r = new StringReader("abcdef");
const buf = new Uint8Array(3);
let res1 = await r.read(buf);
- assertEq(res1.nread, 3);
- assertEq(res1.eof, false);
- assertEq(decode(buf), "abc");
+ assertEquals(res1.nread, 3);
+ assertEquals(res1.eof, false);
+ assertEquals(decode(buf), "abc");
let res2 = await r.read(buf);
- assertEq(res2.nread, 3);
- assertEq(res2.eof, true);
- assertEq(decode(buf), "def");
+ assertEquals(res2.nread, 3);
+ assertEquals(res2.eof, true);
+ assertEquals(decode(buf), "def");
});
test(async function ioMultiReader() {
const r = new MultiReader(new StringReader("abc"), new StringReader("def"));
const w = new StringWriter();
const n = await copyN(w, r, 4);
- assertEq(n, 4);
- assertEq(w.toString(), "abcd");
+ assertEquals(n, 4);
+ assertEquals(w.toString(), "abcd");
await copy(w, r);
- assertEq(w.toString(), "abcdef");
+ assertEquals(w.toString(), "abcdef");
});
diff --git a/io/util_test.ts b/io/util_test.ts
index 2fca41d31..6dde3a4fc 100644
--- a/io/util_test.ts
+++ b/io/util_test.ts
@@ -1,7 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { remove } = Deno;
import { test } from "../testing/mod.ts";
-import { assert, assertEq } from "../testing/asserts.ts";
+import { assert, assertEquals } from "../testing/asserts.ts";
import { copyBytes, tempFile } from "./util.ts";
import * as path from "../fs/path.ts";
@@ -12,31 +12,31 @@ test(function testCopyBytes() {
let src = Uint8Array.of(1, 2);
let len = copyBytes(dst, src, 0);
assert(len === 2);
- assertEq(dst, Uint8Array.of(1, 2, 0, 0));
+ assertEquals(dst, Uint8Array.of(1, 2, 0, 0));
dst.fill(0);
src = Uint8Array.of(1, 2);
len = copyBytes(dst, src, 1);
assert(len === 2);
- assertEq(dst, Uint8Array.of(0, 1, 2, 0));
+ assertEquals(dst, Uint8Array.of(0, 1, 2, 0));
dst.fill(0);
src = Uint8Array.of(1, 2, 3, 4, 5);
len = copyBytes(dst, src);
assert(len === 4);
- assertEq(dst, Uint8Array.of(1, 2, 3, 4));
+ assertEquals(dst, Uint8Array.of(1, 2, 3, 4));
dst.fill(0);
src = Uint8Array.of(1, 2);
len = copyBytes(dst, src, 100);
assert(len === 0);
- assertEq(dst, Uint8Array.of(0, 0, 0, 0));
+ assertEquals(dst, Uint8Array.of(0, 0, 0, 0));
dst.fill(0);
src = Uint8Array.of(3, 4);
len = copyBytes(dst, src, -2);
assert(len === 2);
- assertEq(dst, Uint8Array.of(3, 4, 0, 0));
+ assertEquals(dst, Uint8Array.of(3, 4, 0, 0));
});
test(async function ioTempfile() {
diff --git a/io/writers_test.ts b/io/writers_test.ts
index 847fc059b..5d6ed33ef 100644
--- a/io/writers_test.ts
+++ b/io/writers_test.ts
@@ -1,6 +1,6 @@
const { copy } = Deno;
import { test } from "../testing/mod.ts";
-import { assertEq } from "../testing/asserts.ts";
+import { assertEquals } from "../testing/asserts.ts";
import { StringWriter } from "./writers.ts";
import { StringReader } from "./readers.ts";
import { copyN } from "./ioutil.ts";
@@ -9,7 +9,7 @@ test(async function ioStringWriter() {
const w = new StringWriter("base");
const r = new StringReader("0123456789");
await copyN(w, r, 4);
- assertEq(w.toString(), "base0123");
+ assertEquals(w.toString(), "base0123");
await copy(w, r);
- assertEq(w.toString(), "base0123456789");
+ assertEquals(w.toString(), "base0123456789");
});