liveBook · Manning

forAllPar

As explained in Functional Programming in Scala, Second Edition

forAllPar is a property-construction function that generates parallel computations and evaluates their properties across executor variations.

forAllPar constructs properties for parallel computations by generating both an input and an executor, then running the computation inside the property test.

It separates executor management from the property itself, avoiding repeated run and get calls while testing behavior across several parallel strategies. section 8.2.3

Testing map identity

val gpy: Gen[Par[Int]] = Gen.choose(0,10).map(Par.unit(_)) val property = Prop.forAllPar(gpy)(py => equal(py.map(y => y), py))

How Functional Programming in Scala, Second Edition covers it

How deep it goes
Defines the implementation through generated executor-input pairs and stops short of deeper executor semantics.
Examples
Uses identity-map testing and comparisons between Par.unit computations across generated executors.
What it assumes
Builds on Gen, Prop, Par, and executor APIs rather than introducing those abstractions from zero.
What you can do after
Apply it via property-based tests that exercise parallel computations under multiple executor strategies.
How it connects
Connects property-based testing with Par, Gen, Prop, and ExecutorService.

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.