diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2019-07-06 23:16:03 +0900 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-07-06 10:16:03 -0400 |
commit | a948f9ff541e5983bc29113d1e0f1898206f8581 (patch) | |
tree | 67e47efd88468886a8e2a50ad28cc2c75be69389 /js/buffer_test.ts | |
parent | 33cb79d24cf03c2c771dfa499e4cc8ee7bcee800 (diff) |
io: change Reader interface (#2591)
Instead of returning { nread: number, eof: bool }, read() returns EOF | number.
Diffstat (limited to 'js/buffer_test.ts')
-rw-r--r-- | js/buffer_test.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/js/buffer_test.ts b/js/buffer_test.ts index b4ed3a58a..3b2f5d312 100644 --- a/js/buffer_test.ts +++ b/js/buffer_test.ts @@ -60,10 +60,10 @@ async function empty(buf: Buffer, s: string, fub: Uint8Array): Promise<void> { check(buf, s); while (true) { const r = await buf.read(fub); - if (r.nread == 0) { + if (r === Deno.EOF) { break; } - s = s.slice(r.nread); + s = s.slice(r); check(buf, s); } check(buf, ""); @@ -126,8 +126,7 @@ test(async function bufferReadEmptyAtEOF(): Promise<void> { let buf = new Buffer(); const zeroLengthTmp = new Uint8Array(0); let result = await buf.read(zeroLengthTmp); - assertEquals(result.nread, 0); - assertEquals(result.eof, false); + assertEquals(result, 0); }); test(async function bufferLargeByteWrites(): Promise<void> { @@ -217,7 +216,8 @@ test(async function bufferTestGrow(): Promise<void> { for (let growLen of [0, 100, 1000, 10000, 100000]) { const buf = new Buffer(xBytes.buffer as ArrayBuffer); // If we read, this affects buf.off, which is good to test. - const { nread } = await buf.read(tmp); + const result = await buf.read(tmp); + const nread = result === Deno.EOF ? 0 : result; buf.grow(growLen); const yBytes = repeat("y", growLen); await buf.write(yBytes); |