Skip to content

Commit

Permalink
BREAKING: remove overload of Deno.test() (denoland/deno#4951)
Browse files Browse the repository at this point in the history
This commit removes overload of Deno.test() that accepted named
function.
  • Loading branch information
bartlomieju authored Apr 28, 2020
1 parent 06858b3 commit 6312e30
Show file tree
Hide file tree
Showing 63 changed files with 434 additions and 425 deletions.
8 changes: 5 additions & 3 deletions archive/tar_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Tar, Untar } from "./tar.ts";

const filePath = resolve("archive", "testdata", "example.txt");

Deno.test(async function createTarArchive(): Promise<void> {
Deno.test("createTarArchive", async function (): Promise<void> {
// initialize
const tar = new Tar();

Expand All @@ -40,7 +40,7 @@ Deno.test(async function createTarArchive(): Promise<void> {
assertEquals(wrote, 3072);
});

Deno.test(async function deflateTarArchive(): Promise<void> {
Deno.test("deflateTarArchive", async function (): Promise<void> {
const fileName = "output.txt";
const text = "hello tar world!";

Expand All @@ -63,7 +63,9 @@ Deno.test(async function deflateTarArchive(): Promise<void> {
assertEquals(untarText, text);
});

Deno.test(async function appendFileWithLongNameToTarArchive(): Promise<void> {
Deno.test("appendFileWithLongNameToTarArchive", async function (): Promise<
void
> {
// 9 * 15 + 13 = 148 bytes
const fileName = new Array(10).join("long-file-name/") + "file-name.txt";
const text = "hello tar world!";
Expand Down
12 changes: 6 additions & 6 deletions datetime/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { assertEquals, assertThrows } from "../testing/asserts.ts";
import * as datetime from "./mod.ts";

Deno.test(function parseDateTime(): void {
Deno.test("parseDateTime", function (): void {
assertEquals(
datetime.parseDateTime("01-03-2019 16:30", "mm-dd-yyyy hh:mm"),
new Date(2019, 0, 3, 16, 30)
Expand All @@ -29,7 +29,7 @@ Deno.test(function parseDateTime(): void {
);
});

Deno.test(function invalidParseDateTimeFormatThrows(): void {
Deno.test("invalidParseDateTimeFormatThrows", function (): void {
assertThrows(
(): void => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -40,7 +40,7 @@ Deno.test(function invalidParseDateTimeFormatThrows(): void {
);
});

Deno.test(function parseDate(): void {
Deno.test("parseDate", function (): void {
assertEquals(
datetime.parseDate("01-03-2019", "mm-dd-yyyy"),
new Date(2019, 0, 3)
Expand All @@ -55,7 +55,7 @@ Deno.test(function parseDate(): void {
);
});

Deno.test(function invalidParseDateFormatThrows(): void {
Deno.test("invalidParseDateFormatThrows", function (): void {
assertThrows(
(): void => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -66,13 +66,13 @@ Deno.test(function invalidParseDateFormatThrows(): void {
);
});

Deno.test(function DayOfYear(): void {
Deno.test("DayOfYear", function (): void {
assertEquals(1, datetime.dayOfYear(new Date("2019-01-01T03:24:00")));
assertEquals(70, datetime.dayOfYear(new Date("2019-03-11T03:24:00")));
assertEquals(365, datetime.dayOfYear(new Date("2019-12-31T03:24:00")));
});

Deno.test(function currentDayOfYear(): void {
Deno.test("currentDayOfYear", function (): void {
assertEquals(datetime.currentDayOfYear(), datetime.dayOfYear(new Date()));
});

Expand Down
38 changes: 19 additions & 19 deletions encoding/binary_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ import {
writeVarnum,
} from "./binary.ts";

Deno.test(async function testGetNBytes(): Promise<void> {
Deno.test("testGetNBytes", async function (): Promise<void> {
const data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const buff = new Deno.Buffer(data.buffer);
const rslt = await getNBytes(buff, 8);
assertEquals(rslt, data);
});

Deno.test(async function testGetNBytesThrows(): Promise<void> {
Deno.test("testGetNBytesThrows", async function (): Promise<void> {
const data = new Uint8Array([1, 2, 3, 4]);
const buff = new Deno.Buffer(data.buffer);
await assertThrowsAsync(async () => {
await getNBytes(buff, 8);
}, Deno.errors.UnexpectedEof);
});

Deno.test(function testPutVarbig(): void {
Deno.test("testPutVarbig", function (): void {
const buff = new Uint8Array(8);
putVarbig(buff, 0xffeeddccbbaa9988n);
assertEquals(
Expand All @@ -38,7 +38,7 @@ Deno.test(function testPutVarbig(): void {
);
});

Deno.test(function testPutVarbigLittleEndian(): void {
Deno.test("testPutVarbigLittleEndian", function (): void {
const buff = new Uint8Array(8);
putVarbig(buff, 0x8899aabbccddeeffn, { endian: "little" });
assertEquals(
Expand All @@ -47,47 +47,47 @@ Deno.test(function testPutVarbigLittleEndian(): void {
);
});

Deno.test(function testPutVarnum(): void {
Deno.test("testPutVarnum", function (): void {
const buff = new Uint8Array(4);
putVarnum(buff, 0xffeeddcc);
assertEquals(buff, new Uint8Array([0xff, 0xee, 0xdd, 0xcc]));
});

Deno.test(function testPutVarnumLittleEndian(): void {
Deno.test("testPutVarnumLittleEndian", function (): void {
const buff = new Uint8Array(4);
putVarnum(buff, 0xccddeeff, { endian: "little" });
assertEquals(buff, new Uint8Array([0xff, 0xee, 0xdd, 0xcc]));
});

Deno.test(async function testReadVarbig(): Promise<void> {
Deno.test("testReadVarbig", async function (): Promise<void> {
const data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const buff = new Deno.Buffer(data.buffer);
const rslt = await readVarbig(buff);
assertEquals(rslt, 0x0102030405060708n);
});

Deno.test(async function testReadVarbigLittleEndian(): Promise<void> {
Deno.test("testReadVarbigLittleEndian", async function (): Promise<void> {
const data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const buff = new Deno.Buffer(data.buffer);
const rslt = await readVarbig(buff, { endian: "little" });
assertEquals(rslt, 0x0807060504030201n);
});

Deno.test(async function testReadVarnum(): Promise<void> {
Deno.test("testReadVarnum", async function (): Promise<void> {
const data = new Uint8Array([1, 2, 3, 4]);
const buff = new Deno.Buffer(data.buffer);
const rslt = await readVarnum(buff);
assertEquals(rslt, 0x01020304);
});

Deno.test(async function testReadVarnumLittleEndian(): Promise<void> {
Deno.test("testReadVarnumLittleEndian", async function (): Promise<void> {
const data = new Uint8Array([1, 2, 3, 4]);
const buff = new Deno.Buffer(data.buffer);
const rslt = await readVarnum(buff, { endian: "little" });
assertEquals(rslt, 0x04030201);
});

Deno.test(function testSizeof(): void {
Deno.test("testSizeof", function (): void {
assertEquals(1, sizeof("int8"));
assertEquals(1, sizeof("uint8"));
assertEquals(2, sizeof("int16"));
Expand All @@ -100,30 +100,30 @@ Deno.test(function testSizeof(): void {
assertEquals(8, sizeof("float64"));
});

Deno.test(function testVarbig(): void {
Deno.test("testVarbig", function (): void {
const data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const rslt = varbig(data);
assertEquals(rslt, 0x0102030405060708n);
});

Deno.test(function testVarbigLittleEndian(): void {
Deno.test("testVarbigLittleEndian", function (): void {
const data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const rslt = varbig(data, { endian: "little" });
assertEquals(rslt, 0x0807060504030201n);
});

Deno.test(function testVarnum(): void {
Deno.test("testVarnum", function (): void {
const data = new Uint8Array([1, 2, 3, 4]);
const rslt = varnum(data);
assertEquals(rslt, 0x01020304);
});
Deno.test(function testVarnumLittleEndian(): void {
Deno.test("testVarnumLittleEndian", function (): void {
const data = new Uint8Array([1, 2, 3, 4]);
const rslt = varnum(data, { endian: "little" });
assertEquals(rslt, 0x04030201);
});

Deno.test(async function testWriteVarbig(): Promise<void> {
Deno.test("testWriteVarbig", async function (): Promise<void> {
const data = new Uint8Array(8);
const buff = new Deno.Buffer();
await writeVarbig(buff, 0x0102030405060708n);
Expand All @@ -134,7 +134,7 @@ Deno.test(async function testWriteVarbig(): Promise<void> {
);
});

Deno.test(async function testWriteVarbigLittleEndian(): Promise<void> {
Deno.test("testWriteVarbigLittleEndian", async function (): Promise<void> {
const data = new Uint8Array(8);
const buff = new Deno.Buffer();
await writeVarbig(buff, 0x0807060504030201n, { endian: "little" });
Expand All @@ -145,15 +145,15 @@ Deno.test(async function testWriteVarbigLittleEndian(): Promise<void> {
);
});

Deno.test(async function testWriteVarnum(): Promise<void> {
Deno.test("testWriteVarnum", async function (): Promise<void> {
const data = new Uint8Array(4);
const buff = new Deno.Buffer();
await writeVarnum(buff, 0x01020304);
await buff.read(data);
assertEquals(data, new Uint8Array([0x01, 0x02, 0x03, 0x04]));
});

Deno.test(async function testWriteVarnumLittleEndian(): Promise<void> {
Deno.test("testWriteVarnumLittleEndian", async function (): Promise<void> {
const data = new Uint8Array(4);
const buff = new Deno.Buffer();
await writeVarnum(buff, 0x04030201, { endian: "little" });
Expand Down
6 changes: 3 additions & 3 deletions examples/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ const { run } = Deno;
import { assertEquals } from "../testing/asserts.ts";

/** Example of how to do basic tests */
Deno.test(function t1(): void {
Deno.test("t1", function (): void {
assertEquals("hello", "hello");
});

Deno.test(function t2(): void {
Deno.test("t2", function (): void {
assertEquals("world", "world");
});

/** A more complicated test that runs a subprocess. */
Deno.test(async function catSmoke(): Promise<void> {
Deno.test("catSmoke", async function (): Promise<void> {
const p = run({
cmd: [
Deno.execPath(),
Expand Down
6 changes: 3 additions & 3 deletions examples/tests/xeval_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {
} from "../../testing/asserts.ts";
const { execPath, run } = Deno;

Deno.test(async function xevalSuccess(): Promise<void> {
Deno.test("xevalSuccess", async function (): Promise<void> {
const chunks: string[] = [];
await xeval(stringsReader("a\nb\nc"), ($): number => chunks.push($));
assertEquals(chunks, ["a", "b", "c"]);
});

Deno.test(async function xevalDelimiter(): Promise<void> {
Deno.test("xevalDelimiter", async function (): Promise<void> {
const chunks: string[] = [];
await xeval(stringsReader("!MADMADAMADAM!"), ($): number => chunks.push($), {
delimiter: "MADAM",
Expand Down Expand Up @@ -43,7 +43,7 @@ Deno.test({
},
});

Deno.test(async function xevalCliSyntaxError(): Promise<void> {
Deno.test("xevalCliSyntaxError", async function (): Promise<void> {
const p = run({
cmd: [execPath(), xevalPath, "("],
stdin: "null",
Expand Down
4 changes: 2 additions & 2 deletions flags/all_bool_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { assertEquals } from "../testing/asserts.ts";
import { parse } from "./mod.ts";

// flag boolean true (default all --args to boolean)
Deno.test(function flagBooleanTrue(): void {
Deno.test("flagBooleanTrue", function (): void {
const argv = parse(["moo", "--honk", "cow"], {
boolean: true,
});
Expand All @@ -17,7 +17,7 @@ Deno.test(function flagBooleanTrue(): void {
});

// flag boolean true only affects double hyphen arguments without equals signs
Deno.test(function flagBooleanTrueOnlyAffectsDoubleDash(): void {
Deno.test("flagBooleanTrueOnlyAffectsDoubleDash", function (): void {
const argv = parse(["moo", "--honk", "cow", "-p", "55", "--tacos=good"], {
boolean: true,
});
Expand Down
Loading

0 comments on commit 6312e30

Please sign in to comment.