diff options
Diffstat (limited to 'cli/js/tests')
-rw-r--r-- | cli/js/tests/buffer_test.ts | 5 | ||||
-rw-r--r-- | cli/js/tests/files_test.ts | 8 | ||||
-rw-r--r-- | cli/js/tests/io_test.ts | 2 | ||||
-rw-r--r-- | cli/js/tests/net_test.ts | 16 | ||||
-rw-r--r-- | cli/js/tests/process_test.ts | 14 | ||||
-rw-r--r-- | cli/js/tests/tls_test.ts | 6 |
6 files changed, 25 insertions, 26 deletions
diff --git a/cli/js/tests/buffer_test.ts b/cli/js/tests/buffer_test.ts index 9cfb71669..e45bcb976 100644 --- a/cli/js/tests/buffer_test.ts +++ b/cli/js/tests/buffer_test.ts @@ -65,7 +65,7 @@ async function empty(buf: Buffer, s: string, fub: Uint8Array): Promise<void> { check(buf, s); while (true) { const r = await buf.read(fub); - if (r === Deno.EOF) { + if (r === null) { break; } s = s.slice(r); @@ -231,8 +231,7 @@ unitTest(async function bufferTestGrow(): Promise<void> { for (const 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 result = await buf.read(tmp); - const nread = result === Deno.EOF ? 0 : result; + const nread = (await buf.read(tmp)) ?? 0; buf.grow(growLen); const yBytes = repeat("y", growLen); await buf.write(yBytes); diff --git a/cli/js/tests/files_test.ts b/cli/js/tests/files_test.ts index 8952166db..a035c7074 100644 --- a/cli/js/tests/files_test.ts +++ b/cli/js/tests/files_test.ts @@ -101,13 +101,13 @@ unitTest(async function readerIter(): Promise<void> { this.#buf = new Uint8Array(encoder.encode(s)); } - read(p: Uint8Array): Promise<number | Deno.EOF> { + 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(Deno.EOF); + return Promise.resolve(null); } return Promise.resolve(n); @@ -136,13 +136,13 @@ unitTest(async function readerIterSync(): Promise<void> { this.#buf = new Uint8Array(encoder.encode(s)); } - readSync(p: Uint8Array): number | Deno.EOF { + 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 Deno.EOF; + return null; } return n; diff --git a/cli/js/tests/io_test.ts b/cli/js/tests/io_test.ts index 5b6e860be..d6d6e35d1 100644 --- a/cli/js/tests/io_test.ts +++ b/cli/js/tests/io_test.ts @@ -19,7 +19,7 @@ function spyRead(obj: Deno.Buffer): Spy { const orig = obj.read.bind(obj); - obj.read = (p: Uint8Array): Promise<number | Deno.EOF> => { + obj.read = (p: Uint8Array): Promise<number | null> => { spy.calls++; return orig(p); }; diff --git a/cli/js/tests/net_test.ts b/cli/js/tests/net_test.ts index 8840730a8..ef3cd833d 100644 --- a/cli/js/tests/net_test.ts +++ b/cli/js/tests/net_test.ts @@ -179,10 +179,10 @@ unitTest({ perms: { net: true } }, async function netTcpDialListen(): Promise< assertEquals(3, buf[2]); assert(conn.rid > 0); - assert(readResult !== Deno.EOF); + assert(readResult !== null); const readResult2 = await conn.read(buf); - assertEquals(Deno.EOF, readResult2); + assertEquals(readResult2, null); listener.close(); conn.close(); @@ -214,10 +214,10 @@ unitTest( assertEquals(3, buf[2]); assert(conn.rid > 0); - assert(readResult !== Deno.EOF); + assert(readResult !== null); const readResult2 = await conn.read(buf); - assertEquals(Deno.EOF, readResult2); + assertEquals(readResult2, null); listener.close(); conn.close(); @@ -358,10 +358,10 @@ unitTest( assertEquals(3, buf[2]); assert(conn.rid > 0); - assert(readResult !== Deno.EOF); + assert(readResult !== null); const readResult2 = await conn.read(buf); - assertEquals(Deno.EOF, readResult2); + assertEquals(readResult2, null); listener.close(); conn.close(); @@ -396,7 +396,7 @@ unitTest( closeReadDeferred.resolve(); const buf = new Uint8Array(1024); const readResult = await conn.read(buf); - assertEquals(Deno.EOF, readResult); // with immediate EOF + assertEquals(readResult, null); // with immediate EOF // Ensure closeRead does not impact write await conn.write(new Uint8Array([4, 5, 6])); await closeDeferred; @@ -523,7 +523,7 @@ unitTest( try { while (true) { const nread = await conn.read(p); - if (nread === Deno.EOF) { + if (nread === null) { break; } await conn.write(new Uint8Array([1, 2, 3])); diff --git a/cli/js/tests/process_test.ts b/cli/js/tests/process_test.ts index f0615193b..b70ce8307 100644 --- a/cli/js/tests/process_test.ts +++ b/cli/js/tests/process_test.ts @@ -154,14 +154,14 @@ unitTest({ perms: { run: true } }, async function runStdoutPiped(): Promise< const data = new Uint8Array(10); let r = await p.stdout!.read(data); - if (r === Deno.EOF) { - throw new Error("p.stdout.read(...) should not be EOF"); + if (r === null) { + throw new Error("p.stdout.read(...) should not be null"); } assertEquals(r, 5); const s = new TextDecoder().decode(data.subarray(0, r)); assertEquals(s, "hello"); r = await p.stdout!.read(data); - assertEquals(r, Deno.EOF); + assertEquals(r, null); p.stdout!.close(); const status = await p.status(); @@ -183,14 +183,14 @@ unitTest({ perms: { run: true } }, async function runStderrPiped(): Promise< const data = new Uint8Array(10); let r = await p.stderr!.read(data); - if (r === Deno.EOF) { - throw new Error("p.stderr.read should not return EOF here"); + if (r === null) { + throw new Error("p.stderr.read should not return null here"); } assertEquals(r, 5); const s = new TextDecoder().decode(data.subarray(0, r)); assertEquals(s, "hello"); r = await p.stderr!.read(data); - assertEquals(r, Deno.EOF); + assertEquals(r, null); p.stderr!.close(); const status = await p.status(); @@ -313,7 +313,7 @@ unitTest({ perms: { run: true } }, async function runClose(): Promise<void> { const data = new Uint8Array(10); const r = await p.stderr!.read(data); - assertEquals(r, Deno.EOF); + assertEquals(r, null); p.stderr!.close(); }); diff --git a/cli/js/tests/tls_test.ts b/cli/js/tests/tls_test.ts index ce44beac0..b971ccf5c 100644 --- a/cli/js/tests/tls_test.ts +++ b/cli/js/tests/tls_test.ts @@ -191,7 +191,7 @@ unitTest( await w.flush(); const tpr = new TextProtoReader(r); const statusLine = await tpr.readLine(); - assert(statusLine !== Deno.EOF, `line must be read: ${String(statusLine)}`); + assert(statusLine !== null, `line must be read: ${String(statusLine)}`); const m = statusLine.match(/^(.+?) (.+?) (.+?)$/); assert(m !== null, "must be matched"); const [_, proto, status, ok] = m; @@ -199,7 +199,7 @@ unitTest( assertEquals(status, "200"); assertEquals(ok, "OK"); const headers = await tpr.readMIMEHeader(); - assert(headers !== Deno.EOF); + assert(headers !== null); const contentLength = parseInt(headers.get("content-length")!); const bodyBuf = new Uint8Array(contentLength); await r.readFull(bodyBuf); @@ -225,7 +225,7 @@ unitTest( let writer = new BufWriter(conn); let reader = new TextProtoReader(new BufReader(conn)); - let line: string | Deno.EOF = (await reader.readLine()) as string; + let line: string | null = (await reader.readLine()) as string; assert(line.startsWith("220")); await writer.write(encoder.encode(`EHLO ${hostname}\r\n`)); |