diff options
Diffstat (limited to 'tests/unit/buffer_test.ts')
-rw-r--r-- | tests/unit/buffer_test.ts | 97 |
1 files changed, 45 insertions, 52 deletions
diff --git a/tests/unit/buffer_test.ts b/tests/unit/buffer_test.ts index 2295aa5ae..221574882 100644 --- a/tests/unit/buffer_test.ts +++ b/tests/unit/buffer_test.ts @@ -10,7 +10,6 @@ import { assertEquals, assertRejects, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; import { writeAllSync } from "@std/io/write-all"; @@ -88,7 +87,7 @@ function repeat(c: string, bytes: number): Uint8Array { return ui8; } -Deno.test({ ignore: DENO_FUTURE }, function bufferNewBuffer() { +Deno.test(function bufferNewBuffer() { init(); assert(testBytes); assert(testString); @@ -96,7 +95,7 @@ Deno.test({ ignore: DENO_FUTURE }, function bufferNewBuffer() { check(buf, testString); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferBasicOperations() { +Deno.test(async function bufferBasicOperations() { init(); assert(testBytes); assert(testString); @@ -136,7 +135,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferBasicOperations() { } }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferReadEmptyAtEOF() { +Deno.test(async function bufferReadEmptyAtEOF() { // 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 Deno.Buffer(); @@ -145,7 +144,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadEmptyAtEOF() { assertEquals(result, 0); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteWrites() { +Deno.test(async function bufferLargeByteWrites() { init(); const buf = new Deno.Buffer(); const limit = 9; @@ -156,7 +155,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteWrites() { check(buf, ""); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferTooLargeByteWrites() { +Deno.test(async function bufferTooLargeByteWrites() { init(); const tmp = new Uint8Array(72); const growLen = Number.MAX_VALUE; @@ -174,7 +173,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferTooLargeByteWrites() { }); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, function bufferGrowWriteMaxBuffer() { const bufSize = 16 * 1024; const capacities = [MAX_SIZE, MAX_SIZE - 1]; @@ -196,7 +195,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, async function bufferGrowReadCloseMaxBufferPlus1() { const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1)); const buf = new Deno.Buffer(); @@ -212,7 +211,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, function bufferGrowReadSyncCloseMaxBufferPlus1() { const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1)); const buf = new Deno.Buffer(); @@ -228,7 +227,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, function bufferGrowReadSyncCloseToMaxBuffer() { const capacities = [MAX_SIZE, MAX_SIZE - 1]; for (const capacity of capacities) { @@ -242,7 +241,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, async function bufferGrowReadCloseToMaxBuffer() { const capacities = [MAX_SIZE, MAX_SIZE - 1]; for (const capacity of capacities) { @@ -255,7 +254,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, async function bufferReadCloseToMaxBufferWithInitialGrow() { const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512]; for (const capacity of capacities) { @@ -268,7 +267,7 @@ Deno.test( }, ); -Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteReads() { +Deno.test(async function bufferLargeByteReads() { init(); assert(testBytes); assert(testString); @@ -281,12 +280,12 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteReads() { check(buf, ""); }); -Deno.test({ ignore: DENO_FUTURE }, function bufferCapWithPreallocatedSlice() { +Deno.test(function bufferCapWithPreallocatedSlice() { const buf = new Deno.Buffer(new ArrayBuffer(10)); assertEquals(buf.capacity, 10); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFrom() { +Deno.test(async function bufferReadFrom() { init(); assert(testBytes); assert(testString); @@ -308,7 +307,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFrom() { }); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFromSync() { +Deno.test(async function bufferReadFromSync() { init(); assert(testBytes); assert(testString); @@ -330,7 +329,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFromSync() { }); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferTestGrow() { +Deno.test(async function bufferTestGrow() { const tmp = new Uint8Array(72); for (const startLen of [0, 100, 1000, 10000]) { const xBytes = repeat("x", startLen); @@ -354,7 +353,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferTestGrow() { } }); -Deno.test({ ignore: DENO_FUTURE }, async function testReadAll() { +Deno.test(async function testReadAll() { init(); assert(testBytes); const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer); @@ -365,7 +364,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function testReadAll() { } }); -Deno.test({ ignore: DENO_FUTURE }, function testReadAllSync() { +Deno.test(function testReadAllSync() { init(); assert(testBytes); const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer); @@ -376,7 +375,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testReadAllSync() { } }); -Deno.test({ ignore: DENO_FUTURE }, async function testWriteAll() { +Deno.test(async function testWriteAll() { init(); assert(testBytes); const writer = new Deno.Buffer(); @@ -388,7 +387,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function testWriteAll() { } }); -Deno.test({ ignore: DENO_FUTURE }, function testWriteAllSync() { +Deno.test(function testWriteAllSync() { init(); assert(testBytes); const writer = new Deno.Buffer(); @@ -400,7 +399,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testWriteAllSync() { } }); -Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesArrayBufferLength() { +Deno.test(function testBufferBytesArrayBufferLength() { // defaults to copy const args = [{}, { copy: undefined }, undefined, { copy: true }]; for (const arg of args) { @@ -419,7 +418,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesArrayBufferLength() { } }); -Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesCopyFalse() { +Deno.test(function testBufferBytesCopyFalse() { const bufSize = 64 * 1024; const bytes = new TextEncoder().encode("a".repeat(bufSize)); const reader = new Deno.Buffer(); @@ -434,36 +433,30 @@ Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesCopyFalse() { assert(actualBytes.buffer.byteLength > actualBytes.byteLength); }); -Deno.test( - { ignore: DENO_FUTURE }, - function testBufferBytesCopyFalseGrowExactBytes() { - const bufSize = 64 * 1024; - const bytes = new TextEncoder().encode("a".repeat(bufSize)); - const reader = new Deno.Buffer(); - writeAllSync(reader, bytes); +Deno.test(function testBufferBytesCopyFalseGrowExactBytes() { + const bufSize = 64 * 1024; + const bytes = new TextEncoder().encode("a".repeat(bufSize)); + const reader = new Deno.Buffer(); + writeAllSync(reader, bytes); - const writer = new Deno.Buffer(); - writer.grow(bufSize); - writer.readFromSync(reader); - const actualBytes = writer.bytes({ copy: false }); + const writer = new Deno.Buffer(); + writer.grow(bufSize); + writer.readFromSync(reader); + const actualBytes = writer.bytes({ copy: false }); - assertEquals(actualBytes.byteLength, bufSize); - assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength); - }, -); + assertEquals(actualBytes.byteLength, bufSize); + assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength); +}); -Deno.test( - { ignore: DENO_FUTURE }, - function testThrowsErrorWhenBufferExceedsMaxLength() { - const kStringMaxLengthPlusOne = 536870888 + 1; - const bytes = new Uint8Array(kStringMaxLengthPlusOne); +Deno.test(function testThrowsErrorWhenBufferExceedsMaxLength() { + const kStringMaxLengthPlusOne = 536870888 + 1; + const bytes = new Uint8Array(kStringMaxLengthPlusOne); - assertThrows( - () => { - new TextDecoder().decode(bytes); - }, - TypeError, - "buffer exceeds maximum length", - ); - }, -); + assertThrows( + () => { + new TextDecoder().decode(bytes); + }, + TypeError, + "buffer exceeds maximum length", + ); +}); |