Puregrain.SelfCheck
- Package
- purescript-puregrain
- Repository
- roman-mkh/puregrain
Checks that the JavaScript engine running the library computes its
light curves (Puregrain.Gamma) exactly as the reference does, so that
dithering with them gives the same results here as everywhere else.
The curves use only operations that the JavaScript standard defines exactly, so every correct engine gives the same bits. This check makes sure, on the engine at hand: an engine with a fault in its arithmetic, or an optimizing compiler that changes it, would fail it. A pass means that this engine computed the reference values exactly: strong evidence, not proof for every value. Why and how: docs/exact-arithmetic.md.
report <- checkEngine
unless (exactArithmetic report) do
for_ (problems report) log
#checkEngine Source
checkEngine :: Effect EngineReportRuns the check on this engine.
Returns the report. It takes a fraction of a second: each of the four computed curves is converted both ways for about 200,000 values, so that the engine's optimizing compilers run too. Nothing runs until it's called.
#exactArithmetic Source
exactArithmetic :: EngineReport -> BooleanWhether the engine computed every reference value exactly.
#problems Source
problems :: EngineReport -> Array StringWhat failed, one sentence for each problem; empty when everything passed. Each names the curve and direction, or the byte, concerned.
Re-exports from Puregrain.Internal.SelfCheck
#EngineReport Source
newtype EngineReportThe result of Puregrain.SelfCheck.checkEngine: whether the
JavaScript engine computed the light curves exactly as the reference,
and if not, what differed.
- Modules
- Puregrain
- Puregrain.
Cells - Puregrain.
Dither - Puregrain.
Gamma - Puregrain.
Internal. Exact - Puregrain.
Internal. Fifo - Puregrain.
Internal. Gamma - Puregrain.
Internal. Image - Puregrain.
Internal. Kernel - Puregrain.
Internal. Quantize - Puregrain.
Internal. Row - Puregrain.
Internal. SelfCheck - Puregrain.
Internal. State - Puregrain.
Internal. Step - Puregrain.
Internal. Util - Puregrain.
Kernel - Puregrain.
Machine. C64 - Puregrain.
Machine. ZxSpectrum - Puregrain.
Ordered - Puregrain.
Palette - Puregrain.
Palette. Presets - Puregrain.
Pixel - Puregrain.
Quantize - Puregrain.
SelfCheck