npbt/pbt_types_execution

    Dark Mode
Search:
Group by:
  Source   Edit

Types

AssertParams = object
  seed*: uint32
  random*: Random
  runsBeforeSuccess*: range[1 .. high(int)]
  shrinkFirstFails*: range[1 .. high(int)]
  path*: Option[seq[int]]
parameters for asserting properties   Source   Edit
AssertReport[T] = object
  name*: string
  runId*: PossibleRunId
  failures*: uint32
  firstFailure*: PossibleRunId
  failureType*: PTStatus
  seed*: uint32
  counterExample*: Option[CounterExample[T]]
result of a property assertion, with all runs information   Source   Edit
GlobalContext = object
  hasFailure*: bool
  specNames*: seq[string]
  Source   Edit
RunExecution[T] = object
  runId*: uint32
  failureOn*: PossibleRunId
  seed*: uint32
  name*: string
  counterExample*: Option[CounterExample[T]]
  message*: string
  numSuccess*: int
result of run execution   Source   Edit

Procs

proc `$`[T](r: AssertReport[T]): string
  Source   Edit
proc `$`[T](r: RunExecution[T]): string
  Source   Edit
proc ctxEcho(ctx: GlobalContext; msg: string) {....raises: [], tags: [].}
  Source   Edit
proc defAssertPropParams(): AssertParams {....raises: [], tags: [TimeEffect].}
default params used for an execProperty   Source   Edit
proc execAndShrink[T](ctx: var GlobalContext; value: Shrinkable[T];
                      prop: Property[T];
                      params: AssertParams = defAssertPropParams()): seq[
    AssertReport[T]]
  Source   Edit
proc execProperty[A, B, C](ctx: var GlobalContext; name: string;
                           arb1: Arbitrary[A]; arb2: Arbitrary[B];
                           arb3: Arbitrary[C]; pred: Predicate[(A, B, C)];
                           params: AssertParams = defAssertPropParams()): AssertReport[
    (A, B, C)]
  Source   Edit
proc execProperty[A, B](ctx: var GlobalContext; name: string;
                        arb1: Arbitrary[A]; arb2: Arbitrary[B];
                        pred: Predicate[(A, B)];
                        params: AssertParams = defAssertPropParams()): AssertReport[
    (A, B)]
  Source   Edit
proc execProperty[A](ctx: var GlobalContext; name: string; arb: Arbitrary[A];
                     pred: Predicate[A];
                     params: AssertParams = defAssertPropParams()): seq[
    AssertReport[A]]
  Source   Edit
proc execProperty[T](name: string; arb: Arbitrary[T]; check: Predicate[T];
                     params: AssertParams = defAssertPropParams()): RunExecution[
    T]
Execute property using values generated by arb. Either run params.runsNeforeSuccess, or until first failure is found, returning execution results and associated metadata.   Source   Edit
proc handleResult[T](runner: var Runner[T]; status: PTStatus)
This procedure must be called after next() (or in every iteration of the loop over items), otherwise recorded failure would not store correct counterexample value.   Source   Edit
proc hasFailure(r: AssertReport): bool
  Source   Edit
func hasFailure[T](ex: RunExecution[T]): bool
  Source   Edit
proc isSuccessful(r: AssertReport): bool
  Source   Edit
proc newRunner[T](name: string; params: AssertParams; arb: Arbitrary[T]): Runner[
    T]
Create new runner object, using specified params.   Source   Edit
proc newRunnerYield[T](shrinkable: Shrinkable[T]; done: bool = false): RunnerYield[
    T]
Create new runner yield object   Source   Edit
proc next[T](runner: var Runner[T]): RunnerYield[T]
Get next value from arbitrary generator embedded in runner   Source   Edit
proc propParams(seed: uint32; path: seq[int]): AssertParams {....raises: [],
    tags: [TimeEffect].}
Construct new assert parameters based on default ones, overriding seed and path with specified ones.   Source   Edit
proc recordFail[T](execution: var RunExecution[T]; value: T; id: int)
Record failure of the execution, setting counterexample and associated metadata.   Source   Edit
proc recordFailure[T](r: var AssertReport[T]; example: T; ft: PTStatus)
records the failure in the report, and notes first failure and associated counter-example as necessary   Source   Edit
proc recordPass[T](execution: var RunExecution[T]; value: T)
Record success of the executiuon   Source   Edit
proc reportFailure(ctx: var GlobalContext; msg: string) {....raises: [], tags: [].}
XXX: do better reporting   Source   Edit
proc reportSuccess(ctx: GlobalContext; msg: string) {....raises: [], tags: [].}
XXX: do better reporting   Source   Edit
proc startReport[T](name: string; seed: uint32): AssertReport[T]
start a new report   Source   Edit
proc startRun[T](r: var AssertReport[T]) {.inline.}
  Source   Edit

Iterators

iterator items[T](runner: var Runner[T]): RunnerYield[T]
Iterate over results of the arbitrary generator until no more results are produced, or until runner detects a run execution failure.   Source   Edit