summaryrefslogtreecommitdiff
path: root/pbt/ts/src/property.ts
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud@pankzsoft.com>2025-12-02 04:43:49 +0100
committerArnaud Bailly <arnaud@pankzsoft.com>2025-12-02 04:43:49 +0100
commit83d63d6d3248666ebb23c7c29f0c58775f277482 (patch)
treed6e094a866dcca3bf2320cd0b6754b452358bdc0 /pbt/ts/src/property.ts
parent8a6cfd0187b149a1ce83f62af62bb227ee441277 (diff)
downloadlambda-nantes-83d63d6d3248666ebb23c7c29f0c58775f277482.tar.gz
adapt Bank interface to async
Diffstat (limited to 'pbt/ts/src/property.ts')
-rw-r--r--pbt/ts/src/property.ts20
1 files changed, 12 insertions, 8 deletions
diff --git a/pbt/ts/src/property.ts b/pbt/ts/src/property.ts
index 56683c1..635e731 100644
--- a/pbt/ts/src/property.ts
+++ b/pbt/ts/src/property.ts
@@ -53,11 +53,11 @@ export function generate<A>(gen: Gen<A>): A {
return gen(rng)(100);
}
-export function property<A>(
+export async function property<A>(
generator: Gen<A>,
predicate: Predicate<A>,
shrinker?: Shrinker<A>,
-): Property<A> {
+): Promise<Property<A>> {
return async (seed: number, size: number) => {
const rng = new Prando(seed);
const gen = generator(rng);
@@ -243,9 +243,10 @@ export function shrinkPair<A, B>(
}
export const Property = {
- run<A>(prop: Property<A>): Promise<TestResult<A>> {
+ async run<A>(prop: Promise<Property<A>>): Promise<TestResult<A>> {
const seed = Math.floor(Math.random() * 1000000);
- return prop(seed, 0);
+ const p = await prop;
+ return await p(seed, 0);
},
};
@@ -253,11 +254,14 @@ export const Property = {
export function forall<A, B>(
gen: Gen<A>,
- k: (a: A) => Property<B>,
-): Property<B> {
- return (seed: number, size: number) => {
+ k: (a: A) => Promise<Property<B>>,
+): Promise<Property<B>> {
+ const p = async (seed: number, size: number) => {
const rng = new Prando(seed);
const a = gen(rng)(size);
- return k(a)(seed, size);
+ const p = await k(a);
+ return await p(seed, size);
};
+
+ return Promise.resolve(p);
}