Vocabulary
proptastic is one library in several languages, and it uses the same words in each: a property written in Java reads like one written in Rust, and a failure says the same things. So what you learn in one carries over, and a team that uses two languages tests both the same way.
The words are kept in a contract,
which each edition’s tests check its API against. These tables are read from it. Each language
writes a word in its own casing, forAll or for_all, and that counts as the same word.
The words
Section titled “The words”Starting a property, and its domains
| Java | Rust pending | Swift planned | What it does |
|---|---|---|---|
forAll | for_all | forAll | start a property, one draw per domain |
domain | domain | domain | a custom domain: combined from domains and a constructor, or named with a source |
any | any | any | a domain found from a type: each scalar from its word, a sum type's variants in declaration order (decision 84) |
integers | integers | integers | integers |
doubles | doubles | doubles | floating-point numbers |
booleans | booleans | booleans | booleans |
strings | strings | strings | strings |
lists | lists | lists | lists, the language's native type |
sets | sets | sets | sets, the language's native type |
maps | maps | maps | maps, the language's native type |
optionals | optionals | optionals | optional values, the language's native type |
elements | elements | elements | one of the values given |
oneOf | one_of | oneOf | a value from one of the domains given |
weighted | weighted | weighted | a domain weighing more or less in a oneOf: drawn in proportion to its weight, an unweighted part weighing 1 |
steps | steps | steps | start a stateful test: the state each try starts from, then its steps; or steps as values of one type (a record, an enum), each a value of one domain taken by one function |
lean | lean | lean | a model built by Lean's Lake: by its name, the program Lake built in models/lean; or the executable in a project at a path |
command | command | command | a model in any language: an executable that speaks the model protocol |
spec | spec | spec | a TLA+ spec a stateful test follows: the state graph TLC checked, every next state it allows, or, with no graph, each step judged by TLC (decision 110); by its name, the graph in models/tla |
record | record | record | inside a step: what the step saw, which the steps one at a time must give too, in some order, when they run on threads; anywhere else it does nothing |
lock | lock | lock | a named lock for the state of steps run on threads: taking it is a point where another thread may run, a thread asking for it while another holds it waits, and a deadlock is found and named; a plain lock anywhere else |
thread | thread | thread | one thread's steps, in order, pinning steps run on threads for .example: one thread(…) for each thread |
first | first | first | the steps taken on one thread before the threads start, pinning steps run on threads for .example, before the thread(…)s (decision 109) |
handles | handles | handles | values steps make that later steps use, named for what they are: in an argument's place they draw one the run kept and hasn't dropped (decision 105) |
handle | handle | handle | the nth value a run's handles of a name kept, as a step's argument in a pin: handle("account", 1) (decision 105) |
fromState | from_state | fromState | a step's argument from a domain the state gives, as it is when the run reaches the step, its precondition checked first (decision 106) |
dates | dates | dates | calendar dates in the language's own date type, 1900-01-01 to 2100-12-31 unless bounded, about one try in five on a calendar edge; a failure shrinks toward Monday 2001-01-01, or the allowed day nearest it (decisions 79 and 80) |
times | times | times | times of day, whole seconds mostly and fractions sometimes; a failure shrinks toward midnight (decision 81) |
dateTimes | date_times | dateTimes | a date and a time of day with no zone, drawn as a date and a time; a failure shrinks toward 2001-01-01T00:00 (decision 81) |
instants | instants | instants | moments, in UTC, in the dates' window; a failure shrinks toward 2001-01-01T00:00:00Z (decision 81) |
durations | durations | durations | signed lengths of time, edges at zero, one unit, a day, 23 and 25 hours; a failure shrinks toward zero (decision 81) |
offsets | offsets | offsets | fixed UTC offsets, edges at half and quarter hours and the extremes; a failure shrinks toward UTC (decision 81) |
zones | zones | zones | region zones from calendar.zones, UTC first; in .inZones(zones()) a zone's transitions are edges, and a failure names the tz database's version (decision 91) (the zones module) |
luhnNumbers | luhn_numbers | luhnNumbers | Luhn numbers, 12 to 19 digits and their check digit; .mistyped() for ones a digit off (decision 98) (the identifiers module) |
ibans | ibans | ibans | IBANs with their mod-97 check digits, from countries whose account numbers carry no check of their own (decision 98) (the identifiers module) |
isins | isins | isins | ISINs: a country, nine letters or digits and the Luhn check digit (decision 98) (the identifiers module) |
isbns | isbns | isbns | ISBN-13s with their check digit (decision 98) (the identifiers module) |
ipAddresses | ip_addresses | ipAddresses | IP addresses, version 4 first, edges at loopback, private, link-local and the version 6 forms; a failure shrinks toward 0.0.0.0 (decision 94) (provisional) (the internet module) |
domains | domains | domains | RFC 1123 host names under common top-level domains, or the test's own; a failure shrinks toward a.com (decision 94) (provisional) (the internet module) |
emails | emails | emails | email addresses both RFC 5322's dot-atom and HTML accept; a failure shrinks toward [email protected] (decision 94) (provisional) (the internet module) |
urls | urls | urls | absolute http and https URLs a WHATWG parser leaves as they are; a failure shrinks toward https://a.com/ (decision 94) (provisional) (the internet module) |
decimals | decimals | decimals | exact decimal numbers, an unscaled whole number and a scale; a failure shrinks toward zero, then toward fewer places (decision 82) |
uuids | uuids | uuids | UUIDs of version 4 and 7, their version and variant set by construction; a failure shrinks toward the one whose drawn bits are all zero (decision 82) |
floats | floats | floats | 32-bit floating-point numbers, the language's own, by doubles()'s laws in their own range, NaN, the infinities, -0.0 and the smallest subnormal among them unbounded (decision 88) |
bytes | bytes | bytes | byte strings, the language's own, edges empty, all zero and all 0xFF (decision 88) |
bigIntegers | big_integers | bigIntegers | arbitrary-precision integers, the i128 range unless bounded, written as 64-bit choices (decisions 87 and 88) |
On a property
| Java | Rust pending | Swift planned | What it does |
|---|---|---|---|
check | check | check | run it now; throws or panics with the shrunk counterexample |
example | example | example | pin one example, a value per draw |
examples | examples | examples | pin many examples from a collection |
via | via | via | where the example before it came from |
tries | tries | tries | the number of tries |
exhaustively | exhaustively | exhaustively | every value the draws can take, once each, in place of random tries (decision 47) |
seed | seed | seed | the seed |
id | id | id | the key of a property's corpus, so renaming the test keeps its entries |
follows | follows | follows | run the property against a model: the code's answer must be one the model allows, and every outcome the model names must come up |
unreachable | unreachable | unreachable | an outcome of the model the draws can't reach, and why: printed, and a failure if it comes up |
allow | allow | allow | a health check that's fine for this property, and why: it isn't made (decision 46) |
threads | threads | threads | run a stateful test's steps on several threads at once, sharing one state: every schedule within the bound, switching threads only at points proptastic sees; it fails on a deadlock, a thread stuck elsewhere, a broken invariant, a step's own failure, or answers that no order of the steps, one at a time, gives |
Inside a check
| Java | Rust pending | Swift planned | What it does |
|---|---|---|---|
assume | assume | assume | skip a try unless a condition holds (how to use it) |
classify | classify | classify | label a try, for the distribution report |
target | target | target | score a try, for the run to climb toward higher scores (decision 62) |
require | require | require | label a try and ask for a share of tries: the run fails when the label is surely rarer, and says it is incomplete when the tries can't tell (decisions 45 and 107) |
keep | keep | keep | inside a step: keeps a value the step made, for later steps to draw, and returns it (decision 105) |
drop | drop | drop | inside a step: the step is done with a value kept, so no later step draws it (decision 105) |
On a domain
| Java | Rust pending | Swift planned | What it does |
|---|---|---|---|
edges | edges | edges | edge values of your own, drawn one try in 8 on top of the domain's own |
writtenAs | written_as | writtenAs | how to write the domain's values as source, for a type the edition can't write itself, so a pin line pins the value, not the seed; draws exactly as the domain does (decision 95) |
from | from | from | a string domain's alphabet, or several alphabets one after another: their characters only, each as likely, the first the simplest; strings.alphabets names the common ones (decision 96) |
matching | matching | matching | strings a regular expression matches in full, in the language's own syntax (decision 41) |
finite | finite | finite | a floating-point domain without NaN, the infinities, -0.0 and the smallest subnormal, which unbounded it draws one try in 16 |
with | with | with | a by-type domain's field given a domain of its own, named as the edition names a field (Java its accessor), wherever its type is drawn |
map | map | map | transform each value |
filter | filter | filter | keep only the values that pass |
flatMap | flat_map | flatMap | a dependent value: one value decides another's domain |
ofSize | of_size | ofSize | a collection's size, exact or between bounds |
ofLength | of_length | ofLength | a string's length, exact or between bounds |
averageSize | average_size | averageSize | a collection's average size, within its bounds |
averageLength | average_length | averageLength | a string's average length in code points, within its bounds |
nonEmpty | non_empty | nonEmpty | a size or length of at least 1 |
nonBlank | non_blank | nonBlank | strings with at least one character outside strings.whitespace, built so, never filtered: a string drawn all whitespace has one place drawn again from the rest (decision 96) |
singleLine | single_line | singleLine | strings with no character of strings.lineBreaks, left out by index, never filtered (decision 96) |
mistyped | mistyped | mistyped | an identifier with one character typed wrong, which its check catches (decision 98) (the identifiers module) |
excluding | excluding | excluding | values left out of any domain, by equality: stepped over by index where the domain draws by index (whole numbers, elements, dates), else rejected as a filter rejects (decision 92); on dates also days of the week, a set of dates, or those a function names, drawn by index, never filtered (decision 79) |
on | on | on | only dates on the days of the week given, drawn by index, never filtered (decision 79) |
every | every | every | times, date-times or instants on a grid of one step only, counted from midnight (decision 81) |
inZones | in_zones | inZones | a date-time placed in a zone drawn from the domain given; a region zone's transitions are edges, and a wall time it repeats takes either offset (decisions 81 and 91) (provisional) |
places | places | places | the most places after the point a decimal domain draws (decision 82) |
inSerials | in_serials | inSerials | dates or date-times as serial numbers in a spreadsheet system: Excel 1900, Excel 1904 or OLE Automation (decision 85) (the serials module) |
inBase64 | in_base64 | inBase64 | the drawn bytes as base64 text, standard or URL-safe, padded or not, always canonical (decision 88) |
inHex | in_hex | inHex | the drawn bytes as hex text, lower or upper case (decision 88) |
nonCanonical | non_canonical | nonCanonical | encoded text a strict decoder must refuse: non-zero pad bits, wrong padding (decision 88) |
Bounds
| Java | Rust pending | Swift planned | What it does |
|---|---|---|---|
atLeast | at_least | atLeast | lower bound, inclusive |
atMost | at_most | atMost | upper bound, inclusive |
greaterThan | greater_than | greaterThan | lower bound, exclusive |
lessThan | less_than | lessThan | upper bound, exclusive |
On a source
| Java | Rust pending | Swift planned | What it does |
|---|---|---|---|
draw | draw | draw | draw a value from a domain, inside a named domain |
On steps
| Java | Rust pending | Swift planned | What it does |
|---|---|---|---|
step | step | step | one step, by name, with a domain for each of its arguments and what it does with them; as a function, step(name, arguments…) pins one step for .example |
when | when | when | the precondition of the step before it: a step whose precondition doesn't hold is skipped, and the run goes on |
invariant | invariant | invariant | what holds at the start and after every step, by name, so a failure can say which broke |
Where the editions differ
Section titled “Where the editions differ”Where a language makes the same word impossible or wrong, the contract registers the difference and says why. These are all of them:
| Id | What differs | Why |
|---|---|---|
E1 | How a setting is set besides its PROPTASTIC_* variable | Each language's runtime offers its own (Java's system properties); most have none. |
E2 | How a test is named: the name the random stream is keyed on (decision 12) and the manifest's id, class, method and signature | Each language names a test its own way: a class and a method's signature, a module path and a function. |
E3 | The command a rerun: line prints to run exactly one test (decisions 14 and 16), and the hosts it knows | Each ecosystem's build and test runners. |
E4 | Where counterexamples, events and the manifest go by default, and how processes running at once share the manifest | Each build tool has its own output directory. |
E5 | Where auto colour (decision 22) knows output is rendered, and the variables besides FORCE_COLOR that force it | Each ecosystem's runners show output differently, and has its own conventions for forcing colour. |
E6 | How a pin line spells values and steps as source (decision 30) | Each language's literals. |
E7 | The escape a value and a pin line use for a character that can't be seen (decision 17) | Each language's string literals. |
E8 | When the edition knows the draws' names (decision 31) | Whether a language keeps a closure's parameter names at run time. |
E9 | When the steps have a text for the state (decisions 32 and 39) | Whether generic code can ask a type for its text. |
E10 | How final states of steps on threads are compared, and what keys the search's cache (decision 39) | Each language's equality, and whether its text is safe to compare. |
E11 | When a step's own failure is threw rather than failed, and what it names (decisions 32 and 39) | Whether a language can tell a failure from a failed assertion. |
E12 | What generates typed steps and pins from an interface of steps (decision 38), and its pin form | Java's annotation processors, Rust's attribute macros, Swift's macros. |
E13 | How a state and its steps are shared across threads (decision 39) | A language's rules for sharing data between threads. |
E14 | What lock(name) returns, and how the code under test takes it (decision 39) | Each language's lock types. |
E15 | Which of the language's types a model's JSON writes as whole numbers, floating point, sum types' variants, sets and arrays (decision 33) | Each language's types, and its usual JSON library's form for them. |
E16 | The syntax matching(regex) reads, and the engine each draw is checked against (decision 42) | Each language's own regular expressions. |
E17 | What a string's length counts, which a counterexample's characters are shrunk against (decision 43) | Each language's own strings. |
E18 | How the edition runs TLC to check a spec's invariants on the code's state (decision 34) and judge the steps of a spec with no graph (decision 110) | TLC is a Java program: an edition on the JVM runs it on its own Java, others find one. |
E19 | Which hosts the CLI drives for the edition, how it runs exactly the properties it selects, and how it makes the host run when the build would call the tests up to date (decisions 49 and 50) | Each ecosystem's build tools and test runners. |
E20 | How example inserts a pin line into a property's chain, and what it refuses (decision 54) | Each language's syntax for a chain. |
E21 | How fuzz runs the properties for as long as it's given (decision 56) | Each ecosystem's runners: a JVM build is slow to start, and Rust's built test binaries run one test each. |
E22 | How the code under test is given switch points for .threads(n), and the interface it calls (decision 65) | Each runtime rewrites code its own way, or not at all. |
E23 | Which test checks the contract's golden counterexample ids, golden corpus entry names and the choices' text examples against the edition's own store (decisions 52 and 67) | Each edition's own contract test reads the one contract, in its own language. |
E24 | Which of the language's types dates(), times(), dateTimes(), instants(), durations(), offsets(), decimals() and uuids() draw, what .excluding and .on take, and where they're packaged (decisions 79 to 82) | The editions' types differ more here than anywhere else: Java has java.time in the JDK; Rust has none in std but SystemTime and an unsigned Duration, so its types come from crates, behind features; Swift's Foundation has Date, an instant only, and no civil date, so Swift settles its own date type before dates() binds. |
E25 | How with names the field of a by-type domain it gives a domain of its own | Each language names a field its own way: Java an accessor reference, Rust an attribute on a derive, as a closure can't name a field at run time (E8), Swift a key path. |
E26 | The language's character type, drawn by type as one character as strings draw it, in strings' order, a the simplest (decision 88) | The three languages mean three things by a character: Java a UTF-16 code unit, Rust a Unicode scalar, Swift an extended grapheme cluster, so no one word could mean one thing. |
E27 | How the alphabets in strings.alphabets are named for from(…): their characters, in order, are the contract's | Each language names constants its own way and keeps them in its own place: Java upper snake case on the class a test imports statically, Rust a module of &str constants, Swift static members found by leading dot (.lowercase). |
J1 | longs() beside integers() | Java has no generic numeric integers<T>: Rust says integers::<i64>(), Swift integers(Int64.self). |
J2 | PropertyFailure extends org.opentest4j.AssertionFailedError | It keeps what an IDE and a build tool read from the original: the message is the original's, a blank line and the report; expected, actual, the cause and the stack trace are copied from the original. |
J3 | the static atLeast, atMost, greaterThan and lessThan for sizes live in io.proptastic.bounds.Bounds | Java imports statics by class: their own small package, so import static io.proptastic.bounds.Bounds.*; reads well (Brian, 26 Nov). Mockito's static atLeast and atMost clash with a star import of both, which is accepted. |
J4 | In Kotlin, .with(Line::quantity, d) from proptastic-kotlin names a data class's property by KProperty1 | A Kotlin property reference reaches Java as a lambda that hides its name; the extension lets Kotlin name it, and keeps Kotlin out of the library's jar (decision 44). |
J5 | io.proptastic.Points's methods, each what rewritten code calls in place of, or before, its own | The agent's rewriting calls them, not a person: each is named for the call it stands in for, a monitor's wait and notify as waitOn and notifyOn, as Object's are final; unswitched goes before a call no point can be put inside, which the next pass says; LockSupport's, a blocking queue's and a StampedLock's calls that wait keep their own names (decision 65). |
J6 | io.proptastic.Probes.hit(id), what code rewritten for coverage calls at each probe | The agent's rewriting calls it, not a person (decision 66). |
J7 | io.proptastic.Fuzzing's arm, stop, result, disarm and running, what fuzz's worker calls to search a property | The worker calls them, not a person: an edition's fuzz worker reaches its library its own way (decision 69). |
J8 | io.proptastic.Compares' icmp, lcmp and equals, what code rewritten for coverage calls in place of its comparisons | The agent's rewriting calls them, not a person, each named for the comparison it stands in for (decision 71). |
J9 | unsigned, 128-bit and platform-width integers | Java has no unsigned, 128-bit or platform-width integer types; char is its only unsigned primitive. Storing an unsigned value in signed bits, as Protocol Buffers does, would shrink toward the wrong zero and weight the wrong end, and print 2^64-1 as -1. Instead: bigIntegers().atLeast(BigInteger.ZERO).atMost(…) for an unsigned or a 128-bit value; longs() only for a 64-bit pattern the code already reads as unsigned, such as with Long.toUnsignedString. |
J10 | java(TheModel.class), and Model.serve, outcome and answer, for a model written in Java | A model in Java speaks the protocol through the library, from its own main, and runs with the tests' own Java (decision 104); a model in another language is that language's program, run by command(…). |
R1 | a tuple for several draws, for_all((a, b)), several-draw examples, .example((a, b)), and two size bounds, of_size((at_least(1), at_most(50))) | Rust has no variadics or overloads. |
R2 | integers::<i32>(), with a turbofish | Rust can't default a function's type parameter. |
R3 | the helper traits IntoDomain, SourceForm and IntoExcluding | For range and tuple domains, pin lines, and the shapes .excluding(…) takes (decisions 79 and 92): Rust has no overloads. |
R4 | domain_of((d1, d2, d3), |(a, b, c)| …) for the combined form | Rust has no overloads, so domain(|d| …) keeps the name and the combined form takes a second one (Brian, 24 Nov). |
R5 | an Arbitrary trait (Rust) or protocol (Swift) behind any::<T>() and any(T.self) | VOCABULARY.md's any row: Java finds a domain from the class by reflection; Rust and Swift put a trait or protocol behind it. |
R6 | the failed at and saved facts; a failing pinned example prints them too | VOCABULARY.md's failure output: Rust only. saved is a JSON file under target/proptastic/. |
R7 | domains draw owned values only: String, Vec<u8>, PathBuf, never &str or &[u8]; the check borrows | A value must outlive its try to be shrunk, replayed, printed and saved; borrowed data can't. proptastic's fuzz reads choices, not a buffer to slice. |
S1 | into: before a constructor: domain(d1, d2, into: Trade.init) | Swift requires a label on a parameter that follows a parameter pack. The trailing-closure form, domain(d1, d2) { a, b in … }, needs none. |
S2 | try assume(…) | Swift can leave a closure only by throwing. Write try #expect(…) when the checked expression throws (a Swift rule). |
S3 | .ofSize(atLeast: 1, atMost: 50), labelled with the bound words | VOCABULARY.md's bounds: Swift labels the arguments, with the same words, as Swift does. |
S4 | arbitrary-precision integers | Swift's standard library has no big integer type, and proptastic doesn't invent one. Instead: integers(Int128.self), the range an unbounded bigIntegers() draws elsewhere. |
Editions says which editions there are, and how far along each is.