| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Evaluation.Builtins.Conformance
Description
Write generated conformance test cases shared by the builtin property suites.
Synopsis
- data OutputFormat
- data CheckMode
- checkModeName ∷ CheckMode → String
- type PropertyFilter = PropertyId → Bool
- data PropertyId = PropertyId {}
- data PropertySpec gen = PropertySpec {}
- caseNumberDigits ∷ Int
- checkUniqueIds ∷ [String] → [PropertySpec gen] → IO ()
- propertyIdPath ∷ PropertyId → FilePath
- propertyIdText ∷ PropertyId → String
- propertySpecPropertyIds ∷ [String] → [PropertySpec gen] → [PropertyId]
- data TermCase
- data Generated = Generated {}
- data PropertyReport = PropertyReport {}
- data Check
- formatName ∷ OutputFormat → String
- caseTerms ∷ CheckMode → Check → [TermCase]
- caseTermsUnchecked ∷ Check → [TermCase]
- checkHolds ∷ CheckMode → Check → Bool
- guardCheck ∷ CheckMode → Check → [TermCase] → [TermCase]
- isCekSuccess ∷ TypeErrorOrCekResult → Bool
- evaluationFailureText ∷ Text
- generateTermFiles ∷ OutputFormat → FilePath → Int → PropertyId → String → [TermCase] → IO Generated
- propertySeed ∷ QCGen → PropertyId → QCGen
- samplingSize ∷ Int
Documentation
data OutputFormat Source #
Representations to write for each generated case. Both formats share a budget.
How thoroughly a sampled case is checked against its property before it is written.
FastCheckevaluates the terms with the untyped CEK machine, as the exporter does to record results. It confirms that the reference implementation satisfies the property but does not typecheck the terms.FullCheckusesevalTerm, exactly as the normal tests do: it typechecks the terms and evaluates them with a freshly built typed evaluator. That setup is repeated for every case, which makes it much slower.
checkModeName ∷ CheckMode → String Source #
Name of a mode, as recorded in the info file.
type PropertyFilter = PropertyId → Bool Source #
Select a property by its path relative to the output root, without case numbers or filename extensions (for example, integerRingPropertiesaddition_associative).
data PropertyId Source #
Location of a property relative to the output root, for example
integerRingPropertiesaddition_associative. Keeping the segments apart lets
match keys use / on every platform while file paths use the native separator.
Constructors
| PropertyId | |
Fields
| |
Instances
| Show PropertyId Source # | |
Defined in Evaluation.Builtins.Conformance | |
| Eq PropertyId Source # | |
Defined in Evaluation.Builtins.Conformance | |
| Ord PropertyId Source # | |
Defined in Evaluation.Builtins.Conformance Methods compare ∷ PropertyId → PropertyId → Ordering Source # (<) ∷ PropertyId → PropertyId → Bool Source # (<=) ∷ PropertyId → PropertyId → Bool Source # (>) ∷ PropertyId → PropertyId → Bool Source # (>=) ∷ PropertyId → PropertyId → Bool Source # max ∷ PropertyId → PropertyId → PropertyId Source # min ∷ PropertyId → PropertyId → PropertyId Source # | |
data PropertySpec gen Source #
A property with the identifier and description shared by the normal test suite and the conformance generator, together with the sampler that produces its inputs.
Constructors
| PropertySpec | |
Fields
| |
caseNumberDigits ∷ Int Source #
Number of digits used to number cases, for example 00001.
checkUniqueIds ∷ [String] → [PropertySpec gen] → IO () Source #
Fail if two properties in a suite share an identifier: their cases would be written to the same directories, silently overwriting each other.
propertyIdPath ∷ PropertyId → FilePath Source #
Directory for the property, relative to the output root.
propertyIdText ∷ PropertyId → String Source #
Identifier used for matching and display: segments joined by /.
propertySpecPropertyIds ∷ [String] → [PropertySpec gen] → [PropertyId] Source #
Generated test case identifiers for a suite's properties, in declaration order.
Keep the terms of an equality check together until their filenames are assigned.
Constructors
| SingleTerm PlcTerm | |
| EqualTerms PlcTerm PlcTerm | |
| ViolatedCase String | Why the reference implementation does not satisfy the property for this input. No files are written for such a case. |
What was written for one property.
Constructors
| Generated | |
Fields
| |
data PropertyReport Source #
A property together with the cases written for it.
Constructors
| PropertyReport | |
Instances
| Show PropertyReport Source # | |
Defined in Evaluation.Builtins.Conformance | |
| Eq PropertyReport Source # | |
Defined in Evaluation.Builtins.Conformance Methods (==) ∷ PropertyReport → PropertyReport → Bool Source # (/=) ∷ PropertyReport → PropertyReport → Bool Source # | |
A property check expressed without performing it. Normal QuickCheck suites
interpret it as an assertion, the Hedgehog suites have their own interpreter,
and the test generator extracts its terms, first checking with checkHolds that
the reference implementation satisfies the property for the sampled input.
Constructors
| CheckEq PlcTerm PlcTerm | Both terms evaluate successfully to equal results. |
| CheckEvaluatesTo PlcTerm TypeErrorOrCekResult | The term evaluates to the given result. |
| CheckTrue PlcTerm | The term evaluates successfully to |
| CheckOk PlcTerm | The term evaluates successfully. |
| CheckFails PlcTerm | The term fails to evaluate. |
| CheckBoth Check Check | Both checks must hold. When generating, each check contributes its own numbered cases, so one sampled input can use several numbers. |
| CheckImplies Bool Check | |
| CheckDistinct [PlcTerm] | All terms evaluate successfully to pairwise distinct results. |
| CheckSatisfies String PlcTerm (TypeErrorOrCekResult → Bool) | The term's result satisfies the predicate, labelled for failure reports. |
formatName ∷ OutputFormat → String Source #
Name of a format, as accepted on the command line and recorded in the info file.
caseTerms ∷ CheckMode → Check → [TermCase] Source #
The terms to write for a check, after confirming that it holds. Preconditions still select suitable inputs. Kept lazy so reaching the case limit need not inspect later checks.
caseTermsUnchecked ∷ Check → [TermCase] Source #
As caseTerms, but without checking that the property holds.
checkHolds ∷ CheckMode → Check → Bool Source #
Whether the reference implementation satisfies a check. This mirrors the
Testable instance, so the cases written out are those the normal tests would
accept. With FullCheck the terms are evaluated, and typechecked, exactly as
the normal tests do; with FastCheck they are evaluated by the untyped machine
alone. A false precondition counts as satisfied, since such inputs are discarded
rather than tested.
guardCheck ∷ CheckMode → Check → [TermCase] → [TermCase] Source #
Replace the terms of a check by a violation if the reference implementation does not satisfy it. Writing such a case would record behaviour that contradicts the property as if it were the expected result.
isCekSuccess ∷ TypeErrorOrCekResult → Bool Source #
Successful evaluations only.
evaluationFailureText ∷ Text Source #
Text recorded in .expected and .budget.expected files when evaluation
fails. The conformance harness compares those files verbatim against its own
shownEvaluationFailure; that constant lives in PlutusConformance.Common,
which depends on this library, so it cannot be imported here. Keep them in step.
generateTermFiles ∷ OutputFormat → FilePath → Int → PropertyId → String → [TermCase] → IO Generated Source #
Consume at most the requested number of cases, writing each one as it is
produced so that memory use does not grow with the number of cases. The count is
a number of terms, not of sampled inputs: an equality check emits both terms
under one number with -A/-B suffixes, while a check that combines several terms
(for example CheckBoth) supplies one numbered case per term. Each term has its
own result and budget files. A case that violates its property, or a stream with
fewer cases than requested, is an error.
propertySeed ∷ QCGen → PropertyId → QCGen Source #
The random generator for one property, derived from the run's seed and the property's identifier. Using the seed directly for every property would give them all the same stream of random numbers, and so correlated inputs. Deriving it from the identifier also means that the cases generated for a property do not depend on which other properties are selected.
Size passed to the generators when sampling inputs.