Repository navigation
v0.14.0
Changed
- Breaking: the public API is two modules,
metamonandmetamon/generator. Everything else is internal or removed. Packages that use metamon in their tests need updating. - Breaking: a property is
fn(a) -> Niland fails by panicking, so Gleam'sassertandlet assertwork inside it. The report shows the panic message, and the failing input is shrunk while the property still panics. - Breaking:
Configis a plain record withruns,seed: Option(Int),max_size,shrink_limit,max_edges,regression_file: Option(String)andoutput: Output. Override fields ofdefault_config(); the runners panic on invalid values when they start. - Breaking:
Morph(a, b)replaces the opaqueMrand has two constructors,Morph(name:, transform:, relation:)andEquivariant(name:, input:, output:, relation:).forall_morphtakes a list of morphs and reports every one that fails.TransformandRelationare plain records inmetamon. - Breaking: ranges and character sets are part of
metamon/generator:range(from:, to:),linear_range(from:, to:), theCharacterstype,character(of:),string(of:, length:)andstring_from(characters:, length:). Collection generators take labelled lengths, andsample(generator, count:, seed:)draws values. - Breaking:
classify(label:, when:),cover(at_least:, label:, when:)andannotate(label:, value:)are inmetamon. - The JSON failure report has a
panic_messagekey. - A panic inside the function, a transform or a relation of
forall_morphandassert_morphis a failure of that morph: it is shrunk, reported with its message, and the other morphs are still checked. - Shrinking keeps only inputs that fail the same way as the original failure, with the same panic message or the same broken relation. A message that contains the input stops shrinking at the first failing input; put the value in
annotateinstead. - Edge cases count toward
Config.runs, soruns: 1tries one input. - Regression files use schema version 2, which records
max_size. Version 1 files are still read, withmax_size99. Entries recorded by earlier versions for round trips (under(plain property)) or for string and list edge cases may no longer replay; delete and re-record them.
// Before
let config =
metamon.default_config()
|> metamon.with_seed(metamon.seed(42))
|> metamon.with_runs_or_panic(300)
metamon.forall_with(
config,
generator.list_of(generator.int(range.constant(-100, 100)), range.constant(0, 20)),
fn(items) { list.reverse(list.reverse(items)) == items },
)
// After
let config = metamon.Config(..metamon.default_config(), seed: Some(42), runs: 300)
metamon.forall_with(
config,
generator.list_of(
generator.int(generator.range(from: -100, to: 100)),
length: generator.range(from: 0, to: 20),
),
fn(items) { assert list.reverse(list.reverse(items)) == items },
)Removed
- Breaking: the modules
metamon/config,metamon/relation,metamon/transform,metamon/transform/list,metamon/transform/string,metamon/transform/dict,metamon/coverage,metamon/annotate,metamon/diff,metamon/stateful,metamon/commandandmetamon/generator/{range,seed,tree,shrink,edges}. - Breaking: the configuration setters, getters and
_or_panicvariants,seed,random_seed,mr,mr_equivariant,equivariant_under,name_of,forall_observable,forall_morphs,forall_morph_n, the partial andunderround-trip runners, n-ary relations, the relation and transform catalogues beyondequal,approximately,equivalent_underandpermutation_of,cover_at_least,classify_in_bucket,collect,footnote, and the generator shortcuts that one range or character set replaces (non_negative_int,positive_int,negative_int,byte,ascii_*,string_*,unicode_codepoint,bit_array_printable,bit_array_utf8,float_special_edges,non_empty_list_of,map7,map8,tuple7,tuple8,resize,scale,statistics,add_edges). - The CRDT case study page, which was written for the old API.
Fixed
cover(at_least: p)is met when exactlyppercent of the runs hit the label. Floating-point rounding used to report a shortfall.forall,forall_withand theforall_round_triprunners now shrink a failing input. They used to report the first failing input withshrinks: 0.- A generated list keeps shrinking after an element is dropped, and never shrinks below the range's minimum length.
- The configured
max_sizenow reaches the generators. Ranges used to grow as ifmax_sizewere 99. - The coverage percentage is now hits per run. A label counts at most once per run, and calling
coverorclassifyseveral times in a run no longer lowers or raises other labels' percentages. - Annotations appear in the order they were registered, and only the annotations of the reported input are shown.
forall_morphwith several morphs now replays and records regression entries, checks coverage and shrinks, like the other runners.- Round-trip runners key their regression entries by the round-trip name, so two round trips sharing a file no longer replay each other's entries.
- String generators no longer add
" "and"\n"as edge cases outside the character set. - Generating a long list on JavaScript no longer overflows the stack.
- Failure reports show the structured list and tuple diff again, and strings are no longer escaped twice.
- A regression file that cannot be written is reported in the failure footnote instead of being ignored. Entries are appended instead of rewriting the file.
Install
gleam add metamonSee HexDocs for the API
reference.