Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/combinator/src/a/a.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { apply } from '.';

const addSix = (a: number) => a + 6;

it('should apply the function to the given value', () => {
expect(apply(addSix)(3)).toEqual(9);
describe('A Combinator', () => {
it('should apply the function to the given value', () => {
expect(apply(addSix)(3)).toEqual(9);
});
});
8 changes: 5 additions & 3 deletions packages/combinator/src/b/b.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { compose } from '.';

const addEight = (a: number) => a + 8;
const timesThree = (a: number) => a * 3;

it('should correctly compose the functions', () => {
expect(compose(addEight)(timesThree)(4)).toEqual(20);
describe('B Combinator', () => {
it('should correctly compose the functions', () => {
expect(compose(addEight)(timesThree)(4)).toEqual(20);
});
});
8 changes: 5 additions & 3 deletions packages/combinator/src/bl/bl.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { BL } from '.';

const add = (a: number) => (b: number) => a + b;
const double = (x: number) => x * 2;

it('should compose binary function with unary', () => {
expect(BL(double)(add)(3)(4)).toEqual(14); // double(add(3)(4))
describe('B1 Combinator', () => {
it('should compose binary function with unary', () => {
expect(BL(double)(add)(3)(4)).toEqual(14); // double(add(3)(4))
});
});
12 changes: 7 additions & 5 deletions packages/combinator/src/c/c.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { C } from '.';

const subtract = (a: number) => (b: number) => a - b;

it('should swap argument order', () => {
const flipped = C(subtract);
expect(flipped(3)(10)).toEqual(7); // 10 - 3, not 3 - 10
expect(subtract(10)(3)).toEqual(7); // Verify original behavior
describe('C Combinator', () => {
it('should swap argument order', () => {
const flipped = C(subtract);
expect(flipped(3)(10)).toEqual(7); // 10 - 3, not 3 - 10
expect(subtract(10)(3)).toEqual(7); // Verify original behavior
});
});
12 changes: 7 additions & 5 deletions packages/combinator/src/i/i.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { identity } from '.';

const addThree = (a: number) => a + 3;

it('should always return the value, unchanged', () => {
expect(identity(1)).toEqual(1);
expect(identity(addThree)).toEqual(addThree);
expect(identity('test')).toEqual('test');
describe('I Combinator', () => {
it('should always return the value, unchanged', () => {
expect(identity(1)).toEqual(1);
expect(identity(addThree)).toEqual(addThree);
expect(identity('test')).toEqual('test');
});
});
12 changes: 7 additions & 5 deletions packages/combinator/src/k/k.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { constant } from '.';

it('should always return the first value', () => {
expect(constant(1)(2)).toEqual(1);
expect(constant(9)(7)).toEqual(9);
expect(constant(4)(8)).toEqual(4);
describe('K Combinator', () => {
it('should always return the first value', () => {
expect(constant(1)(2)).toEqual(1);
expect(constant(9)(7)).toEqual(9);
expect(constant(4)(8)).toEqual(4);
});
});
12 changes: 7 additions & 5 deletions packages/combinator/src/ki/ki.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { second } from '.';

it('should always return the second value', () => {
expect(second(1)(2)).toEqual(2);
expect(second(9)(7)).toEqual(7);
expect(second(4)(8)).toEqual(8);
describe('KI Combinator', () => {
it('should always return the second value', () => {
expect(second(1)(2)).toEqual(2);
expect(second(9)(7)).toEqual(7);
expect(second(4)(8)).toEqual(8);
});
});
8 changes: 5 additions & 3 deletions packages/combinator/src/phi/phi.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { fork } from '.';

const add = (a: number) => (b: number) => a + b;
const addThree = (a: number) => a + 3;
const minusTwo = (a: number) => a - 2;

it('should correctly compose the two unary functions and the binary function', () => {
expect(fork(add)(addThree)(minusTwo)(9)).toEqual(19);
describe('Phi Combinator', () => {
it('should correctly compose the two unary functions and the binary function', () => {
expect(fork(add)(addThree)(minusTwo)(9)).toEqual(19);
});
});
8 changes: 5 additions & 3 deletions packages/combinator/src/psi/psi.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { Psi } from '.';

const add = (a: number) => (b: number) => a + b;
const square = (x: number) => x * x;

it('should apply function to both transformed arguments', () => {
expect(Psi(add)(square)(3)(4)).toEqual(25); // 3² + 4² = 9 + 16
describe('Psi Combinator', () => {
it('should apply function to both transformed arguments', () => {
expect(Psi(add)(square)(3)(4)).toEqual(25); // 3² + 4² = 9 + 16
});
});
8 changes: 5 additions & 3 deletions packages/combinator/src/q/q.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { pipe } from '.';

const double = (x: number) => x * 2;
const addThree = (x: number) => x + 3;

it('should compose functions left-to-right', () => {
expect(pipe(double)(addThree)(5)).toEqual(13); // (5 * 2) + 3 = 13
describe('Q Combinator', () => {
it('should compose functions left-to-right', () => {
expect(pipe(double)(addThree)(5)).toEqual(13); // (5 * 2) + 3 = 13
});
});
2 changes: 1 addition & 1 deletion packages/combinator/src/readme.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
W,
} from '.';

describe('@certes/combinator - README Examples', () => {
describe('README Examples', () => {
describe('Quick Start', () => {
it('should compose functions right-to-left', () => {
const addThenDouble = compose((x: number) => x * 2)((x: number) => x + 3);
Expand Down
8 changes: 5 additions & 3 deletions packages/combinator/src/s/s.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { substitution } from '.';

const add = (a: number) => (b: number) => a + b;
const double = (x: number) => x * 2;

it('should distribute argument to both functions', () => {
expect(substitution(add)(double)(5)).toEqual(15); // 5 + double(5) = 5 + 10 = 15
describe('S Combinator', () => {
it('should distribute argument to both functions', () => {
expect(substitution(add)(double)(5)).toEqual(15); // 5 + double(5) = 5 + 10 = 15
});
});
10 changes: 10 additions & 0 deletions packages/combinator/src/th/t.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { describe, expect, it } from 'vitest';
import { applyTo } from '.';

const addSix = (a: number) => a + 6;

describe('T Combinator', () => {
it('should apply the value the given function', () => {
expect(applyTo(3)(addSix)).toEqual(9);
});
});
8 changes: 0 additions & 8 deletions packages/combinator/src/th/th.test.ts

This file was deleted.

8 changes: 5 additions & 3 deletions packages/combinator/src/v/v.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { V } from '.';

const multiply = (a: number) => (b: number) => a * b;

it('should pair arguments for function application', () => {
expect(V(3)(4)(multiply)).toEqual(12);
describe('V Combinator', () => {
it('should pair arguments for function application', () => {
expect(V(3)(4)(multiply)).toEqual(12);
});
});
8 changes: 5 additions & 3 deletions packages/combinator/src/w/w.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';
import { duplication } from '.';

const multiply = (a: number) => (b: number) => a * b;

it('should apply binary function to same argument twice', () => {
expect(duplication(multiply)(7)).toEqual(49); // 7 * 7 = 49
describe('W Combinator', () => {
it('should apply binary function to same argument twice', () => {
expect(duplication(multiply)(7)).toEqual(49); // 7 * 7 = 49
});
});
2 changes: 1 addition & 1 deletion packages/common/src/lookup/lookup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const defaultColor: Color = [128, 128, 128, 155];
const colorLookup = lookup(colorTable, defaultVal(defaultColor));
const undefLookup = lookup(colorTable);

describe('lookup', () => {
describe('Lookup', () => {
it('should return the selected value', () => {
const actualOne = colorLookup('NOPE');
const actualTwo = colorLookup('BUZZ');
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/once/once.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { once } from '.';

let globalVal = 10;

describe('once', () => {
describe('Once', () => {
beforeEach(() => {
globalVal = 10;
});
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/readme.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import { lookup, noop, once, tap } from '.';

describe('@certes/common - README Examples', () => {
describe('README Examples', () => {
describe('lookup', () => {
it('should lookup status codes with default handler', () => {
const statusCodes = {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/tap/tap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const tapper = (n: number) => {

const tapped = tap(tapper);

describe('tap', () => {
describe('Tap', () => {
beforeEach(() => {
sideEffect = 5;
});
Expand Down
Loading