Module

poke/property

src/poke/property.pooka

Ask the same question of many small worlds.

Checks use an explicit seed and bounded shrinking. A counterexample carries the original value, the smaller failure and the exact seed/size for replay. Properties should be pure: shrinking repeats the callback. Exceptions are failures too, but callbacks have no automatic timeout.

API reference

class

Config

src/poke/property.pooka:18
class Config(seed: Int, cases: Int, max_size: Int, max_shrinks: Int)

cases must be positive; sizes and shrink budgets must be nonnegative.

field

seed

src/poke/property.pooka:18
seed: Int
INFERREDInt
field

cases

src/poke/property.pooka:18
cases: Int
INFERREDInt
field

max_size

src/poke/property.pooka:18
max_size: Int
INFERREDInt
field

max_shrinks

src/poke/property.pooka:18
max_shrinks: Int
INFERREDInt
constructor

new

src/poke/property.pooka:18
INFERREDfn(Int, Int, Int, Int) -> poke/property.Config
class

Report

src/poke/property.pooka:20
class Report(seed: Int, cases: Int)
field

seed

src/poke/property.pooka:20
seed: Int
INFERREDInt
field

cases

src/poke/property.pooka:20
cases: Int
INFERREDInt
constructor

new

src/poke/property.pooka:20
INFERREDfn(Int, Int) -> poke/property.Report
class

Failure

src/poke/property.pooka:22
class Failure(
  seed: Int,
  trial: Int,
  case_seed: Int,
  size: Int,
  original: a,
  minimal: a,
  reason: String,
  shrinks: Int
)
field

seed

src/poke/property.pooka:23
seed: Int
INFERREDInt
field

trial

src/poke/property.pooka:24
trial: Int
INFERREDInt
field

case_seed

src/poke/property.pooka:25
case_seed: Int
INFERREDInt
field

size

src/poke/property.pooka:26
size: Int
INFERREDInt
field

original

src/poke/property.pooka:27
original: a
INFERREDa
field

minimal

src/poke/property.pooka:28
minimal: a
INFERREDa
field

reason

src/poke/property.pooka:29
reason: String
INFERREDString
field

shrinks

src/poke/property.pooka:30
shrinks: Int
INFERREDInt
constructor

new

src/poke/property.pooka:23
INFERREDfn(Int, Int, Int, Int, a, a, String, Int) -> poke/property.Failure(a)
function

defaults

src/poke/property.pooka:36
defaults() -> Config
INFERREDfn() -> poke/property.Config

A repeatable default, rather than a fresh mystery on every run.

function

check

src/poke/property.pooka:45
check(source: Generator(a), predicate: fn(a) -> Bool, config: Config) -> Result(
  Report,
  Failure(a)
)

Check a Boolean predicate, returning a replayable failure instead of raising.

Pooka
property.check(generator.integers(-20, 20), fn(n) { n + 0 == n }, property.defaults())
function

for_all

src/poke/property.pooka:180
for_all(source: Generator(a), assertion: fn(a) -> Nil) -> Nil
INFERREDfn(poke/generator.Generator(a), fn(a) -> Nil) -> Nil

Run assertion-style properties with the default seed and bounds.

Pooka
property.for_all(generator.integers(-100, 100), fn(n) {
  should.equal(n + 0, n)
})
function

for_all_with

src/poke/property.pooka:185
for_all_with(source: Generator(a), assertion: fn(a) -> Nil, config: Config) -> Nil
INFERREDfn(poke/generator.Generator(a), fn(a) -> Nil, poke/property.Config) -> Nil

Choose a seed and bounds explicitly. The failure message includes replay data.

function

replay

src/poke/property.pooka:201
replay(source: Generator(a), case_seed: Int, size: Int) -> a
INFERREDfn(poke/generator.Generator(a), Int, Int) -> a

Replay just one failing sample using Failure.case_seed and Failure.size.

function

describe

src/poke/property.pooka:206
describe(problem: Failure(a)) -> String
INFERREDfn(poke/property.Failure(a)) -> String

Show a counterexample without hiding the seed behind a stack trace.