def check.go

bend-kit-property@0.4.0.0 · property.bend:68

import bend-kit-property@0.4.0.0/property.bend as Property
import Base
import bend-kit-random@0.1.0.1/random.bend as Rand

68def check.go(~T: Type, ~gen: Rand.Rng -> T & Rand.Rng, ~copy: T -> T & T,
69  ~shrink: T -> List<&1, T>, ~test: T -> T & Bool,
70  remaining: Nat, +seed: U32, +trial: Nat, state: (T & Bool) & Rand.Rng) -> Maybe<&1, Failure<T>>:
71  match remaining:
72    case 0n:
73      None{}
74    case 1n+p:
75      match p:
76        case 0n:
77          (tested, next) = state
78          (value, ok) = tested
79          match ok:
80            case False{}:
81              Some{Failure{seed, trial, minimize.start(~T, ~copy, ~shrink, ~test, value)}}
82            case True{}:
83              None{}
84        case 1n+q:
85          (tested, next) = state
86          (value, ok) = tested
87          match ok:
88            case False{}:
89              Some{Failure{seed, trial, minimize.start(~T, ~copy, ~shrink, ~test, value)}}
90            case True{}:
91              check.go(~T, ~gen, ~copy, ~shrink, ~test, p, seed, (1n+trial), draw(~T, ~gen, ~test, next))

Uses (11)

Used by (1)