diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-09-03 18:35:54 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 18:35:54 +1000 |
commit | 45c1737531be882947e2f62038c0b72fbac921e3 (patch) | |
tree | 4dc3336a5d6bc74b7b5190ba49e771fd00d9ff20 /tests/unit/files_test.ts | |
parent | 259752537f5c81101c47a547ae345f0863235cf6 (diff) |
BREAKING(io): remove `Deno.iter[Sync]()` (#25346)
Towards #22079
Diffstat (limited to 'tests/unit/files_test.ts')
-rw-r--r-- | tests/unit/files_test.ts | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/tests/unit/files_test.ts b/tests/unit/files_test.ts index 71c5a4561..fb45e3ad6 100644 --- a/tests/unit/files_test.ts +++ b/tests/unit/files_test.ts @@ -34,142 +34,6 @@ Deno.test( ); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - async function filesIter() { - const filename = "tests/testdata/assets/hello.txt"; - using file = await Deno.open(filename); - - let totalSize = 0; - for await (const buf of Deno.iter(file)) { - totalSize += buf.byteLength; - } - - assertEquals(totalSize, 12); - }, -); - -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - async function filesIterCustomBufSize() { - const filename = "tests/testdata/assets/hello.txt"; - using file = await Deno.open(filename); - - let totalSize = 0; - let iterations = 0; - for await (const buf of Deno.iter(file, { bufSize: 6 })) { - totalSize += buf.byteLength; - iterations += 1; - } - - assertEquals(totalSize, 12); - assertEquals(iterations, 2); - }, -); - -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - function filesIterSync() { - const filename = "tests/testdata/assets/hello.txt"; - using file = Deno.openSync(filename); - - let totalSize = 0; - for (const buf of Deno.iterSync(file)) { - totalSize += buf.byteLength; - } - - assertEquals(totalSize, 12); - }, -); - -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - function filesIterSyncCustomBufSize() { - const filename = "tests/testdata/assets/hello.txt"; - using file = Deno.openSync(filename); - - let totalSize = 0; - let iterations = 0; - for (const buf of Deno.iterSync(file, { bufSize: 6 })) { - totalSize += buf.byteLength; - iterations += 1; - } - - assertEquals(totalSize, 12); - assertEquals(iterations, 2); - }, -); - -Deno.test({ ignore: DENO_FUTURE }, async function readerIter() { - // ref: https://github.com/denoland/deno/issues/2330 - const encoder = new TextEncoder(); - - class TestReader implements Deno.Reader { - #offset = 0; - #buf: Uint8Array; - - constructor(s: string) { - this.#buf = new Uint8Array(encoder.encode(s)); - } - - read(p: Uint8Array): Promise<number | null> { - const n = Math.min(p.byteLength, this.#buf.byteLength - this.#offset); - p.set(this.#buf.slice(this.#offset, this.#offset + n)); - this.#offset += n; - - if (n === 0) { - return Promise.resolve(null); - } - - return Promise.resolve(n); - } - } - - const reader = new TestReader("hello world!"); - - let totalSize = 0; - for await (const buf of Deno.iter(reader)) { - totalSize += buf.byteLength; - } - - assertEquals(totalSize, 12); -}); - -Deno.test({ ignore: DENO_FUTURE }, async function readerIterSync() { - // ref: https://github.com/denoland/deno/issues/2330 - const encoder = new TextEncoder(); - - class TestReader implements Deno.ReaderSync { - #offset = 0; - #buf: Uint8Array; - - constructor(s: string) { - this.#buf = new Uint8Array(encoder.encode(s)); - } - - readSync(p: Uint8Array): number | null { - const n = Math.min(p.byteLength, this.#buf.byteLength - this.#offset); - p.set(this.#buf.slice(this.#offset, this.#offset + n)); - this.#offset += n; - - if (n === 0) { - return null; - } - - return n; - } - } - - const reader = new TestReader("hello world!"); - - let totalSize = 0; - for await (const buf of Deno.iterSync(reader)) { - totalSize += buf.byteLength; - } - - assertEquals(totalSize, 12); -}); - -Deno.test( { permissions: { read: true, write: true }, }, |