plutus-core-1.72.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

Evaluation.Builtins.Conformance

Description

Write generated conformance test cases shared by the builtin property suites.

Synopsis

Documentation

data OutputFormat Source #

Representations to write for each generated case. Both formats share a budget.

Constructors

Flat 
Uplc 
Both 

data CheckMode Source #

How thoroughly a sampled case is checked against its property before it is written.

  • FastCheck evaluates 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.
  • FullCheck uses evalTerm, 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.

Constructors

FastCheck 
FullCheck 

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

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.

data TermCase Source #

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.

data Generated Source #

What was written for one property.

Constructors

Generated 

Fields

Instances

Instances details
Show Generated Source # 
Instance details

Defined in Evaluation.Builtins.Conformance

Eq Generated Source # 
Instance details

Defined in Evaluation.Builtins.Conformance

data PropertyReport Source #

A property together with the cases written for it.

data Check 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 True.

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.

Instances

Instances details
Testable Check Source # 
Instance details

Defined in Evaluation.Builtins.Conformance

Methods

property ∷ Check → Property #

propertyForAllShrinkShow ∷ Gen a → (a → [a]) → (a → [String]) → (a → Check) → Property #

Show Check Source #

Shows the terms of a check; the predicate of CheckSatisfies is omitted.

Instance details

Defined in Evaluation.Builtins.Conformance

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.

samplingSize ∷ Int Source #

Size passed to the generators when sampling inputs.