Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit 818a366

Browse files
committed
fix: randomize NonEmptyArray elements independently
1 parent 7e01e15 commit 818a366

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/experimental.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Fuzzer } from './fuzzer';
22
import * as t from 'io-ts';
33
import { NonEmptyArray, cons } from 'fp-ts/lib/NonEmptyArray';
4+
import { rng } from './rng';
45

56
/**
67
* @experimental 4.1.0 This will be superseded by a generic handler for NonEmptyArrays in io-ts-types when https://github.com/gcanti/io-ts-types/issues/102 is fixed.
@@ -14,7 +15,11 @@ export const nonEmptyArrayFuzzer = <T>(
1415
type: 'fuzzer',
1516
children: [c, t.array(c)],
1617
func: (ctx, n0, hc, ha) => {
17-
return cons(hc.encode([n0, ctx]) as T, ha.encode([n0, ctx]) as T[]);
18+
const r = rng(n0);
19+
return cons(
20+
hc.encode([r.int32(), ctx]) as T,
21+
ha.encode([r.int32(), ctx]) as T[]
22+
);
1823
},
1924
},
2025
});

0 commit comments

Comments
 (0)