@fncts/test 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_cjs/api.cjs +5 -5
- package/_cjs/api.cjs.map +1 -1
- package/_cjs/control/AbstractRunnableSpec.cjs +1 -1
- package/_cjs/control/AbstractRunnableSpec.cjs.map +1 -1
- package/_cjs/control/Assertion/api.cjs +6 -5
- package/_cjs/control/Assertion/api.cjs.map +1 -1
- package/_cjs/control/DefaultTestReporter/render.cjs +1 -1
- package/_cjs/control/DefaultTestReporter/render.cjs.map +1 -1
- package/_cjs/control/Gen/api.cjs +216 -78
- package/_cjs/control/Gen/api.cjs.map +1 -1
- package/_cjs/control/Live/definition.cjs +9 -8
- package/_cjs/control/Live/definition.cjs.map +1 -1
- package/_cjs/control/Sample/api.cjs +16 -16
- package/_cjs/control/Sample/api.cjs.map +1 -1
- package/_cjs/control/Spec/api.cjs +7 -7
- package/_cjs/control/Spec/api.cjs.map +1 -1
- package/_cjs/control/TestAnnotationRenderer/api.cjs +6 -5
- package/_cjs/control/TestAnnotationRenderer/api.cjs.map +1 -1
- package/_cjs/control/TestAspect/api.cjs +2 -3
- package/_cjs/control/TestAspect/api.cjs.map +1 -1
- package/_cjs/control/TestClock/definition.cjs +6 -6
- package/_cjs/control/TestClock/definition.cjs.map +1 -1
- package/_cjs/data/AssertionResult.cjs +3 -2
- package/_cjs/data/AssertionResult.cjs.map +1 -1
- package/_cjs/data/AssertionValue/definition.cjs +2 -1
- package/_cjs/data/AssertionValue/definition.cjs.map +1 -1
- package/_cjs/data/FreeBooleanAlgebra/api.cjs +5 -4
- package/_cjs/data/FreeBooleanAlgebra/api.cjs.map +1 -1
- package/_cjs/data/TestAnnotation/api.cjs +3 -2
- package/_cjs/data/TestAnnotation/api.cjs.map +1 -1
- package/_cjs/demo.cjs +1 -1
- package/_mjs/api.mjs +5 -5
- package/_mjs/api.mjs.map +1 -1
- package/_mjs/control/AbstractRunnableSpec.mjs +1 -1
- package/_mjs/control/AbstractRunnableSpec.mjs.map +1 -1
- package/_mjs/control/Assertion/api.mjs +6 -5
- package/_mjs/control/Assertion/api.mjs.map +1 -1
- package/_mjs/control/DefaultTestReporter/render.mjs +1 -1
- package/_mjs/control/DefaultTestReporter/render.mjs.map +1 -1
- package/_mjs/control/Gen/api.mjs +198 -71
- package/_mjs/control/Gen/api.mjs.map +1 -1
- package/_mjs/control/Live/definition.mjs +8 -7
- package/_mjs/control/Live/definition.mjs.map +1 -1
- package/_mjs/control/Sample/api.mjs +16 -16
- package/_mjs/control/Sample/api.mjs.map +1 -1
- package/_mjs/control/Spec/api.mjs +7 -7
- package/_mjs/control/Spec/api.mjs.map +1 -1
- package/_mjs/control/TestAnnotationRenderer/api.mjs +6 -5
- package/_mjs/control/TestAnnotationRenderer/api.mjs.map +1 -1
- package/_mjs/control/TestAspect/api.mjs +2 -3
- package/_mjs/control/TestAspect/api.mjs.map +1 -1
- package/_mjs/control/TestClock/definition.mjs +6 -6
- package/_mjs/control/TestClock/definition.mjs.map +1 -1
- package/_mjs/data/AssertionResult.mjs +3 -2
- package/_mjs/data/AssertionResult.mjs.map +1 -1
- package/_mjs/data/AssertionValue/definition.mjs +2 -1
- package/_mjs/data/AssertionValue/definition.mjs.map +1 -1
- package/_mjs/data/FreeBooleanAlgebra/api.mjs +5 -4
- package/_mjs/data/FreeBooleanAlgebra/api.mjs.map +1 -1
- package/_mjs/data/TestAnnotation/api.mjs +3 -2
- package/_mjs/data/TestAnnotation/api.mjs.map +1 -1
- package/_mjs/demo.mjs +1 -1
- package/_src/api.ts +1 -1
- package/_src/control/Gen/api.ts +166 -1
- package/_src/control/Live/definition.ts +8 -9
- package/_src/control/TestAspect/api.ts +2 -2
- package/_src/demo.ts +1 -1
- package/api.d.ts +1 -1
- package/control/Gen/api.d.ts +46 -1
- package/control/Live/definition.d.ts +6 -2
- package/package.json +3 -3
package/_mjs/control/Gen/api.mjs
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
const fileName_1 = "(@fncts/test) src/control/Gen/api.ts";
|
2
|
-
import * as tsplus_module_1 from "@fncts/
|
3
|
-
import * as tsplus_module_2 from "@fncts/
|
4
|
-
import * as tsplus_module_3 from "@fncts/
|
5
|
-
import * as tsplus_module_4 from "@fncts/
|
6
|
-
import * as tsplus_module_5 from "@fncts/
|
7
|
-
import * as tsplus_module_6 from "@fncts/
|
8
|
-
import * as tsplus_module_7 from "@fncts/
|
9
|
-
import * as tsplus_module_8 from "@fncts/base/
|
10
|
-
import * as tsplus_module_9 from "@fncts/
|
11
|
-
import * as tsplus_module_10 from "@fncts/base/collection/immutable/Conc/api/
|
12
|
-
import * as tsplus_module_11 from "@fncts/base/
|
13
|
-
import * as tsplus_module_12 from "@fncts/base/
|
14
|
-
import * as tsplus_module_13 from "@fncts/base/
|
15
|
-
import * as tsplus_module_14 from "@fncts/base/
|
16
|
-
import * as tsplus_module_15 from "@fncts/base/
|
17
|
-
import * as tsplus_module_16 from "@fncts/base/
|
2
|
+
import * as tsplus_module_1 from "@fncts/base/data/Equatable/api";
|
3
|
+
import * as tsplus_module_2 from "@fncts/base/data/Eq/definition";
|
4
|
+
import * as tsplus_module_3 from "@fncts/test/control/Sized/api";
|
5
|
+
import * as tsplus_module_4 from "@fncts/test/control/Sample/api";
|
6
|
+
import * as tsplus_module_5 from "@fncts/io/Random/api";
|
7
|
+
import * as tsplus_module_6 from "@fncts/io/IO/api";
|
8
|
+
import * as tsplus_module_7 from "@fncts/base/collection/immutable/Conc/definition";
|
9
|
+
import * as tsplus_module_8 from "@fncts/base/data/Maybe/constructors";
|
10
|
+
import * as tsplus_module_9 from "@fncts/io/Stream/api";
|
11
|
+
import * as tsplus_module_10 from "@fncts/base/collection/immutable/Conc/api/empty";
|
12
|
+
import * as tsplus_module_11 from "@fncts/base/collection/immutable/Conc/api";
|
13
|
+
import * as tsplus_module_12 from "@fncts/base/collection/immutable/Conc/api/replicate";
|
14
|
+
import * as tsplus_module_13 from "@fncts/base/data/Maybe/api";
|
15
|
+
import * as tsplus_module_14 from "@fncts/base/data/Maybe/destructors";
|
16
|
+
import * as tsplus_module_15 from "@fncts/base/collection/compat/Array/api";
|
17
|
+
import * as tsplus_module_16 from "@fncts/base/collection/immutable/Conc/constructors";
|
18
18
|
import * as tsplus_module_17 from "@fncts/base/data/number/instances";
|
19
19
|
import * as tsplus_module_18 from "@fncts/base/collection/immutable/SortedMap/api";
|
20
20
|
import * as tsplus_module_19 from "@fncts/base/data/function/api";
|
21
|
+
import * as tsplus_module_20 from "@fncts/base/data/string/instances";
|
22
|
+
import * as tsplus_module_21 from "@fncts/base/data/Eq/api";
|
23
|
+
export const array = array_1;
|
21
24
|
export const arrayWith = arrayWith_1;
|
22
25
|
export const arrayN = arrayN_1;
|
23
26
|
export const arrayInt64 = arrayInt64_1;
|
@@ -37,6 +40,7 @@ export const fromIOSample = fromIOSample_1;
|
|
37
40
|
export const floatWith = floatWith_1;
|
38
41
|
export const intWith = intWith_1;
|
39
42
|
export const map = map_1;
|
43
|
+
export const memo = memo_1;
|
40
44
|
export const oneOf = oneOf_1;
|
41
45
|
export const reshrink = reshrink_1;
|
42
46
|
export const small = small_1;
|
@@ -48,21 +52,73 @@ export const uniqueConcN = uniqueConcN_1;
|
|
48
52
|
export const unwrap = unwrap_1;
|
49
53
|
export const weighted = weighted_1;
|
50
54
|
export const zipWith = zipWith_1;
|
55
|
+
export const tuple = tuple_1;
|
56
|
+
export const record = record_1;
|
57
|
+
export const date = date_1;
|
58
|
+
export const int8Array = int8Array_1;
|
59
|
+
export const int16Array = int16Array_1;
|
60
|
+
export const int32Array = int32Array_1;
|
61
|
+
export const uint8Array = uint8Array_1;
|
62
|
+
export const uint16Array = uint16Array_1;
|
63
|
+
export const uint32Array = uint32Array_1;
|
51
64
|
import { IllegalArgumentError, NoSuchElementError } from "@fncts/base/data/exceptions";
|
52
65
|
import { identity } from "@fncts/base/data/function";
|
53
66
|
import { add64, clamp, computeArrayInt64GenerateRange, indexToDouble, indexToFloat, isStrictlyPositive64, isStrictlySmaller64, MAX_VALUE_32, safeDoubleToIndex, safeFloatToIndex, substract64, Unit64 } from "../../util/math.mjs";
|
54
67
|
import { Sample } from "../Sample.mjs";
|
55
68
|
import { Gen } from "./definition.mjs";
|
56
69
|
const gapSize = 0xdfff + 1 - 0xd800;
|
70
|
+
/**
|
71
|
+
* @tsplus static fncts.test.GenOps anything
|
72
|
+
*/
|
73
|
+
export function anything(constraints = {}) {
|
74
|
+
const key = constraints.key ?? alphaNumericString_1;
|
75
|
+
const maxDepth = constraints.maxDepth ?? 2;
|
76
|
+
const maxKeys = constraints.maxKeys ?? 5;
|
77
|
+
const values = constraints.values ?? [boolean_1, alphaNumericString_1, double_1, int_1, oneOf_1(alphaNumericString_1, constant_1(null), constant_1(undefined))];
|
78
|
+
function mapOf(key, value) {
|
79
|
+
return map_1(pairs => new Map(pairs))(uniqueConc_1({
|
80
|
+
eq: tsplus_module_2.makeEq({
|
81
|
+
equals: ([k1]) => ([k]) => tsplus_module_1.strictEquals(k, k1)
|
82
|
+
}),
|
83
|
+
maxLength: maxKeys
|
84
|
+
})(tuple_1(key, value)));
|
85
|
+
}
|
86
|
+
function setOf(value) {
|
87
|
+
return map_1(values => new Set(values))(uniqueConc_1({
|
88
|
+
eq: tsplus_module_2.makeEq({
|
89
|
+
equals: v1 => v => tsplus_module_1.strictEquals(v, v1)
|
90
|
+
}),
|
91
|
+
maxLength: maxKeys
|
92
|
+
})(value));
|
93
|
+
}
|
94
|
+
const base = oneOf_1(...values);
|
95
|
+
const arrayBase = oneOf_1(...values.map(gen => arrayWith_1({
|
96
|
+
maxLength: maxKeys
|
97
|
+
})(gen)));
|
98
|
+
const arrayGen = memo_1(n => oneOf_1(arrayBase, arrayWith_1({
|
99
|
+
maxLength: maxKeys
|
100
|
+
})(gen(n))));
|
101
|
+
const objectBase = oneOf_1(...values.map(gen => record_1(key, gen)));
|
102
|
+
const objectGen = memo_1(n => oneOf_1(objectBase, record_1(key, gen(n))));
|
103
|
+
const setBase = oneOf_1(...values.map(setOf));
|
104
|
+
const setGen = memo_1(n => oneOf_1(setBase, setOf(gen(n))));
|
105
|
+
const mapBase = oneOf_1(...values.map(value => mapOf(key, value)));
|
106
|
+
const mapGen = memo_1(n => oneOf_1(mapBase, mapOf(oneOf_1(key, gen(n)), gen(n))));
|
107
|
+
const gen = memo_1(n => {
|
108
|
+
if (n <= 0) return base;
|
109
|
+
return oneOf_1(base, arrayGen(), objectGen(), ...(constraints.withDate ? [date_1()] : []), ...(constraints.withSet ? [setGen()] : []), ...(constraints.withMap ? [mapGen()] : []), ...(constraints.withTypedArray ? [oneOf_1(int8Array_1(), uint8Array_1(), int16Array_1(), uint16Array_1(), int32Array_1(), uint32Array_1())] : []));
|
110
|
+
});
|
111
|
+
return gen(maxDepth);
|
112
|
+
}
|
57
113
|
/**
|
58
114
|
* @tsplus static fncts.test.GenOps size
|
59
115
|
*/
|
60
|
-
const size_1 = /*#__PURE__*/fromIO_1(
|
116
|
+
const size_1 = /*#__PURE__*/fromIO_1(tsplus_module_3.size);
|
61
117
|
export const size = size_1;
|
62
118
|
/**
|
63
119
|
* @tsplus static fncts.test.GenOps uniform
|
64
120
|
*/
|
65
|
-
const uniform_1 = /*#__PURE__*/fromIOSample_1( /*#__PURE__*/
|
121
|
+
const uniform_1 = /*#__PURE__*/fromIOSample_1( /*#__PURE__*/tsplus_module_6.map(tsplus_module_4.shrinkFractional(0.0), fileName_1 + ":127:82")(tsplus_module_5.nextDouble));
|
66
122
|
export const uniform = uniform_1;
|
67
123
|
/**
|
68
124
|
* @tsplus static fncts.test.GenOps alphaNumericChar
|
@@ -87,12 +143,13 @@ export function alphaNumericStringWith(constraints = {}) {
|
|
87
143
|
/**
|
88
144
|
* @tsplus static fncts.test.GenOps alphaNumericString
|
89
145
|
*/
|
90
|
-
|
146
|
+
const alphaNumericString_1 = /*#__PURE__*/string_1()(alphaNumericChar_1);
|
147
|
+
export const alphaNumericString = alphaNumericString_1;
|
91
148
|
/**
|
92
149
|
* @tsplus static fncts.test.GenOps array
|
93
150
|
* @tsplus getter fncts.test.Gen array
|
94
151
|
*/
|
95
|
-
|
152
|
+
function array_1(self) {
|
96
153
|
return arrayWith_1()(self);
|
97
154
|
}
|
98
155
|
/**
|
@@ -112,22 +169,22 @@ function arrayWith_1(constraints = {}) {
|
|
112
169
|
*/
|
113
170
|
function arrayN_1(n) {
|
114
171
|
return self => {
|
115
|
-
return map_1(conc =>
|
172
|
+
return map_1(conc => tsplus_module_7.toArray(conc))(concN_1(n)(self));
|
116
173
|
};
|
117
174
|
}
|
118
175
|
/**
|
119
176
|
* @tsplus static fncts.test.GenOps arrayInt64
|
120
177
|
*/
|
121
178
|
function arrayInt64_1(min, max) {
|
122
|
-
return new Gen(
|
179
|
+
return new Gen(tsplus_module_9.map(uncheckedValue => {
|
123
180
|
if (uncheckedValue.data.length === 1) {
|
124
181
|
uncheckedValue.data.unshift(0);
|
125
182
|
}
|
126
|
-
return
|
127
|
-
}, fileName_1 + ":
|
183
|
+
return tsplus_module_8.just(tsplus_module_4.shrinkArrayInt64(min)(uncheckedValue), fileName_1 + ":190:20");
|
184
|
+
}, fileName_1 + ":186:11")(tsplus_module_9.flatMap(({
|
128
185
|
min,
|
129
186
|
max
|
130
|
-
}) =>
|
187
|
+
}) => tsplus_module_9.repeatIO(tsplus_module_5.nextArrayIntBetween(min, max, fileName_1 + ":185:76"), fileName_1 + ":185:49"), fileName_1 + ":185:15")(tsplus_module_9.fromIO(computeArrayInt64GenerateRange(min, max, undefined, undefined), fileName_1 + ":184:18"))));
|
131
188
|
}
|
132
189
|
/**
|
133
190
|
* @tsplus static fncts.test.GenOps asciiChar
|
@@ -162,11 +219,12 @@ function base64StringWith_1(constraints = {}) {
|
|
162
219
|
/**
|
163
220
|
* @tsplus static fncts.test.GenOps bigInt
|
164
221
|
*/
|
165
|
-
export const bigInt = /*#__PURE__*/fromIOSample_1( /*#__PURE__*/
|
222
|
+
export const bigInt = /*#__PURE__*/fromIOSample_1( /*#__PURE__*/tsplus_module_6.map(tsplus_module_4.shrinkBigInt(BigInt(0)), fileName_1 + ":233:98")( /*#__PURE__*/tsplus_module_5.nextBigIntBetween( /*#__PURE__*/BigInt(-1) << /*#__PURE__*/BigInt(255), ( /*#__PURE__*/BigInt(1) << /*#__PURE__*/BigInt(255)) - /*#__PURE__*/BigInt(1), fileName_1 + ":233:27")));
|
166
223
|
/**
|
167
224
|
* @tsplus static fncts.test.GenOps boolean
|
168
225
|
*/
|
169
|
-
|
226
|
+
const boolean_1 = /*#__PURE__*/defer_1(() => oneOf_1(constant_1(true), constant_1(false)));
|
227
|
+
export const boolean = boolean_1;
|
170
228
|
/**
|
171
229
|
* @tsplus static fncts.test.GenOps bounded
|
172
230
|
*/
|
@@ -211,25 +269,26 @@ export function conc(self) {
|
|
211
269
|
*/
|
212
270
|
function concN_1(n) {
|
213
271
|
return g => {
|
214
|
-
return
|
272
|
+
return tsplus_module_11.foldLeft(constant_1(tsplus_module_10.empty()), (gen, a) => zipWith_1(a, (as, a) => tsplus_module_11.append(a)(as))(gen))(tsplus_module_12.replicate(n, g));
|
215
273
|
};
|
216
274
|
}
|
217
275
|
/**
|
218
276
|
* @tsplus static fncts.test.GenOps constant
|
219
277
|
*/
|
220
278
|
function constant_1(a) {
|
221
|
-
return new Gen(
|
279
|
+
return new Gen(tsplus_module_9.succeedNow(tsplus_module_8.just(tsplus_module_4.noShrink(a), fileName_1 + ":297:40"), fileName_1 + ":297:35"));
|
222
280
|
}
|
223
281
|
/**
|
224
282
|
* @tsplus static fncts.test.GenOps defer
|
225
283
|
*/
|
226
284
|
function defer_1(gen) {
|
227
|
-
return flatten_1(fromIO_1(
|
285
|
+
return flatten_1(fromIO_1(tsplus_module_6.succeed(gen, fileName_1 + ":304:31")));
|
228
286
|
}
|
229
287
|
/**
|
230
288
|
* @tsplus static fncts.test.GenOps double
|
231
289
|
*/
|
232
|
-
|
290
|
+
const double_1 = /*#__PURE__*/fromIOSample_1( /*#__PURE__*/tsplus_module_6.map(tsplus_module_4.shrinkFractional(0), fileName_1 + ":310:81")(tsplus_module_5.nextDouble));
|
291
|
+
export const double = double_1;
|
233
292
|
/**
|
234
293
|
* @tsplus static fncts.test.GenOps doubleWith
|
235
294
|
*/
|
@@ -240,11 +299,11 @@ export function doubleWith(constraints = {}) {
|
|
240
299
|
min = noDefaultInfinity ? -Number.MAX_VALUE : Number.NEGATIVE_INFINITY,
|
241
300
|
max = noDefaultInfinity ? Number.MAX_VALUE : Number.POSITIVE_INFINITY
|
242
301
|
} = constraints;
|
243
|
-
return unwrap_1(
|
244
|
-
const minIndex = yield* _(safeDoubleToIndex(min, "min"), fileName_1 + ":
|
245
|
-
const maxIndex = yield* _(safeDoubleToIndex(max, "max"), fileName_1 + ":
|
302
|
+
return unwrap_1(tsplus_module_6.gen(function* (_) {
|
303
|
+
const minIndex = yield* _(safeDoubleToIndex(min, "min"), fileName_1 + ":324:32");
|
304
|
+
const maxIndex = yield* _(safeDoubleToIndex(max, "max"), fileName_1 + ":325:32");
|
246
305
|
if (isStrictlySmaller64(maxIndex, minIndex)) {
|
247
|
-
return yield* _(
|
306
|
+
return yield* _(tsplus_module_6.haltNow(new IllegalArgumentError("min must be less than or equal to max", "Gen.double"), fileName_1 + ":327:35"), fileName_1 + ":327:24");
|
248
307
|
}
|
249
308
|
if (noNaN) {
|
250
309
|
return map_1(indexToDouble)(arrayInt64_1(minIndex, maxIndex));
|
@@ -255,12 +314,12 @@ export function doubleWith(constraints = {}) {
|
|
255
314
|
return map_1(index => {
|
256
315
|
if (isStrictlySmaller64(maxIndex, index) || isStrictlySmaller64(index, minIndex)) return Number.NaN;else return indexToDouble(index);
|
257
316
|
})(arrayInt64_1(minIndexWithNaN, maxIndexWithNaN));
|
258
|
-
}, fileName_1 + ":
|
317
|
+
}, fileName_1 + ":323:11"));
|
259
318
|
}
|
260
319
|
/**
|
261
320
|
* @tsplus static fncts.test.GenOps empty
|
262
321
|
*/
|
263
|
-
const empty_1 = /*#__PURE__*/new Gen(
|
322
|
+
const empty_1 = /*#__PURE__*/new Gen(tsplus_module_9.empty);
|
264
323
|
export const empty = empty_1;
|
265
324
|
/**
|
266
325
|
* @tsplus static fncts.test.GenOps exponential
|
@@ -285,10 +344,10 @@ export function filterNot(p) {
|
|
285
344
|
*/
|
286
345
|
function flatMap_1(f) {
|
287
346
|
return ma => {
|
288
|
-
return new Gen(
|
347
|
+
return new Gen(tsplus_module_4.flatMapStream(ma.sample, sample => {
|
289
348
|
const values = f(sample.value).sample;
|
290
349
|
const shrinks = flatMap_1(a => f(a))(new Gen(sample.shrink)).sample;
|
291
|
-
return
|
350
|
+
return tsplus_module_9.map(maybeSample => tsplus_module_13.map(sample => tsplus_module_4.flatMap(b => new Sample(b, shrinks))(sample))(maybeSample), fileName_1 + ":382:26")(values);
|
292
351
|
}));
|
293
352
|
};
|
294
353
|
}
|
@@ -302,13 +361,13 @@ function flatten_1(mma) {
|
|
302
361
|
* @tsplus static fncts.test.GenOps fromIO
|
303
362
|
*/
|
304
363
|
function fromIO_1(effect) {
|
305
|
-
return fromIOSample_1(
|
364
|
+
return fromIOSample_1(tsplus_module_6.map(tsplus_module_4.noShrink, fileName_1 + ":399:37")(effect));
|
306
365
|
}
|
307
366
|
/**
|
308
367
|
* @tsplus static fncts.test.GenOps fromIOSample
|
309
368
|
*/
|
310
369
|
function fromIOSample_1(effect) {
|
311
|
-
return new Gen(
|
370
|
+
return new Gen(tsplus_module_9.fromIO(tsplus_module_6.map(tsplus_module_8.just, fileName_1 + ":406:42")(effect), fileName_1 + ":406:31"));
|
312
371
|
}
|
313
372
|
/**
|
314
373
|
* @tsplus static fncts.test.GenOps floatWith
|
@@ -320,11 +379,11 @@ function floatWith_1(constraints = {}) {
|
|
320
379
|
max = noDefaultInfinity ? MAX_VALUE_32 : Number.POSITIVE_INFINITY,
|
321
380
|
noNaN = false
|
322
381
|
} = constraints;
|
323
|
-
return unwrap_1(
|
324
|
-
const minIndex = yield* _(safeFloatToIndex(min, "min"), fileName_1 + ":
|
325
|
-
const maxIndex = yield* _(safeFloatToIndex(max, "max"), fileName_1 + ":
|
382
|
+
return unwrap_1(tsplus_module_6.gen(function* (_) {
|
383
|
+
const minIndex = yield* _(safeFloatToIndex(min, "min"), fileName_1 + ":421:32");
|
384
|
+
const maxIndex = yield* _(safeFloatToIndex(max, "max"), fileName_1 + ":422:32");
|
326
385
|
if (minIndex > maxIndex) {
|
327
|
-
return yield* _(
|
386
|
+
return yield* _(tsplus_module_6.haltNow(new Error("Gen.float constraints.min must be less than or equal to constraints.max"), fileName_1 + ":425:21"), fileName_1 + ":424:24");
|
328
387
|
}
|
329
388
|
if (noNaN) {
|
330
389
|
return map_1(indexToFloat)(intWith_1({
|
@@ -340,7 +399,7 @@ function floatWith_1(constraints = {}) {
|
|
340
399
|
min: minIndexWithNaN,
|
341
400
|
max: maxIndexWithNaN
|
342
401
|
}));
|
343
|
-
}, fileName_1 + ":
|
402
|
+
}, fileName_1 + ":420:11"));
|
344
403
|
}
|
345
404
|
/**
|
346
405
|
* @tsplus static fncts.test.GenOps float
|
@@ -371,27 +430,28 @@ export function hexString(constraints = {}) {
|
|
371
430
|
/**
|
372
431
|
* @tsplus static fncts.test.GenOps int
|
373
432
|
*/
|
374
|
-
|
433
|
+
const int_1 = /*#__PURE__*/fromIOSample_1( /*#__PURE__*/tsplus_module_6.map(tsplus_module_4.shrinkIntegral(0), fileName_1 + ":473:75")(tsplus_module_5.nextInt));
|
434
|
+
export const int = int_1;
|
375
435
|
/**
|
376
436
|
* @tsplus static fncts.test.GenOps intWith
|
377
437
|
*/
|
378
438
|
function intWith_1(constraints = {}) {
|
379
|
-
return fromIOSample_1(
|
439
|
+
return fromIOSample_1(tsplus_module_6.defer(() => {
|
380
440
|
const min = constraints.min ?? -0x80000000;
|
381
441
|
const max = constraints.max ?? 0x7fffffff;
|
382
442
|
if (min > max || min < Number.MIN_SAFE_INTEGER || max > Number.MAX_SAFE_INTEGER) {
|
383
|
-
return
|
443
|
+
return tsplus_module_6.haltNow(new IllegalArgumentError("invalid bounds", "Gen.intWith"), fileName_1 + ":484:26");
|
384
444
|
} else {
|
385
|
-
return
|
445
|
+
return tsplus_module_6.map(tsplus_module_4.shrinkIntegral(min), fileName_1 + ":486:51")(tsplus_module_5.nextIntBetween(min, max, fileName_1 + ":486:37"));
|
386
446
|
}
|
387
|
-
}, fileName_1 + ":
|
447
|
+
}, fileName_1 + ":480:13"));
|
388
448
|
}
|
389
449
|
/**
|
390
450
|
* @tsplus pipeable fncts.test.Gen map
|
391
451
|
*/
|
392
452
|
function map_1(f) {
|
393
453
|
return self => {
|
394
|
-
return new Gen(
|
454
|
+
return new Gen(tsplus_module_9.map(maybeSample => tsplus_module_13.map(sample => tsplus_module_4.map(f)(sample))(maybeSample), fileName_1 + ":497:35")(self.sample));
|
395
455
|
};
|
396
456
|
}
|
397
457
|
/**
|
@@ -399,19 +459,19 @@ function map_1(f) {
|
|
399
459
|
*/
|
400
460
|
export function mapIO(f) {
|
401
461
|
return self => {
|
402
|
-
return new Gen(
|
462
|
+
return new Gen(tsplus_module_9.mapIO(maybeSample => tsplus_module_14.match(() => tsplus_module_6.succeedNow(tsplus_module_8.nothing(fileName_1 + ":509:38"), fileName_1 + ":509:30"), sample => tsplus_module_6.map(tsplus_module_8.just, fileName_1 + ":510:44")(tsplus_module_4.foreach(f)(sample)))(maybeSample), fileName_1 + ":507:24")(self.sample));
|
403
463
|
};
|
404
464
|
}
|
405
465
|
/**
|
406
466
|
* @tsplus static fncts.test.GenOps medium
|
407
467
|
*/
|
408
468
|
export function medium(f, min = 0) {
|
409
|
-
return flatMap_1(f)(reshrink_1(
|
469
|
+
return flatMap_1(f)(reshrink_1(tsplus_module_4.shrinkIntegral(min))(flatMap_1(max => map_1(n => clamp(Math.round(n * max / 10.0), min, max))(exponential_1))(size_1)));
|
410
470
|
}
|
411
471
|
/**
|
412
472
|
* @tsplus static fncts.test.GenOps memo
|
413
473
|
*/
|
414
|
-
|
474
|
+
function memo_1(builder) {
|
415
475
|
const previous = {};
|
416
476
|
let remainingDepth = 10;
|
417
477
|
return maxDepth => {
|
@@ -438,7 +498,7 @@ export function nat(max = 0x7fffffff) {
|
|
438
498
|
* @tsplus static fncts.test.GenOps oneOf
|
439
499
|
*/
|
440
500
|
function oneOf_1(...gens) {
|
441
|
-
if (
|
501
|
+
if (tsplus_module_15.isEmpty(gens)) return empty_1;else return flatMap_1(i => gens[i])(intWith_1({
|
442
502
|
min: 0,
|
443
503
|
max: gens.length - 1
|
444
504
|
}));
|
@@ -448,10 +508,10 @@ function oneOf_1(...gens) {
|
|
448
508
|
*/
|
449
509
|
export function partial(properties) {
|
450
510
|
const entries = Object.entries(properties);
|
451
|
-
return
|
511
|
+
return tsplus_module_15.foldLeft(constant_1({}), (b, [k, gen]) => unwrap_1(tsplus_module_6.ifIO(() => tsplus_module_6.succeed(() => zipWith_1(gen, (r, a) => ({
|
452
512
|
...r,
|
453
513
|
[k]: a
|
454
|
-
}))(b), fileName_1 + ":
|
514
|
+
}))(b), fileName_1 + ":575:50"), () => tsplus_module_6.succeed(() => b, fileName_1 + ":575:108"), fileName_1 + ":575:39")(tsplus_module_5.nextBoolean)))(entries);
|
455
515
|
}
|
456
516
|
/**
|
457
517
|
* @tsplus static fncts.test.GenOps printableChar
|
@@ -465,7 +525,7 @@ export const printableChar = /*#__PURE__*/char_1({
|
|
465
525
|
*/
|
466
526
|
function reshrink_1(f) {
|
467
527
|
return gen => {
|
468
|
-
return new Gen(
|
528
|
+
return new Gen(tsplus_module_9.map(maybeSample => tsplus_module_13.map(sample => f(sample.value))(maybeSample), fileName_1 + ":590:69")(gen.sample));
|
469
529
|
};
|
470
530
|
}
|
471
531
|
/**
|
@@ -478,7 +538,7 @@ export function sized(f) {
|
|
478
538
|
* @tsplus static fncts.test.GenOps small
|
479
539
|
*/
|
480
540
|
function small_1(f, min = 0) {
|
481
|
-
return flatMap_1(f)(reshrink_1(
|
541
|
+
return flatMap_1(f)(reshrink_1(tsplus_module_4.shrinkIntegral(min))(flatMap_1(max => map_1(n => clamp(Math.round(n * max / 25), min, max))(exponential_1))(size_1)));
|
482
542
|
}
|
483
543
|
/**
|
484
544
|
* @tsplus static fncts.test.GenOps string16
|
@@ -508,7 +568,7 @@ function stringN_1(n) {
|
|
508
568
|
*/
|
509
569
|
export function struct(properties) {
|
510
570
|
const entries = Object.entries(properties);
|
511
|
-
return
|
571
|
+
return tsplus_module_15.foldLeft(constant_1({}), (b, [k, gen]) => zipWith_1(gen, (out, a) => ({
|
512
572
|
...out,
|
513
573
|
[k]: a
|
514
574
|
}))(b))(entries);
|
@@ -523,7 +583,7 @@ export function unfoldGen(s, f) {
|
|
523
583
|
* @tsplus static fncts.test.GenOps unfoldGenN
|
524
584
|
*/
|
525
585
|
function unfoldGenN_1(n, s, f) {
|
526
|
-
if (n <= 0) return constant_1(
|
586
|
+
if (n <= 0) return constant_1(tsplus_module_16.make());else return flatMap_1(([s, a]) => map_1(as => tsplus_module_11.append(a)(as))(unfoldGenN_1(n - 1, s, f)))(f(s));
|
527
587
|
}
|
528
588
|
/**
|
529
589
|
* @tsplus static fncts.test.GenOps unicodeChar
|
@@ -541,7 +601,7 @@ export function unicodeString(constraints = {}) {
|
|
541
601
|
*/
|
542
602
|
export function uniqueArray(constraints = {}) {
|
543
603
|
return gen => {
|
544
|
-
return map_1(conc =>
|
604
|
+
return map_1(conc => tsplus_module_7.toArray(conc))(uniqueConc_1(constraints)(gen));
|
545
605
|
};
|
546
606
|
}
|
547
607
|
/**
|
@@ -550,8 +610,8 @@ export function uniqueArray(constraints = {}) {
|
|
550
610
|
function uniqueConc_1(constraints = {}) {
|
551
611
|
return self => {
|
552
612
|
const minLength = constraints.minLength ?? 0;
|
553
|
-
const eq = constraints.eq ??
|
554
|
-
equals: y => x =>
|
613
|
+
const eq = constraints.eq ?? tsplus_module_2.makeEq({
|
614
|
+
equals: y => x => tsplus_module_1.strictEquals(x, y)
|
555
615
|
});
|
556
616
|
return constraints.maxLength ? bounded_1(minLength, constraints.maxLength, n => uniqueConcN_1(n, eq)(self)) : small_1(n => uniqueConcN_1(n, eq)(self), minLength);
|
557
617
|
};
|
@@ -561,7 +621,7 @@ function uniqueConc_1(constraints = {}) {
|
|
561
621
|
*/
|
562
622
|
function uniqueConcN_1(n, /** @tsplus auto */E) {
|
563
623
|
return self => {
|
564
|
-
return
|
624
|
+
return tsplus_module_11.foldLeft(constant_1(tsplus_module_10.empty()), (gen, a) => zipWith_1(a, (as, a) => tsplus_module_11.elem(a, E)(as) ? as : tsplus_module_11.append(a)(as))(gen))(tsplus_module_12.replicate(n, self));
|
565
625
|
};
|
566
626
|
}
|
567
627
|
/**
|
@@ -574,11 +634,11 @@ function unwrap_1(effect) {
|
|
574
634
|
* @tsplus static fncts.test.GenOps weighted
|
575
635
|
*/
|
576
636
|
function weighted_1(...gens) {
|
577
|
-
const sum =
|
578
|
-
const [map] =
|
637
|
+
const sum = tsplus_module_15.foldLeft(0, (b, a) => b + a)(gens.map(([, weight]) => weight));
|
638
|
+
const [map] = tsplus_module_15.foldLeft(tsplus_module_19.tuple(tsplus_module_18.make(tsplus_module_17.Ord), 0), ([map, acc], [gen, d]) => {
|
579
639
|
if ((acc + d) / sum > acc / sum) return tsplus_module_19.tuple(tsplus_module_18.set((acc + d) / sum, gen)(map), acc + d);else return tsplus_module_19.tuple(map, acc);
|
580
640
|
})(gens);
|
581
|
-
return flatMap_1(n =>
|
641
|
+
return flatMap_1(n => tsplus_module_13.getOrElse(() => {
|
582
642
|
throw new NoSuchElementError("Gen.weighted");
|
583
643
|
})(tsplus_module_18.getGte(n)(map)))(uniform_1);
|
584
644
|
}
|
@@ -601,8 +661,75 @@ export function zip(that) {
|
|
601
661
|
/**
|
602
662
|
* @tsplus static fncts.test.GenOps tuple
|
603
663
|
*/
|
604
|
-
|
605
|
-
return
|
664
|
+
function tuple_1(...components) {
|
665
|
+
return tsplus_module_15.foldLeft(constant_1([]), (b, a) => zipWith_1(a, (vs, v) => [...vs, v])(b))(components);
|
666
|
+
}
|
667
|
+
/**
|
668
|
+
* @tsplus static fncts.test.GenOps record
|
669
|
+
*/
|
670
|
+
function record_1(key, value, constraints) {
|
671
|
+
return map_1(pairs => tsplus_module_11.foldLeft({}, (b, [k, v]) => ({
|
672
|
+
...b,
|
673
|
+
[k]: v
|
674
|
+
}))(pairs))(uniqueConc_1({
|
675
|
+
eq: tsplus_module_21.contramap(([k]) => k)(tsplus_module_20.Eq),
|
676
|
+
...constraints
|
677
|
+
})(tuple_1(key, value)));
|
678
|
+
}
|
679
|
+
/**
|
680
|
+
* @tsplus static fncts.test.GenOps date
|
681
|
+
*/
|
682
|
+
function date_1(constraints = {}) {
|
683
|
+
const min = constraints.min ? constraints.min.getTime() : -8640000000000000;
|
684
|
+
const max = constraints.max ? constraints.max.getTime() : 8640000000000000;
|
685
|
+
return map_1(n => new Date(n))(intWith_1({
|
686
|
+
min,
|
687
|
+
max
|
688
|
+
}));
|
689
|
+
}
|
690
|
+
function typedArray(constraints, minBound, maxBound, ctor) {
|
691
|
+
const min = constraints.min ? clamp(constraints.min, minBound, maxBound) : minBound;
|
692
|
+
const max = constraints.max ? clamp(constraints.max, minBound, maxBound) : maxBound;
|
693
|
+
return map_1(n => new ctor(n))(array_1(intWith_1({
|
694
|
+
min,
|
695
|
+
max
|
696
|
+
})));
|
697
|
+
}
|
698
|
+
/**
|
699
|
+
* @tsplus static fncts.test.GenOps int8Array
|
700
|
+
*/
|
701
|
+
function int8Array_1(constraints = {}) {
|
702
|
+
return typedArray(constraints, -128, 127, Int8Array);
|
703
|
+
}
|
704
|
+
/**
|
705
|
+
* @tsplus static fncts.test.GenOps int16Array
|
706
|
+
*/
|
707
|
+
function int16Array_1(constraints = {}) {
|
708
|
+
return typedArray(constraints, -32768, 32767, Int16Array);
|
709
|
+
}
|
710
|
+
/**
|
711
|
+
* @tsplus static fncts.test.GenOps int32Array
|
712
|
+
*/
|
713
|
+
function int32Array_1(constraints = {}) {
|
714
|
+
return typedArray(constraints, -0x80000000, 0x7fffffff, Int32Array);
|
715
|
+
}
|
716
|
+
/**
|
717
|
+
* @tsplus static fncts.test.GenOps uint8Array
|
718
|
+
*/
|
719
|
+
function uint8Array_1(constraints = {}) {
|
720
|
+
return typedArray(constraints, 0, 255, Uint8Array);
|
721
|
+
}
|
722
|
+
/**
|
723
|
+
* @tsplus static fncts.test.GenOps uint16Array
|
724
|
+
*/
|
725
|
+
function uint16Array_1(constraints = {}) {
|
726
|
+
return typedArray(constraints, 0, 65535, Uint16Array);
|
727
|
+
}
|
728
|
+
/**
|
729
|
+
* @tsplus static fncts.test.GenOps uint32Array
|
730
|
+
*/
|
731
|
+
function uint32Array_1(constraints = {}) {
|
732
|
+
return typedArray(constraints, 0, 0xffffffff, Uint32Array);
|
606
733
|
}
|
607
734
|
function _char(min, max, mapToCode) {
|
608
735
|
return map_1(n => String.fromCharCode(mapToCode(n)))(intWith_1({
|