Updated devtools
This commit is contained in:
parent
19e02992df
commit
aae9949650
7 changed files with 30 additions and 30 deletions
|
@ -1,14 +1,14 @@
|
|||
import { expect, test } from "./deps.test.ts";
|
||||
import { bool, cmp, is } from "./comparison.ts";
|
||||
import { expect, it } from "./deps.test.ts";
|
||||
|
||||
test("cmp", () => {
|
||||
it("cmp", () => {
|
||||
expect([8, 3, 5].sort(cmp())).toEqual([3, 5, 8]);
|
||||
expect([8, 3, 5, 8].sort(cmp({ reverse: true }))).toEqual([8, 8, 5, 3]);
|
||||
expect([-2, 8, -7].sort(cmp({ key: Math.abs }))).toEqual([-2, -7, 8]);
|
||||
expect(["c", "a", "b"].sort(cmp())).toEqual(["a", "b", "c"]);
|
||||
});
|
||||
|
||||
test("is", () => {
|
||||
it("is", () => {
|
||||
const f1 = is(5);
|
||||
expect(f1(5)).toBe(true);
|
||||
expect(f1(4)).toBe(false);
|
||||
|
@ -23,7 +23,7 @@ test("is", () => {
|
|||
expect(f2({ y: 1 } as any)).toBe(false);
|
||||
});
|
||||
|
||||
test("bool", () => {
|
||||
it("bool", () => {
|
||||
expect(bool(null)).toBe(false);
|
||||
expect(bool(undefined)).toBe(false);
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import { expect, test } from "./deps.test.ts";
|
||||
import { identity, nop, partial, pipe } from "./composition.ts";
|
||||
import { expect, it } from "./deps.test.ts";
|
||||
|
||||
test("nop", () => {
|
||||
it("nop", () => {
|
||||
expect(nop()).toBeUndefined();
|
||||
});
|
||||
|
||||
test("identity", () => {
|
||||
it("identity", () => {
|
||||
expect(identity(5)).toBe(5);
|
||||
expect(identity(null)).toBe(null);
|
||||
});
|
||||
|
||||
test("partial", () => {
|
||||
it("partial", () => {
|
||||
const func1 = (conf: { a: number; b: string; c: number }) =>
|
||||
`${conf.a}${conf.b}${conf.c}`;
|
||||
const pfunc1 = partial({ b: "test" }, func1);
|
||||
|
@ -22,7 +22,7 @@ test("partial", () => {
|
|||
expect(pfunc2({ a: 2 }, 3)).toEqual("2test3");
|
||||
});
|
||||
|
||||
test("pipe", () => {
|
||||
it("pipe", () => {
|
||||
const f = pipe((x: number) => x * 2, (x: number) => x + 1);
|
||||
expect(f(1)).toBe(3);
|
||||
expect(f(2)).toBe(5);
|
||||
|
|
|
@ -1 +1 @@
|
|||
export * from "https://code.thunderk.net/typescript/devtools/raw/1.0.0/testing.ts";
|
||||
export * from "https://code.thunderk.net/typescript/devtools/raw/1.2.2/testing.ts";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { expect, test } from "./deps.test.ts";
|
||||
import { expect, it } from "./deps.test.ts";
|
||||
import { at, first, fmap, last, second, third } from "./iterables.ts";
|
||||
|
||||
test("at", () => {
|
||||
it("at", () => {
|
||||
const second = at(1);
|
||||
expect(second([1, 4, 8])).toBe(4);
|
||||
expect(second([1])).toBeUndefined();
|
||||
|
@ -11,31 +11,31 @@ test("at", () => {
|
|||
expect(second_from_end([1])).toBeUndefined();
|
||||
});
|
||||
|
||||
test("first", () => {
|
||||
it("first", () => {
|
||||
expect(first([1, 4, 8])).toBe(1);
|
||||
expect(first([1])).toBe(1);
|
||||
expect(first([])).toBeUndefined();
|
||||
});
|
||||
|
||||
test("second", () => {
|
||||
it("second", () => {
|
||||
expect(second([1, 4, 8])).toBe(4);
|
||||
expect(second([1])).toBeUndefined();
|
||||
expect(second([])).toBeUndefined();
|
||||
});
|
||||
|
||||
test("third", () => {
|
||||
it("third", () => {
|
||||
expect(third([1, 4, 8])).toBe(8);
|
||||
expect(third([1, 4])).toBeUndefined();
|
||||
expect(third([])).toBeUndefined();
|
||||
});
|
||||
|
||||
test("last", () => {
|
||||
it("last", () => {
|
||||
expect(last([1, 4, 8])).toBe(8);
|
||||
expect(last([1])).toBe(1);
|
||||
expect(last([])).toBeUndefined();
|
||||
});
|
||||
|
||||
test("fmap", () => {
|
||||
it("fmap", () => {
|
||||
expect(fmap()([1, 2, 3])).toEqual([1, 2, 3]);
|
||||
expect(fmap((x: number) => x * 2)([1, 2, 3])).toEqual([2, 4, 6]);
|
||||
expect(fmap(undefined, (x: number) => x % 2 == 0)([1, 2, 3])).toEqual([2]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { expect, test } from "./deps.test.ts";
|
||||
import { expect, it } from "./deps.test.ts";
|
||||
import { attr } from "./objects.ts";
|
||||
|
||||
test("attr", () => {
|
||||
it("attr", () => {
|
||||
const getx = attr("x");
|
||||
expect(getx({ x: 4, y: 5 })).toBe(4);
|
||||
expect(getx({ x: undefined, y: 5 })).toBeUndefined();
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import { expect, test } from "./deps.test.ts";
|
||||
import { expect, it } from "./deps.test.ts";
|
||||
import { always, and, never, not, or } from "./predicates.ts";
|
||||
|
||||
test("always", () => {
|
||||
it("always", () => {
|
||||
expect(always()).toBe(true);
|
||||
expect(always(true)).toBe(true);
|
||||
expect(always(false)).toBe(true);
|
||||
});
|
||||
|
||||
test("never", () => {
|
||||
it("never", () => {
|
||||
expect(never()).toBe(false);
|
||||
expect(never(true)).toBe(false);
|
||||
expect(never(false)).toBe(false);
|
||||
});
|
||||
|
||||
test("not", () => {
|
||||
it("not", () => {
|
||||
const iseven = (x: number) => x % 2 == 0;
|
||||
const isodd = not(iseven);
|
||||
expect(iseven(0)).toBe(true);
|
||||
|
@ -24,7 +24,7 @@ test("not", () => {
|
|||
expect(isodd(2)).toBe(false);
|
||||
});
|
||||
|
||||
test("and", () => {
|
||||
it("and", () => {
|
||||
const f = and((x: number) => x % 2 == 0, (x: number) => x > 5);
|
||||
expect(f(0)).toBe(false);
|
||||
expect(f(2)).toBe(false);
|
||||
|
@ -33,7 +33,7 @@ test("and", () => {
|
|||
expect(f(10)).toBe(true);
|
||||
});
|
||||
|
||||
test("or", () => {
|
||||
it("or", () => {
|
||||
const f = or((x: number) => x % 2 == 0, (x: number) => x > 5);
|
||||
expect(f(0)).toBe(true);
|
||||
expect(f(1)).toBe(false);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { expect, test } from "./deps.test.ts";
|
||||
import { expect, it } from "./deps.test.ts";
|
||||
import { isinstance, nn, nnu, nu } from "./typing.ts";
|
||||
|
||||
test("isinstance", () => {
|
||||
it("isinstance", () => {
|
||||
class A {}
|
||||
class A1 extends A {}
|
||||
class A2 extends A {}
|
||||
|
@ -12,7 +12,7 @@ test("isinstance", () => {
|
|||
expect(result).toEqual([f[3], f[4], f[6]]);
|
||||
});
|
||||
|
||||
test("nn", () => {
|
||||
it("nn", () => {
|
||||
expect(nn(undefined)).toBeUndefined();
|
||||
expect(nn(0)).toBe(0);
|
||||
expect(nn("")).toBe("");
|
||||
|
@ -20,7 +20,7 @@ test("nn", () => {
|
|||
expect(() => nn(null)).toThrow("null value");
|
||||
});
|
||||
|
||||
test("nu", () => {
|
||||
it("nu", () => {
|
||||
expect(nu(null)).toBe(null);
|
||||
expect(nu(0)).toBe(0);
|
||||
expect(nu("")).toBe("");
|
||||
|
@ -28,7 +28,7 @@ test("nu", () => {
|
|||
expect(() => nu(undefined)).toThrow("undefined value");
|
||||
});
|
||||
|
||||
test("nnu", () => {
|
||||
it("nnu", () => {
|
||||
expect(nnu(0)).toBe(0);
|
||||
expect(nnu("")).toBe("");
|
||||
expect(nnu([])).toEqual([]);
|
||||
|
|
Loading…
Reference in a new issue