diff options
Diffstat (limited to 'io')
| -rw-r--r-- | io/bufio_test.ts | 35 | ||||
| -rw-r--r-- | io/ioutil_test.ts | 16 | ||||
| -rw-r--r-- | io/readers_test.ts | 6 | ||||
| -rw-r--r-- | io/util_test.ts | 4 | ||||
| -rw-r--r-- | io/writers_test.ts | 2 |
5 files changed, 33 insertions, 30 deletions
diff --git a/io/bufio_test.ts b/io/bufio_test.ts index 1351b7e37..d1db119d8 100644 --- a/io/bufio_test.ts +++ b/io/bufio_test.ts @@ -29,7 +29,7 @@ async function readBytes(buf: BufReader): Promise<string> { return decoder.decode(b.subarray(0, nb)); } -test(async function bufioReaderSimple() { +test(async function bufioReaderSimple(): Promise<void> { const data = "hello world"; const b = new BufReader(stringsReader(data)); const s = await readBytes(b); @@ -42,9 +42,12 @@ interface ReadMaker { } const readMakers: ReadMaker[] = [ - { name: "full", fn: r => r }, - { name: "byte", fn: r => new iotest.OneByteReader(r) }, - { name: "half", fn: r => new iotest.HalfReader(r) } + { name: "full", fn: (r): Reader => r }, + { + name: "byte", + fn: (r): iotest.OneByteReader => new iotest.OneByteReader(r) + }, + { name: "half", fn: (r): iotest.HalfReader => new iotest.HalfReader(r) } // TODO { name: "data+err", r => new iotest.DataErrReader(r) }, // { name: "timeout", fn: r => new iotest.TimeoutReader(r) }, ]; @@ -70,12 +73,12 @@ interface NamedBufReader { } const bufreaders: NamedBufReader[] = [ - { name: "1", fn: (b: BufReader) => reads(b, 1) }, - { name: "2", fn: (b: BufReader) => reads(b, 2) }, - { name: "3", fn: (b: BufReader) => reads(b, 3) }, - { name: "4", fn: (b: BufReader) => reads(b, 4) }, - { name: "5", fn: (b: BufReader) => reads(b, 5) }, - { name: "7", fn: (b: BufReader) => reads(b, 7) }, + { name: "1", fn: (b: BufReader): Promise<string> => reads(b, 1) }, + { name: "2", fn: (b: BufReader): Promise<string> => reads(b, 2) }, + { name: "3", fn: (b: BufReader): Promise<string> => reads(b, 3) }, + { name: "4", fn: (b: BufReader): Promise<string> => reads(b, 4) }, + { name: "5", fn: (b: BufReader): Promise<string> => reads(b, 5) }, + { name: "7", fn: (b: BufReader): Promise<string> => reads(b, 7) }, { name: "bytes", fn: readBytes } // { name: "lines", fn: readLines }, ]; @@ -94,7 +97,7 @@ const bufsizes: number[] = [ 4096 ]; -test(async function bufioBufReader() { +test(async function bufioBufReader(): Promise<void> { const texts = new Array<string>(31); let str = ""; let all = ""; @@ -122,7 +125,7 @@ test(async function bufioBufReader() { } }); -test(async function bufioBufferFull() { +test(async function bufioBufferFull(): Promise<void> { const longString = "And now, hello, world! It is the time for all good men to come to the aid of their party"; const buf = new BufReader(stringsReader(longString), MIN_READ_BUFFER_SIZE); @@ -201,12 +204,12 @@ async function testReadLine(input: Uint8Array): Promise<void> { } } -test(async function bufioReadLine() { +test(async function bufioReadLine(): Promise<void> { await testReadLine(testInput); await testReadLine(testInputrn); }); -test(async function bufioPeek() { +test(async function bufioPeek(): Promise<void> { const decoder = new TextDecoder(); let p = new Uint8Array(10); // string is 16 (minReadBufferSize) long. @@ -283,7 +286,7 @@ test(async function bufioPeek() { */ }); -test(async function bufioWriter() { +test(async function bufioWriter(): Promise<void> { const data = new Uint8Array(8192); for (let i = 0; i < data.byteLength; i++) { @@ -317,7 +320,7 @@ test(async function bufioWriter() { } }); -test(async function bufReaderReadFull() { +test(async function bufReaderReadFull(): Promise<void> { const enc = new TextEncoder(); const dec = new TextDecoder(); const text = "Hello World"; diff --git a/io/ioutil_test.ts b/io/ioutil_test.ts index c6980ebb9..c1c1ded72 100644 --- a/io/ioutil_test.ts +++ b/io/ioutil_test.ts @@ -26,19 +26,19 @@ class BinaryReader implements Reader { } } -test(async function testReadShort() { +test(async function testReadShort(): Promise<void> { const r = new BinaryReader(new Uint8Array([0x12, 0x34])); const short = await readShort(new BufReader(r)); assertEquals(short, 0x1234); }); -test(async function testReadInt() { +test(async function testReadInt(): Promise<void> { const r = new BinaryReader(new Uint8Array([0x12, 0x34, 0x56, 0x78])); const int = await readInt(new BufReader(r)); assertEquals(int, 0x12345678); }); -test(async function testReadLong() { +test(async function testReadLong(): Promise<void> { const r = new BinaryReader( new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78]) ); @@ -46,7 +46,7 @@ test(async function testReadLong() { assertEquals(long, 0x1234567812345678); }); -test(async function testReadLong2() { +test(async function testReadLong2(): Promise<void> { const r = new BinaryReader( new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]) ); @@ -54,7 +54,7 @@ test(async function testReadLong2() { assertEquals(long, 0x12345678); }); -test(async function testSliceLongToBytes() { +test(async function testSliceLongToBytes(): Promise<void> { const arr = sliceLongToBytes(0x1234567890abcdef); const actual = readLong(new BufReader(new BinaryReader(new Uint8Array(arr)))); const expected = readLong( @@ -67,12 +67,12 @@ test(async function testSliceLongToBytes() { assertEquals(actual, expected); }); -test(async function testSliceLongToBytes2() { +test(async function testSliceLongToBytes2(): Promise<void> { const arr = sliceLongToBytes(0x12345678); assertEquals(arr, [0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]); }); -test(async function testCopyN1() { +test(async function testCopyN1(): Promise<void> { const w = new Buffer(); const r = stringsReader("abcdefghij"); const n = await copyN(w, r, 3); @@ -80,7 +80,7 @@ test(async function testCopyN1() { assertEquals(w.toString(), "abc"); }); -test(async function testCopyN2() { +test(async function testCopyN2(): Promise<void> { const w = new Buffer(); const r = stringsReader("abcdefghij"); const n = await copyN(w, r, 11); diff --git a/io/readers_test.ts b/io/readers_test.ts index 35616ace2..a3806fbe2 100644 --- a/io/readers_test.ts +++ b/io/readers_test.ts @@ -6,14 +6,14 @@ import { StringWriter } from "./writers.ts"; import { copyN } from "./ioutil.ts"; import { decode } from "../strings/strings.ts"; -test(async function ioStringReader() { +test(async function ioStringReader(): Promise<void> { const r = new StringReader("abcdef"); const { nread, eof } = await r.read(new Uint8Array(6)); assertEquals(nread, 6); assertEquals(eof, true); }); -test(async function ioStringReader() { +test(async function ioStringReader(): Promise<void> { const r = new StringReader("abcdef"); const buf = new Uint8Array(3); let res1 = await r.read(buf); @@ -26,7 +26,7 @@ test(async function ioStringReader() { assertEquals(decode(buf), "def"); }); -test(async function ioMultiReader() { +test(async function ioMultiReader(): Promise<void> { const r = new MultiReader(new StringReader("abc"), new StringReader("def")); const w = new StringWriter(); const n = await copyN(w, r, 4); diff --git a/io/util_test.ts b/io/util_test.ts index 6dde3a4fc..3302fe9e3 100644 --- a/io/util_test.ts +++ b/io/util_test.ts @@ -5,7 +5,7 @@ import { assert, assertEquals } from "../testing/asserts.ts"; import { copyBytes, tempFile } from "./util.ts"; import * as path from "../fs/path.ts"; -test(function testCopyBytes() { +test(function testCopyBytes(): void { let dst = new Uint8Array(4); dst.fill(0); @@ -39,7 +39,7 @@ test(function testCopyBytes() { assertEquals(dst, Uint8Array.of(3, 4, 0, 0)); }); -test(async function ioTempfile() { +test(async function ioTempfile(): Promise<void> { const f = await tempFile(".", { prefix: "prefix-", postfix: "-postfix" diff --git a/io/writers_test.ts b/io/writers_test.ts index 5d6ed33ef..decf611f1 100644 --- a/io/writers_test.ts +++ b/io/writers_test.ts @@ -5,7 +5,7 @@ import { StringWriter } from "./writers.ts"; import { StringReader } from "./readers.ts"; import { copyN } from "./ioutil.ts"; -test(async function ioStringWriter() { +test(async function ioStringWriter(): Promise<void> { const w = new StringWriter("base"); const r = new StringReader("0123456789"); await copyN(w, r, 4); |
