@@ -14,9 +14,7 @@ import {
14
14
squared ,
15
15
} from '../hyper' ;
16
16
17
- import {
18
- greatestCommonDivisor ,
19
- } from './greatestCommonDivisor' ;
17
+ import * as GCDAlias from './greatestCommonDivisor' ;
20
18
21
19
const pairCombos = <
22
20
LeftElement extends number ,
@@ -48,7 +46,11 @@ const symmetricPairCombos = <
48
46
filler : given . filler ,
49
47
} ) ;
50
48
51
- describe ( greatestCommonDivisor , ( ) => {
49
+ const aliasKeys = Object . keys ( GCDAlias ) as ( keyof typeof GCDAlias ) [ ] ;
50
+
51
+ describe . each ( aliasKeys ) ( `${ GCDAlias . default . name } alias: "%s"` , ( eachAliasKey ) => {
52
+ const eachAliasedGCD = GCDAlias [ eachAliasKey ] ; // eslint-disable-line import/namespace
53
+
52
54
const singleDigitPrimes = [ 2 , 3 , 5 , 7 ] as const ;
53
55
54
56
const [
@@ -67,7 +69,7 @@ describe(greatestCommonDivisor, () => {
67
69
it . each ( combosOfInoperableNumbers ) ( 'should reject inoperable operands' , ( ...$0 ) => {
68
70
expect . assertions ( 1 ) ;
69
71
70
- expect ( ( ) => greatestCommonDivisor ( ...$0 ) ) . toThrow ( Error ) ;
72
+ expect ( ( ) => eachAliasedGCD ( ...$0 ) ) . toThrow ( Error ) ;
71
73
} ) ;
72
74
73
75
const combosOfInfiniteNumbers = symmetricPairCombos ( {
@@ -78,7 +80,7 @@ describe(greatestCommonDivisor, () => {
78
80
it . each ( combosOfInfiniteNumbers ) ( 'should reject infinite operands' , ( ...$0 ) => {
79
81
expect . assertions ( 1 ) ;
80
82
81
- expect ( ( ) => greatestCommonDivisor ( ...$0 ) ) . toThrow ( Error ) ;
83
+ expect ( ( ) => eachAliasedGCD ( ...$0 ) ) . toThrow ( Error ) ;
82
84
} ) ;
83
85
} ) ;
84
86
@@ -94,13 +96,13 @@ describe(greatestCommonDivisor, () => {
94
96
it . each ( combosOfFractionalNumbers ) ( 'should reject them' , ( ...$0 ) => {
95
97
expect . assertions ( 1 ) ;
96
98
97
- expect ( ( ) => greatestCommonDivisor ( ...$0 ) ) . toThrow ( Error ) ;
99
+ expect ( ( ) => eachAliasedGCD ( ...$0 ) ) . toThrow ( Error ) ;
98
100
} ) ;
99
101
100
102
it . each ( combosOfFractionalNumbers ) ( 'should safely propagate the error' , ( ...$0 ) => {
101
103
expect . assertions ( 1 ) ;
102
104
103
- expect ( ( ) => greatestCommonDivisor ( ...$0 ) ) . toThrow ( Attempt . NonActionableError ) ;
105
+ expect ( ( ) => eachAliasedGCD ( ...$0 ) ) . toThrow ( Attempt . NonActionableError ) ;
104
106
} ) ;
105
107
106
108
const fractionalCombosWithMessage = [
@@ -121,7 +123,7 @@ describe(greatestCommonDivisor, () => {
121
123
it . each ( fractionalCombosWithMessage ) ( 'should communicate clearly with developers' , ( $0 ) => {
122
124
expect . assertions ( 1 ) ;
123
125
124
- expect ( ( ) => greatestCommonDivisor ( ...$0 . numbers ) ) . toThrow ( $0 . message ) ;
126
+ expect ( ( ) => eachAliasedGCD ( ...$0 . numbers ) ) . toThrow ( $0 . message ) ;
125
127
} ) ;
126
128
} ) ;
127
129
} ) ;
@@ -131,7 +133,7 @@ describe(greatestCommonDivisor, () => {
131
133
it ( 'should accept valid operands' , ( ) => {
132
134
expect . assertions ( 1 ) ;
133
135
134
- expect ( ( ) => greatestCommonDivisor ( primeA , primeB ) ) . not . toThrow ( ) ;
136
+ expect ( ( ) => eachAliasedGCD ( primeA , primeB ) ) . not . toThrow ( ) ;
135
137
} ) ;
136
138
137
139
const combosOfSignedIdentityFactors = symmetricPairCombos ( {
@@ -145,22 +147,22 @@ describe(greatestCommonDivisor, () => {
145
147
const signedA = eachComboOfSignedIdentityFactors [ 0 ] * primeA ;
146
148
const signedB = eachComboOfSignedIdentityFactors [ 1 ] * primeB ;
147
149
148
- expect ( /* */ greatestCommonDivisor ( /**/ signedA , /**/ signedB ) )
149
- . toBe ( /**/ greatestCommonDivisor ( /* */ primeA , /* */ primeB ) ) ;
150
+ expect ( /* */ eachAliasedGCD ( /**/ signedA , /**/ signedB ) )
151
+ . toBe ( /**/ eachAliasedGCD ( /* */ primeA , /* */ primeB ) ) ;
150
152
} ) ;
151
153
152
154
it ( 'should be commutative' , ( ) => {
153
155
expect . assertions ( 1 ) ;
154
156
155
- expect ( /* */ greatestCommonDivisor ( primeA , primeB ) )
156
- . toBe ( /**/ greatestCommonDivisor ( primeB , primeA ) ) ;
157
+ expect ( /* */ eachAliasedGCD ( primeA , primeB ) )
158
+ . toBe ( /**/ eachAliasedGCD ( primeB , primeA ) ) ;
157
159
} ) ;
158
160
159
161
it ( 'should be associative' , ( ) => {
160
162
expect . assertions ( 1 ) ;
161
163
162
- expect ( /* */ greatestCommonDivisor ( greatestCommonDivisor ( primeA , primeB ) , primeC ) )
163
- . toBe ( /**/ greatestCommonDivisor ( greatestCommonDivisor ( primeB , primeC ) , primeA ) ) ;
164
+ expect ( /* */ eachAliasedGCD ( eachAliasedGCD ( primeA , primeB ) , primeC ) )
165
+ . toBe ( /**/ eachAliasedGCD ( eachAliasedGCD ( primeB , primeC ) , primeA ) ) ;
164
166
} ) ;
165
167
166
168
const combosOfTogglingFactors = [
@@ -173,7 +175,7 @@ describe(greatestCommonDivisor, () => {
173
175
expect . assertions ( 1 ) ;
174
176
175
177
expect (
176
- greatestCommonDivisor (
178
+ eachAliasedGCD (
177
179
primeA * eachComboOfTogglingFactors [ 0 ] ,
178
180
primeA * eachComboOfTogglingFactors [ 1 ] ,
179
181
) ,
@@ -185,7 +187,7 @@ describe(greatestCommonDivisor, () => {
185
187
it ( 'should preserve the identity of matching operands' , ( ) => {
186
188
expect . assertions ( 1 ) ;
187
189
188
- expect ( greatestCommonDivisor ( primeA , primeA ) ) . toBe ( primeA ) ;
190
+ expect ( eachAliasedGCD ( primeA , primeA ) ) . toBe ( primeA ) ;
189
191
} ) ;
190
192
191
193
const identityFactor = 1 ;
@@ -204,7 +206,7 @@ describe(greatestCommonDivisor, () => {
204
206
expect . assertions ( 1 ) ;
205
207
206
208
expect (
207
- greatestCommonDivisor (
209
+ eachAliasedGCD (
208
210
identityFactor * eachCoPrimePair [ 0 ] ,
209
211
identityFactor * eachCoPrimePair [ 1 ] ,
210
212
) ,
@@ -232,7 +234,7 @@ describe(greatestCommonDivisor, () => {
232
234
expect . assertions ( 1 ) ;
233
235
234
236
expect (
235
- greatestCommonDivisor (
237
+ eachAliasedGCD (
236
238
eachCommonFactor * eachComboOfNonComposites [ 0 ] ,
237
239
eachCommonFactor * eachComboOfNonComposites [ 1 ] ,
238
240
) ,
0 commit comments