import { expect, test } from "./deps.test.ts"; import { always, and, never, not, or } from "./predicates.ts"; test("always", () => { expect(always()).toBe(true); expect(always(true)).toBe(true); expect(always(false)).toBe(true); }); test("never", () => { expect(never()).toBe(false); expect(never(true)).toBe(false); expect(never(false)).toBe(false); }); test("not", () => { const iseven = (x: number) => x % 2 == 0; const isodd = not(iseven); expect(iseven(0)).toBe(true); expect(isodd(0)).toBe(false); expect(iseven(1)).toBe(false); expect(isodd(1)).toBe(true); expect(iseven(2)).toBe(true); expect(isodd(2)).toBe(false); }); test("and", () => { const f = and((x: number) => x % 2 == 0, (x: number) => x > 5); expect(f(0)).toBe(false); expect(f(2)).toBe(false); expect(f(8)).toBe(true); expect(f(9)).toBe(false); expect(f(10)).toBe(true); }); test("or", () => { const f = or((x: number) => x % 2 == 0, (x: number) => x > 5); expect(f(0)).toBe(true); expect(f(1)).toBe(false); expect(f(2)).toBe(true); expect(f(8)).toBe(true); expect(f(9)).toBe(true); });