summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/buffer.ts3
-rw-r--r--js/buffer_test.ts10
2 files changed, 11 insertions, 2 deletions
diff --git a/js/buffer.ts b/js/buffer.ts
index f53f6b25d..b06259ed0 100644
--- a/js/buffer.ts
+++ b/js/buffer.ts
@@ -132,8 +132,7 @@ export class Buffer implements Reader, Writer {
// Buffer is empty, reset to recover space.
this.reset();
if (p.byteLength === 0) {
- // TODO This edge case should be tested by porting TestReadEmptyAtEOF
- // from the Go tests.
+ // this edge case is tested in 'bufferReadEmptyAtEOF' test
return { nread: 0, eof: false };
}
return { nread: 0, eof: true };
diff --git a/js/buffer_test.ts b/js/buffer_test.ts
index c614b2e03..843a85f97 100644
--- a/js/buffer_test.ts
+++ b/js/buffer_test.ts
@@ -109,6 +109,16 @@ test(async function bufferBasicOperations() {
}
});
+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)
+ let buf = new Buffer();
+ const zeroLengthTmp = new Uint8Array(0);
+ let result = await buf.read(zeroLengthTmp);
+ assertEqual(result.nread, 0);
+ assertEqual(result.eof, false);
+});
+
test(async function bufferLargeByteWrites() {
init();
const buf = new Buffer();