@@ -4,30 +4,64 @@ import {
4
4
expect ,
5
5
} from 'vitest' ;
6
6
7
+ import {
8
+ numberTaxonomy ,
9
+ } from '../../numberTaxonomy' ;
10
+
7
11
import {
8
12
greatestCommonDivisor ,
9
13
} from './greatestCommonDivisor' ;
10
14
15
+ const pairCombos = <
16
+ LeftElement extends number ,
17
+ RightElement extends number ,
18
+ FillerElement extends number ,
19
+ > (
20
+ given : {
21
+ left : LeftElement ;
22
+ right : RightElement ;
23
+ filler : FillerElement ;
24
+ } ,
25
+ ) => [
26
+ [ given . left /* */ , given . filler /**/ ] ,
27
+ [ given . left /* */ , given . right /* */ ] ,
28
+ [ given . filler /**/ , given . right /* */ ] ,
29
+ ] as const ;
30
+
31
+ const symmetricPairCombos = <
32
+ SymmetricElement extends number ,
33
+ FillerElement extends number ,
34
+ > (
35
+ given : {
36
+ of : SymmetricElement ;
37
+ filler : FillerElement ;
38
+ } ,
39
+ ) => pairCombos ( {
40
+ left : given . of ,
41
+ right : given . of ,
42
+ filler : given . filler ,
43
+ } ) ;
44
+
11
45
describe ( greatestCommonDivisor , ( ) => {
12
46
describe ( 'the sad outcomes' , ( ) => {
13
47
describe ( 'when delegated' , ( ) => {
14
- const combosOfInoperableNumbers = [
15
- [ NaN , 100 ] ,
16
- [ NaN , NaN ] ,
17
- [ 100 , NaN ] ,
18
- ] as const ;
48
+ const primeA = 2 ;
49
+
50
+ const combosOfInoperableNumbers = symmetricPairCombos ( {
51
+ of : numberTaxonomy . undefined ,
52
+ filler : primeA ,
53
+ } ) ;
19
54
20
55
it . each ( combosOfInoperableNumbers ) ( 'should reject inoperable operands' , ( ...$0 ) => {
21
56
expect . assertions ( 1 ) ;
22
57
23
58
expect ( ( ) => greatestCommonDivisor ( ...$0 ) ) . toThrow ( Error ) ;
24
59
} ) ;
25
60
26
- const combosOfInfiniteNumbers = [
27
- [ Infinity , 10000000 ] ,
28
- [ Infinity , Infinity ] ,
29
- [ 10000000 , Infinity ] ,
30
- ] as const ;
61
+ const combosOfInfiniteNumbers = symmetricPairCombos ( {
62
+ of : numberTaxonomy . infinite . positive ,
63
+ filler : primeA ,
64
+ } ) ;
31
65
32
66
it . each ( combosOfInfiniteNumbers ) ( 'should reject infinite operands' , ( ...$0 ) => {
33
67
expect . assertions ( 1 ) ;
0 commit comments