liveBook · Manning

Verify

As explained in Functional Programming in Scala, Second Edition

verify is a property-construction function that proves a supplied Boolean expression by evaluating it once.

verify constructs a property from a hardcoded Boolean expression. Unlike forAll, it evaluates that expression once instead of generating and repeating irrelevant test cases. section 8.2.3

Proving a parallel computation

A direct property compares two parallel results: Prop.verify(equal(Par.unit(1).map(_ + 1), Par.unit(2)).run(executor).get). The Boolean is evaluated once, and the result is classified as Proved rather than Passed.

How Functional Programming in Scala, Second Edition covers it

How deep it goes
Defines the primitive, memoized implementation, Proved result, and runner changes; defers proving some forAll properties to an exercise.
Examples
Uses hardcoded equality checks for Par computations and contrasts them with generated identity properties.
What it assumes
Assumes Prop as a function over test parameters and familiarity with forAll, while exposing Result and runner changes explicitly.
What you can do after
Build it from scratch by implementing verify, classifying successful checks as Proved, and updating the runner to report them.
How it connects
Connects property-based testing with forAll, Prop combinators, Result, test runners, and parallel computations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in Scala, Second Edition. The section links point to the parts of the book it draws on.