Skip to content

refactor(library/math): separates concerns of "number taxonomy" from isOperable test suite #539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
26 changes: 26 additions & 0 deletions src/library/math/numberTaxonomy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** Examples from each classification of number */
const numberTaxonomy = {
signed: {
negative: -1,
positive: +1,
},
fractional: {
rational : 1 / 2,
irrational : Math.PI,
transcendental: Math.E,
},
infinite: {
positive: Infinity,
negative: -Infinity,
},
runtime: {
min: Number.MIN_VALUE,
max: Number.MAX_VALUE,
},
origin : 0,
undefined: NaN,
} as const;

export {
numberTaxonomy,
};
48 changes: 15 additions & 33 deletions src/library/math/operator/predicate/isOperable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,28 @@ import {
expect,
} from 'vitest';

import {
numberTaxonomy,
} from '../../numberTaxonomy';

import {
isOperable,
} from './isOperable';

const numericCategory = {
signed: {
negative: /**/-1,
positive: /**/+1,
},
fractional: {
rational : 1 / 2,
irrational : Math.PI,
transcendental: Math.E,
},
infinite: {
positive: Infinity,
negative: -Infinity,
},
runtime: {
min: Number.MIN_VALUE,
max: Number.MAX_VALUE,
},
origin : 0,
undefined: NaN,
} as const;

describe(isOperable, () => {
const theSoleInoperableNumber = numericCategory.undefined;
const theSoleInoperableNumber = numberTaxonomy.undefined;

const operableNumbers = [
numericCategory.origin,
numericCategory.signed.negative,
numericCategory.signed.positive,
numericCategory.fractional.rational,
numericCategory.fractional.irrational,
numericCategory.fractional.transcendental,
numericCategory.infinite.positive,
numericCategory.infinite.negative,
numericCategory.runtime.min,
numericCategory.runtime.max,
numberTaxonomy.origin,
numberTaxonomy.signed.negative,
numberTaxonomy.signed.positive,
numberTaxonomy.fractional.rational,
numberTaxonomy.fractional.irrational,
numberTaxonomy.fractional.transcendental,
numberTaxonomy.infinite.positive,
numberTaxonomy.infinite.negative,
numberTaxonomy.runtime.min,
numberTaxonomy.runtime.max,
];

describe('the guaranteed behavior', () => {
Expand Down