Skip to content

Commit

Permalink
refactor(io): format test names (#4413)
Browse files Browse the repository at this point in the history
* refactor(io): format test names

ref #3754

* Update io/buffer_test.ts

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
  • Loading branch information
javihernant and iuioiua authored Mar 14, 2024
1 parent 6c88cdb commit 980764a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
18 changes: 9 additions & 9 deletions io/buf_reader_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ const bufreaders: NamedBufReader[] = [
// { name: "lines", fn: readLines },
];

Deno.test("bufioReaderSimple", async function () {
Deno.test("BufReader.readBytes() reads string from buffer", async function () {
const data = "hello world";
const b = new BufReader(new StringReader(data));
const s = await readBytes(b);
assertEquals(s, data);
});

Deno.test("bufioBufReader", async function () {
Deno.test("BufReader with different readers", async function () {
const texts = new Array<string>(31);
let str = "";
let all = "";
Expand All @@ -138,7 +138,7 @@ Deno.test("bufioBufReader", async function () {
}
});

Deno.test("bufioBufferFull", async function () {
Deno.test("BufReader.readSlice() throws when reading with full buffer", async function () {
const longString =
"And now, hello, world! It is the time for all good men to come to the" +
" aid of their party";
Expand All @@ -160,7 +160,7 @@ Deno.test("bufioBufferFull", async function () {
assertEquals(actual, "world!");
});

Deno.test("bufioReadString", async function () {
Deno.test("BufReader.readString()", async function () {
const string = "And now, hello world!";
const buf = new BufReader(new StringReader(string), MIN_READ_BUFFER_SIZE);

Expand All @@ -185,7 +185,7 @@ Deno.test("bufioReadString", async function () {
}
});

Deno.test("bufReaderReadFull", async function () {
Deno.test("BufReader.readFull() throws if array length is too big", async function () {
const enc = new TextEncoder();
const dec = new TextDecoder();
const text = "Hello World";
Expand All @@ -212,7 +212,7 @@ Deno.test("bufReaderReadFull", async function () {
}
});

Deno.test("bufioPeek", async function () {
Deno.test("BufReader.peek()", async function () {
const decoder = new TextDecoder();
const p = new Uint8Array(10);
// string is 16 (minReadBufferSize) long.
Expand Down Expand Up @@ -357,12 +357,12 @@ async function testReadLine(input: Uint8Array) {
}
}

Deno.test("bufioReadLine", async function () {
Deno.test("BufReader.readLine()", async function () {
await testReadLine(testInput);
await testReadLine(testInputrn);
});

Deno.test("bufioReadLineBadResource", async () => {
Deno.test("BufReader.readLine() throws with BadResource", async () => {
const file = await Deno.open("README.md");
const bufReader = new BufReader(file);
file.close();
Expand All @@ -371,7 +371,7 @@ Deno.test("bufioReadLineBadResource", async () => {
}, Deno.errors.BadResource);
});

Deno.test("bufioReadLineBufferFullError", async () => {
Deno.test("BufReader.readLine() fills a full buffer", async () => {
const input = "@".repeat(5000) + "\n";
const bufReader = new BufReader(new StringReader(input));
const r = await bufReader.readLine();
Expand Down
4 changes: 2 additions & 2 deletions io/buf_writer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { StringWriter } from "./string_writer.ts";
import { bufsizes } from "./_test_common.ts";
import type { Writer, WriterSync } from "./types.ts";

Deno.test("bufioWriter", async function () {
Deno.test("BufWriter.write() writes different number of bytes", async function () {
const data = new Uint8Array(8192);

for (let i = 0; i < data.byteLength; i++) {
Expand Down Expand Up @@ -42,7 +42,7 @@ Deno.test("bufioWriter", async function () {
}
});

Deno.test("bufioWriterSync", function () {
Deno.test("BufWriter.writeSync()", function () {
const data = new Uint8Array(8192);

for (let i = 0; i < data.byteLength; i++) {
Expand Down
38 changes: 19 additions & 19 deletions io/buffer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ function repeat(c: string, bytes: number): Uint8Array {
return ui8;
}

Deno.test("bufferNewBuffer", () => {
Deno.test("Buffer", () => {
init();
assert(testBytes);
assert(testString);
const buf = new Buffer(testBytes.buffer);
check(buf, testString);
});

Deno.test("bufferBasicOperations", async () => {
Deno.test("Buffer handles basic operations", async () => {
assert(testBytes);
assert(testString);
const buf = new Buffer();
Expand Down Expand Up @@ -133,7 +133,7 @@ Deno.test("bufferBasicOperations", async () => {
}
});

Deno.test("bufferReadEmptyAtEOF", async () => {
Deno.test("Buffer.read() handles empty at eof", async () => {
// check that EOF of 'buf' is not reached (even though it's empty) if
// results are written to buffer that has 0 length (ie. it can't store any data)
const buf = new Buffer();
Expand All @@ -142,7 +142,7 @@ Deno.test("bufferReadEmptyAtEOF", async () => {
assertEquals(result, 0);
});

Deno.test("bufferLargeByteWrites", async () => {
Deno.test("Buffer.write() handles large bytes", async () => {
init();
const buf = new Buffer();
const limit = 9;
Expand All @@ -153,7 +153,7 @@ Deno.test("bufferLargeByteWrites", async () => {
check(buf, "");
});

Deno.test("bufferTooLargeByteWrites", async () => {
Deno.test("Buffer.grow() throws if growing beyond maximum size", async () => {
init();
const tmp = new Uint8Array(72);
const growLen = Number.MAX_VALUE;
Expand All @@ -171,7 +171,7 @@ Deno.test("bufferTooLargeByteWrites", async () => {
});

Deno.test({
name: "bufferGrowWriteMaxBuffer",
name: "Buffer.writeSync() grows buffer to max capacity",
ignore: ignoreMaxSizeTests,
fn() {
const bufSize = 16 * 1024;
Expand All @@ -194,7 +194,7 @@ Deno.test({
});

Deno.test({
name: "bufferGrowReadCloseMaxBufferPlus1",
name: "Buffer.readFrom() rejects if read max_size + 1",
ignore: ignoreMaxSizeTests,
async fn() {
const reader = new Buffer(new ArrayBuffer(MAX_SIZE + 1));
Expand All @@ -211,7 +211,7 @@ Deno.test({
});

Deno.test({
name: "bufferGrowReadSyncCloseMaxBufferPlus1",
name: "Buffer.readFromSync() throws if read max_size + 1",
ignore: ignoreMaxSizeTests,
fn() {
const reader = new Buffer(new ArrayBuffer(MAX_SIZE + 1));
Expand All @@ -228,7 +228,7 @@ Deno.test({
});

Deno.test({
name: "bufferGrowReadSyncCloseToMaxBuffer",
name: "Buffer.readFromSync() reads close to max_size",
ignore: ignoreMaxSizeTests,
fn() {
const capacities = [MAX_SIZE, MAX_SIZE - 1];
Expand All @@ -243,7 +243,7 @@ Deno.test({
});

Deno.test({
name: "bufferGrowReadCloseToMaxBuffer",
name: "Buffer.readFrom() reads close to max_size",
ignore: ignoreMaxSizeTests,
async fn() {
const capacities = [MAX_SIZE, MAX_SIZE - 1];
Expand All @@ -257,7 +257,7 @@ Deno.test({
});

Deno.test({
name: "bufferReadCloseToMaxBufferWithInitialGrow",
name: "Buffer.readFrom() reads close to max_size with initial grow",
ignore: ignoreMaxSizeTests,
async fn() {
const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512];
Expand All @@ -271,7 +271,7 @@ Deno.test({
},
});

Deno.test("bufferLargeByteReads", async () => {
Deno.test("Buffer.write() handles large bytes", async () => {
init();
assert(testBytes);
assert(testString);
Expand All @@ -284,12 +284,12 @@ Deno.test("bufferLargeByteReads", async () => {
check(buf, "");
});

Deno.test("bufferCapWithPreallocatedSlice", () => {
Deno.test("Buffer handles capacity with preallocated slice", () => {
const buf = new Buffer(new ArrayBuffer(10));
assertEquals(buf.capacity, 10);
});

Deno.test("bufferReadFrom", async () => {
Deno.test("Buffer.readFrom()", async () => {
init();
assert(testBytes);
assert(testString);
Expand All @@ -311,7 +311,7 @@ Deno.test("bufferReadFrom", async () => {
});
});

Deno.test("bufferReadFromSync", async () => {
Deno.test("Buffer.readFromSync()", async () => {
init();
assert(testBytes);
assert(testString);
Expand All @@ -333,7 +333,7 @@ Deno.test("bufferReadFromSync", async () => {
});
});

Deno.test("bufferTestGrow", async () => {
Deno.test("Buffer.grow()", async () => {
const tmp = new Uint8Array(72);
for (const startLen of [0, 100, 1000, 10000]) {
const xBytes = repeat("x", startLen);
Expand All @@ -357,7 +357,7 @@ Deno.test("bufferTestGrow", async () => {
}
});

Deno.test("testBufferBytesArrayBufferLength", () => {
Deno.test("Buffer.write() and Buffer.readFromSync()", () => {
// defaults to copy
const args = [undefined, { copy: true }] as const;
for (const arg of args) {
Expand All @@ -376,7 +376,7 @@ Deno.test("testBufferBytesArrayBufferLength", () => {
}
});

Deno.test("testBufferBytesCopyFalse", () => {
Deno.test("Buffer.bytes() with copy set to false", () => {
const bufSize = 64 * 1024;
const bytes = new TextEncoder().encode("a".repeat(bufSize));
const reader = new Buffer();
Expand All @@ -391,7 +391,7 @@ Deno.test("testBufferBytesCopyFalse", () => {
assert(actualBytes.buffer.byteLength > actualBytes.byteLength);
});

Deno.test("testBufferBytesCopyFalseGrowExactBytes", () => {
Deno.test("Buffer.bytes() with copy set to false after Buffer.grow()", () => {
const bufSize = 64 * 1024;
const bytes = new TextEncoder().encode("a".repeat(bufSize));
const reader = new Buffer();
Expand Down

0 comments on commit 980764a

Please sign in to comment.