Skip to content

Commit

Permalink
added string & symbol unit tests (#59)
Browse files Browse the repository at this point in the history
* added string & symbol unit tests

* consistently renamed value to element in test directory
  • Loading branch information
kubikowski authored Nov 6, 2022
1 parent f77748b commit c5cea91
Show file tree
Hide file tree
Showing 34 changed files with 435 additions and 220 deletions.
6 changes: 3 additions & 3 deletions test/comparisons/disjoint.function.scale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
someDisjoint,
someEquivalent,
times,
} from '../constants/scale-testing.constants';
import { Timer } from '../constants/timer.model';
} from '../util/scale/scale-testing.constants';
import { Timer } from '../util/scale/timer.model';

export function disjointScaleTest(): void {
export function disjointScaleTests(): void {

describe('disjoint ⋅ large sets', () => {
it('disjoint(of1):'.padEnd(padding), () => {
Expand Down
27 changes: 19 additions & 8 deletions test/comparisons/disjoint.function.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { describe, expect, it } from '@jest/globals';
import { disjoint } from '../../src';
import { empty, setA, setB, setC, setD, setE, setF, universal } from '../constants/testing.constants';
import { NumberTestSets } from '../util/test-sets/number-test-sets.model';
import { StringTestSets } from '../util/test-sets/string-test-sets.model';
import { SymbolTestSets } from '../util/test-sets/symbol-test-sets.model';
import { TestSets } from '../util/test-sets/test-sets.model';

describe('disjoint', () => {
describe('disjoint ⋅ number', () => disjointTests(new NumberTestSets()));
describe('disjoint ⋅ string', () => disjointTests(new StringTestSets()));
describe('disjoint ⋅ symbol', () => disjointTests(new SymbolTestSets()));
});

function disjointTests<T>(testSets: TestSets<T>): void {
const { empty, setA, setB, setC, setD, setE, setF, universal } = testSets;

it('no sets are disjoint', () => {
expect(disjoint()).toBe(true);
});
Expand All @@ -19,15 +30,15 @@ describe('disjoint', () => {
expect(disjoint(setA, setA, setA)).toBe(false);
});

it('two sets with some shared values are not disjoint', () => {
it('two sets with some shared elements are not disjoint', () => {
expect(disjoint(setA, setB)).toBe(false);
});

it('three sets with some shared values are not disjoint', () => {
it('three sets with some shared elements are not disjoint', () => {
expect(disjoint(setA, setB, setC)).toBe(false);
});

it('many sets with some shared values are not disjoint', () => {
it('many sets with some shared elements are not disjoint', () => {
expect(disjoint(setA, setB, setC, setD, setE, setF)).toBe(false);
});

Expand All @@ -45,15 +56,15 @@ describe('disjoint', () => {

/* custom disjoint tests */

it('two sets with no shared values are disjoint', () => {
it('two sets with no shared elements are disjoint', () => {
expect(disjoint(setA, setD)).toBe(true);
});

it('many sets with no shared values are disjoint', () => {
it('many sets with no shared elements are disjoint', () => {
expect(disjoint(setA, setD, setE, setF)).toBe(true);
});

it('a set & many of another set with no shared values are disjoint', () => {
it('a set & many of another set with no shared elements are disjoint', () => {
expect(disjoint(setA, setD, setD, setD)).toBe(true);
});
});
}
6 changes: 3 additions & 3 deletions test/comparisons/equivalence.function.scale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
someDisjoint,
someEquivalent,
times,
} from '../constants/scale-testing.constants';
import { Timer } from '../constants/timer.model';
} from '../util/scale/scale-testing.constants';
import { Timer } from '../util/scale/timer.model';

export function equivalenceScaleTest(): void {
export function equivalenceScaleTests(): void {

describe('equivalence ⋅ large sets', () => {
it('equivalence(of1):'.padEnd(padding), () => {
Expand Down
15 changes: 13 additions & 2 deletions test/comparisons/equivalence.function.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { describe, expect, it } from '@jest/globals';
import { equivalence } from '../../src';
import { empty, minimal, setA, setB, setC, setD, setE, setF, universal } from '../constants/testing.constants';
import { NumberTestSets } from '../util/test-sets/number-test-sets.model';
import { StringTestSets } from '../util/test-sets/string-test-sets.model';
import { SymbolTestSets } from '../util/test-sets/symbol-test-sets.model';
import { TestSets } from '../util/test-sets/test-sets.model';

describe('equivalence', () => {
describe('equivalence ⋅ number', () => equivalenceTests(new NumberTestSets()));
describe('equivalence ⋅ string', () => equivalenceTests(new StringTestSets()));
describe('equivalence ⋅ symbol', () => equivalenceTests(new SymbolTestSets()));
});

function equivalenceTests<T>(testSets: TestSets<T>): void {
const { empty, minimal, setA, setB, setC, setD, setE, setF, universal } = testSets;

it('no sets are equivalent', () => {
expect(equivalence()).toBe(true);
});
Expand Down Expand Up @@ -48,4 +59,4 @@ describe('equivalence', () => {
it('two sets with different cardinalities are not equivalent', () => {
expect(equivalence(setA, minimal)).toBe(false);
});
});
}
6 changes: 3 additions & 3 deletions test/comparisons/pairwise-disjoint.function.scale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
someDisjoint,
someEquivalent,
times,
} from '../constants/scale-testing.constants';
import { Timer } from '../constants/timer.model';
} from '../util/scale/scale-testing.constants';
import { Timer } from '../util/scale/timer.model';

export function pairwiseDisjointScaleTest(): void {
export function pairwiseDisjointScaleTests(): void {

describe('pairwise disjoint ⋅ large sets', () => {
it('pairwiseDisjoint(of1):'.padEnd(padding), () => {
Expand Down
27 changes: 19 additions & 8 deletions test/comparisons/pairwise-disjoint.function.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { describe, expect, it } from '@jest/globals';
import { pairwiseDisjoint } from '../../src';
import { empty, setA, setB, setC, setD, setE, setF, universal } from '../constants/testing.constants';
import { NumberTestSets } from '../util/test-sets/number-test-sets.model';
import { StringTestSets } from '../util/test-sets/string-test-sets.model';
import { SymbolTestSets } from '../util/test-sets/symbol-test-sets.model';
import { TestSets } from '../util/test-sets/test-sets.model';

describe('pairwise disjoint', () => {
describe('pairwise disjoint ⋅ number', () => pairwiseDisjointTests(new NumberTestSets()));
describe('pairwise disjoint ⋅ string', () => pairwiseDisjointTests(new StringTestSets()));
describe('pairwise disjoint ⋅ symbol', () => pairwiseDisjointTests(new SymbolTestSets()));
});

function pairwiseDisjointTests<T>(testSets: TestSets<T>): void {
const { empty, setA, setB, setC, setD, setE, setF, universal } = testSets;

it('no sets are pairwise disjoint', () => {
expect(pairwiseDisjoint()).toBe(true);
});
Expand All @@ -19,15 +30,15 @@ describe('pairwise disjoint', () => {
expect(pairwiseDisjoint(setA, setA, setA)).toBe(false);
});

it('two sets with some shared values are not pairwise disjoint', () => {
it('two sets with some shared elements are not pairwise disjoint', () => {
expect(pairwiseDisjoint(setA, setB)).toBe(false);
});

it('three sets with some shared values are not pairwise disjoint', () => {
it('three sets with some shared elements are not pairwise disjoint', () => {
expect(pairwiseDisjoint(setA, setB, setC)).toBe(false);
});

it('many sets with some shared values are not pairwise disjoint', () => {
it('many sets with some shared elements are not pairwise disjoint', () => {
expect(pairwiseDisjoint(setA, setB, setC, setD, setE, setF)).toBe(false);
});

Expand All @@ -45,15 +56,15 @@ describe('pairwise disjoint', () => {

/* custom pairwise disjoint tests */

it('two sets with no shared values are pairwise disjoint', () => {
it('two sets with no shared elements are pairwise disjoint', () => {
expect(pairwiseDisjoint(setA, setD)).toBe(true);
});

it('many sets with no shared values are pairwise disjoint', () => {
it('many sets with no shared elements are pairwise disjoint', () => {
expect(pairwiseDisjoint(setA, setD, setE, setF)).toBe(true);
});

it('a set & many of another set with no shared values are not pairwise disjoint', () => {
it('a set & many of another set with no shared elements are not pairwise disjoint', () => {
expect(pairwiseDisjoint(setA, setD, setD, setD)).toBe(false);
});
});
}
6 changes: 3 additions & 3 deletions test/comparisons/proper-subset.function.scale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
someDisjoint,
someEquivalent,
times,
} from '../constants/scale-testing.constants';
import { Timer } from '../constants/timer.model';
} from '../util/scale/scale-testing.constants';
import { Timer } from '../util/scale/timer.model';

export function properSubsetScaleTest(): void {
export function properSubsetScaleTests(): void {

describe('proper subset ⋅ large sets', () => {
it('properSubset(of1):'.padEnd(padding), () => {
Expand Down
23 changes: 17 additions & 6 deletions test/comparisons/proper-subset.function.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { describe, expect, it } from '@jest/globals';
import { properSubset } from '../../src';
import { empty, minimal, setA, setB, setC, setD, setE, setF, universal } from '../constants/testing.constants';
import { NumberTestSets } from '../util/test-sets/number-test-sets.model';
import { StringTestSets } from '../util/test-sets/string-test-sets.model';
import { SymbolTestSets } from '../util/test-sets/symbol-test-sets.model';
import { TestSets } from '../util/test-sets/test-sets.model';

describe('proper subset', () => {
describe('proper subset ⋅ number', () => properSubsetTests(new NumberTestSets()));
describe('proper subset ⋅ string', () => properSubsetTests(new StringTestSets()));
describe('proper subset ⋅ symbol', () => properSubsetTests(new SymbolTestSets()));
});

function properSubsetTests<T>(testSets: TestSets<T>): void {
const { empty, minimal, setA, setB, setC, setD, setE, setF, universal } = testSets;

it('no sets are proper subsets', () => {
expect(properSubset()).toBe(true);
});
Expand All @@ -19,15 +30,15 @@ describe('proper subset', () => {
expect(properSubset(setA, setA, setA)).toBe(false);
});

it('two sets with different values are not proper subsets', () => {
it('two sets with different elements are not proper subsets', () => {
expect(properSubset(setA, setB)).toBe(false);
});

it('three sets with different values are not proper subsets', () => {
it('three sets with different elements are not proper subsets', () => {
expect(properSubset(setA, setB, setC)).toBe(false);
});

it('many sets with different values are not proper subsets', () => {
it('many sets with different elements are not proper subsets', () => {
expect(properSubset(setA, setB, setC, setD, setE, setF)).toBe(false);
});

Expand All @@ -49,11 +60,11 @@ describe('proper subset', () => {
expect(properSubset(setA, minimal)).toBe(false);
});

it('sets without value bijection are not proper subsets', () => {
it('sets without element bijection are not proper subsets', () => {
expect(properSubset(setD, setA)).toBe(false);
});

it('the empty set is a proper subset of every non-empty set', () => {
expect(properSubset(empty, minimal, setA, setB, setC, universal)).toBe(true);
});
});
}
6 changes: 3 additions & 3 deletions test/comparisons/proper-superset.function.scale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
someDisjoint,
someEquivalent,
times,
} from '../constants/scale-testing.constants';
import { Timer } from '../constants/timer.model';
} from '../util/scale/scale-testing.constants';
import { Timer } from '../util/scale/timer.model';

export function properSupersetScaleTest(): void {
export function properSupersetScaleTests(): void {

describe('proper superset ⋅ large sets', () => {
it('properSuperset(of1):'.padEnd(padding), () => {
Expand Down
23 changes: 17 additions & 6 deletions test/comparisons/proper-superset.function.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { describe, expect, it } from '@jest/globals';
import { properSuperset } from '../../src';
import { empty, minimal, setA, setB, setC, setD, setE, setF, universal } from '../constants/testing.constants';
import { NumberTestSets } from '../util/test-sets/number-test-sets.model';
import { StringTestSets } from '../util/test-sets/string-test-sets.model';
import { SymbolTestSets } from '../util/test-sets/symbol-test-sets.model';
import { TestSets } from '../util/test-sets/test-sets.model';

describe('proper superset', () => {
describe('proper superset ⋅ number', () => properSupersetTests(new NumberTestSets()));
describe('proper superset ⋅ string', () => properSupersetTests(new StringTestSets()));
describe('proper superset ⋅ symbol', () => properSupersetTests(new SymbolTestSets()));
});

function properSupersetTests<T>(testSets: TestSets<T>): void {
const { empty, minimal, setA, setB, setC, setD, setE, setF, universal } = testSets;

it('no sets are proper supersets', () => {
expect(properSuperset()).toBe(true);
});
Expand All @@ -19,15 +30,15 @@ describe('proper superset', () => {
expect(properSuperset(setA, setA, setA)).toBe(false);
});

it('two sets with different values are not proper supersets', () => {
it('two sets with different elements are not proper supersets', () => {
expect(properSuperset(setA, setB)).toBe(false);
});

it('three sets with different values are not proper supersets', () => {
it('three sets with different elements are not proper supersets', () => {
expect(properSuperset(setA, setB, setC)).toBe(false);
});

it('many sets with different values are not proper supersets', () => {
it('many sets with different elements are not proper supersets', () => {
expect(properSuperset(setA, setB, setC, setD, setE, setF)).toBe(false);
});

Expand All @@ -49,11 +60,11 @@ describe('proper superset', () => {
expect(properSuperset(minimal, setA)).toBe(false);
});

it('sets without value bijection are not proper supersets', () => {
it('sets without element bijection are not proper supersets', () => {
expect(properSuperset(setA, setD)).toBe(false);
});

it('the universal set is a proper superset of every non-universal set', () => {
expect(properSuperset(universal, setA, setB, setC, minimal, empty)).toBe(true);
});
});
}
6 changes: 3 additions & 3 deletions test/comparisons/subset.function.scale.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
someDisjoint,
someEquivalent,
times,
} from '../constants/scale-testing.constants';
import { Timer } from '../constants/timer.model';
} from '../util/scale/scale-testing.constants';
import { Timer } from '../util/scale/timer.model';

export function subsetScaleTest(): void {
export function subsetScaleTests(): void {

describe('subset ⋅ large sets', () => {
it('subset(of1):'.padEnd(padding), () => {
Expand Down
23 changes: 17 additions & 6 deletions test/comparisons/subset.function.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { describe, expect, it } from '@jest/globals';
import { subset } from '../../src';
import { empty, minimal, setA, setB, setC, setD, setE, setF, universal } from '../constants/testing.constants';
import { NumberTestSets } from '../util/test-sets/number-test-sets.model';
import { StringTestSets } from '../util/test-sets/string-test-sets.model';
import { SymbolTestSets } from '../util/test-sets/symbol-test-sets.model';
import { TestSets } from '../util/test-sets/test-sets.model';

describe('subset', () => {
describe('subset ⋅ number', () => subsetTests(new NumberTestSets()));
describe('subset ⋅ string', () => subsetTests(new StringTestSets()));
describe('subset ⋅ symbol', () => subsetTests(new SymbolTestSets()));
});

function subsetTests<T>(testSets: TestSets<T>): void {
const { empty, minimal, setA, setB, setC, setD, setE, setF, universal } = testSets;

it('no sets are subsets', () => {
expect(subset()).toBe(true);
});
Expand All @@ -19,15 +30,15 @@ describe('subset', () => {
expect(subset(setA, setA, setA)).toBe(true);
});

it('two sets with different values are not subsets', () => {
it('two sets with different elements are not subsets', () => {
expect(subset(setA, setB)).toBe(false);
});

it('three sets with different values are not subsets', () => {
it('three sets with different elements are not subsets', () => {
expect(subset(setA, setB, setC)).toBe(false);
});

it('many sets with different values are not subsets', () => {
it('many sets with different elements are not subsets', () => {
expect(subset(setA, setB, setC, setD, setE, setF)).toBe(false);
});

Expand All @@ -49,11 +60,11 @@ describe('subset', () => {
expect(subset(setA, minimal)).toBe(false);
});

it('sets without value bijection are not subsets', () => {
it('sets without element bijection are not subsets', () => {
expect(subset(setD, setA)).toBe(false);
});

it('the empty set is a subset of every set', () => {
expect(subset(empty, minimal, setA, setB, setC, universal)).toBe(true);
});
});
}
Loading

0 comments on commit c5cea91

Please sign in to comment.