diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2019-07-23 08:16:39 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-07-23 11:16:39 -0400 |
commit | e49d1e16ca2fca45e959c1add9b5a1d6866dbb90 (patch) | |
tree | 1415190fcd43e18e0994eba5f13b9babf2b474db /js/buffer_test.ts | |
parent | 70de8dd51d465ea2016d6bb7c0728111f4493668 (diff) |
feat: expose writeAll() and writeAllSync() (#2298)
Symmetric with `readAll()` and `readAllSync()`. Also used in `xeval`.
Also correct usage in `writeFile()`/`writeFileSync()`.
Diffstat (limited to 'js/buffer_test.ts')
-rw-r--r-- | js/buffer_test.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/js/buffer_test.ts b/js/buffer_test.ts index 3b2f5d312..911750bb1 100644 --- a/js/buffer_test.ts +++ b/js/buffer_test.ts @@ -5,7 +5,7 @@ // https://github.com/golang/go/blob/master/LICENSE import { assertEquals, test } from "./test_util.ts"; -const { Buffer, readAll, readAllSync } = Deno; +const { Buffer, readAll, readAllSync, writeAll, writeAllSync } = Deno; type Buffer = Deno.Buffer; // N controls how many iterations of certain checks are performed. @@ -253,3 +253,25 @@ test(function testReadAllSync(): void { assertEquals(testBytes[i], actualBytes[i]); } }); + +test(async function testWriteAll(): Promise<void> { + init(); + const writer = new Buffer(); + await writeAll(writer, testBytes); + const actualBytes = writer.bytes(); + assertEquals(testBytes.byteLength, actualBytes.byteLength); + for (let i = 0; i < testBytes.length; ++i) { + assertEquals(testBytes[i], actualBytes[i]); + } +}); + +test(function testWriteAllSync(): void { + init(); + const writer = new Buffer(); + writeAllSync(writer, testBytes); + const actualBytes = writer.bytes(); + assertEquals(testBytes.byteLength, actualBytes.byteLength); + for (let i = 0; i < testBytes.length; ++i) { + assertEquals(testBytes[i], actualBytes[i]); + } +}); |