@@ -2,31 +2,30 @@ import * as t from 'io-ts';
2
2
import { Fuzzer , ConcreteFuzzer , fuzzGenerator } from '../fuzzer' ;
3
3
4
4
export type BasicType =
5
+ | t . NumberType
6
+ | t . BooleanType
7
+ | t . StringType
5
8
| t . NullType
6
9
| t . UndefinedType
7
10
| t . VoidType
8
11
| t . UnknownType
9
- | t . StringType
10
- | t . NumberType
11
- | t . BooleanType
12
+ | t . UnionType < t . Mixed [ ] >
13
+ | t . InterfaceType < unknown >
14
+ | t . PartialType < unknown >
15
+ | t . ArrayType < t . Mixed >
16
+ | t . IntersectionType < t . Mixed [ ] >
17
+ | t . LiteralType < string | number | boolean >
18
+ | t . KeyofType < { [ key : string ] : unknown } >
19
+ | t . TupleType < t . Mixed [ ] >
20
+ // not yet supported:
12
21
| t . AnyArrayType
13
22
| t . AnyDictionaryType
14
23
| t . RefinementType < t . Mixed >
15
- | t . LiteralType < string | number | boolean >
16
- | t . KeyofType < { [ key : string ] : unknown } >
17
24
| t . RecursiveType < t . Mixed >
18
- | t . ArrayType < t . Mixed >
19
- | t . InterfaceType < unknown >
20
- | t . PartialType < unknown >
21
25
| t . DictionaryType < t . Mixed , t . Mixed >
22
- | t . UnionType < t . Mixed [ ] >
23
- | t . IntersectionType < t . Mixed [ ] >
24
- | t . InterfaceType < unknown >
25
- | t . TupleType < t . Mixed [ ] >
26
26
| t . ReadonlyType < t . Mixed >
27
27
| t . ReadonlyArrayType < t . Mixed >
28
- | t . ExactType < t . Mixed >
29
- | t . UnknownType ;
28
+ | t . ExactType < t . Mixed > ;
30
29
31
30
export type basicFuzzGenerator <
32
31
T ,
@@ -162,6 +161,17 @@ export function fuzzInterface(
162
161
} ;
163
162
}
164
163
164
+ export function fuzzTuple (
165
+ b : t . TupleType < t . Mixed [ ] >
166
+ ) : ConcreteFuzzer < unknown [ ] > {
167
+ return {
168
+ children : b . types ,
169
+ func : ( n , ...h ) => {
170
+ return h . map ( ( v , i ) => v . encode ( n + i ) ) ;
171
+ } ,
172
+ } ;
173
+ }
174
+
165
175
export const defaultMaxArrayLength = 13 ;
166
176
167
177
const fuzzArrayWithMaxLength = ( maxLength : number = defaultMaxArrayLength ) => (
@@ -228,7 +238,6 @@ export function fuzzIntersection(
228
238
229
239
export const coreFuzzers = [
230
240
concrete ( fuzzNumber , 'NumberType' ) ,
231
- concreteNamed ( fuzzInt , 'Int' ) ,
232
241
concrete ( fuzzBoolean , 'BooleanType' ) ,
233
242
concrete ( fuzzString , 'StringType' ) ,
234
243
concrete ( fuzzNull , 'NullType' ) ,
@@ -242,4 +251,6 @@ export const coreFuzzers = [
242
251
gen ( fuzzIntersection , 'IntersectionType' ) ,
243
252
gen ( fuzzLiteral , 'LiteralType' ) ,
244
253
gen ( fuzzKeyof , 'KeyofType' ) ,
254
+ gen ( fuzzTuple , 'TupleType' ) ,
255
+ concreteNamed ( fuzzInt , 'Int' ) ,
245
256
] ;
0 commit comments