From 980764ac4133c0a71760f6b9a091bfd158e61689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= <73640929+javihernant@users.noreply.github.com> Date: Thu, 14 Mar 2024 07:26:48 +0100 Subject: [PATCH] refactor(io): format test names (#4413) * refactor(io): format test names ref #3754 * Update io/buffer_test.ts --------- Co-authored-by: Asher Gomez --- io/buf_reader_test.ts | 18 +++++++++--------- io/buf_writer_test.ts | 4 ++-- io/buffer_test.ts | 38 +++++++++++++++++++------------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/io/buf_reader_test.ts b/io/buf_reader_test.ts index 36d5d5cf94da..3342042fc625 100644 --- a/io/buf_reader_test.ts +++ b/io/buf_reader_test.ts @@ -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(31); let str = ""; let 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"; @@ -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); @@ -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"; @@ -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. @@ -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(); @@ -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(); diff --git a/io/buf_writer_test.ts b/io/buf_writer_test.ts index fa95c9048bb9..ef8fe8e592ba 100644 --- a/io/buf_writer_test.ts +++ b/io/buf_writer_test.ts @@ -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++) { @@ -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++) { diff --git a/io/buffer_test.ts b/io/buffer_test.ts index c0c6289401a4..693627f881ef 100644 --- a/io/buffer_test.ts +++ b/io/buffer_test.ts @@ -86,7 +86,7 @@ function repeat(c: string, bytes: number): Uint8Array { return ui8; } -Deno.test("bufferNewBuffer", () => { +Deno.test("Buffer", () => { init(); assert(testBytes); assert(testString); @@ -94,7 +94,7 @@ Deno.test("bufferNewBuffer", () => { check(buf, testString); }); -Deno.test("bufferBasicOperations", async () => { +Deno.test("Buffer handles basic operations", async () => { assert(testBytes); assert(testString); const buf = new Buffer(); @@ -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(); @@ -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; @@ -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; @@ -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; @@ -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)); @@ -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)); @@ -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]; @@ -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]; @@ -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]; @@ -271,7 +271,7 @@ Deno.test({ }, }); -Deno.test("bufferLargeByteReads", async () => { +Deno.test("Buffer.write() handles large bytes", async () => { init(); assert(testBytes); assert(testString); @@ -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); @@ -311,7 +311,7 @@ Deno.test("bufferReadFrom", async () => { }); }); -Deno.test("bufferReadFromSync", async () => { +Deno.test("Buffer.readFromSync()", async () => { init(); assert(testBytes); assert(testString); @@ -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); @@ -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) { @@ -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(); @@ -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();