summaryrefslogtreecommitdiff
path: root/js/process_test.ts
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2019-07-06 23:16:03 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-07-06 10:16:03 -0400
commita948f9ff541e5983bc29113d1e0f1898206f8581 (patch)
tree67e47efd88468886a8e2a50ad28cc2c75be69389 /js/process_test.ts
parent33cb79d24cf03c2c771dfa499e4cc8ee7bcee800 (diff)
io: change Reader interface (#2591)
Instead of returning { nread: number, eof: bool }, read() returns EOF | number.
Diffstat (limited to 'js/process_test.ts')
-rw-r--r--js/process_test.ts25
1 files changed, 13 insertions, 12 deletions
diff --git a/js/process_test.ts b/js/process_test.ts
index 6e5fe7947..874f59a81 100644
--- a/js/process_test.ts
+++ b/js/process_test.ts
@@ -156,13 +156,14 @@ testPerm({ run: true }, async function runStdoutPiped(): Promise<void> {
const data = new Uint8Array(10);
let r = await p.stdout.read(data);
- assertEquals(r.nread, 5);
- assertEquals(r.eof, false);
- const s = new TextDecoder().decode(data.subarray(0, r.nread));
+ if (r === Deno.EOF) {
+ throw new Error("p.stdout.read(...) should not be EOF");
+ }
+ assertEquals(r, 5);
+ const s = new TextDecoder().decode(data.subarray(0, r));
assertEquals(s, "hello");
r = await p.stdout.read(data);
- assertEquals(r.nread, 0);
- assertEquals(r.eof, true);
+ assertEquals(r, Deno.EOF);
p.stdout.close();
const status = await p.status();
@@ -182,13 +183,14 @@ testPerm({ run: true }, async function runStderrPiped(): Promise<void> {
const data = new Uint8Array(10);
let r = await p.stderr.read(data);
- assertEquals(r.nread, 5);
- assertEquals(r.eof, false);
- const s = new TextDecoder().decode(data.subarray(0, r.nread));
+ if (r === Deno.EOF) {
+ throw new Error("p.stderr.read should not return EOF here");
+ }
+ assertEquals(r, 5);
+ const s = new TextDecoder().decode(data.subarray(0, r));
assertEquals(s, "hello");
r = await p.stderr.read(data);
- assertEquals(r.nread, 0);
- assertEquals(r.eof, true);
+ assertEquals(r, Deno.EOF);
p.stderr.close();
const status = await p.status();
@@ -306,8 +308,7 @@ testPerm({ run: true }, async function runClose(): Promise<void> {
const data = new Uint8Array(10);
let r = await p.stderr.read(data);
- assertEquals(r.nread, 0);
- assertEquals(r.eof, true);
+ assertEquals(r, Deno.EOF);
});
test(function signalNumbers(): void {