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

PlutusCore.Generators.Hedgehog.Test

Description

This module defines functions useful for testing.

Synopsis

Documentation

data TypeEvalCheckError uni fun Source #

The type of errors that can occur during type-eval checking.

Constructors

TypeEvalCheckErrorIllFormed !(Error uni fun ()) 
TypeEvalCheckErrorIllTyped !(Normalized (Type TyName uni ())) !(Normalized (Type TyName uni ())) 
TypeEvalCheckErrorException !String 
TypeEvalCheckErrorIllEvaled !(EvaluationResult (HeadSpine (Term TyName Name uni fun ()))) !(EvaluationResult (Term TyName Name uni fun ()))

The former is an expected result of evaluation, the latter -- is an actual one.

Instances

Instances details
(PrettyBy config (Type TyName uni ()), PrettyBy config (Term TyName Name uni fun ()), PrettyBy config (HeadSpine (Term TyName Name uni fun ())), PrettyBy config (Error uni fun ())) ⇒ PrettyBy config (TypeEvalCheckError uni fun) Source # 
Instance details

Defined in PlutusCore.Generators.Hedgehog.TypeEvalCheck

Methods

prettyBy ∷ config → TypeEvalCheckError uni fun → Doc ann Source #

prettyListBy ∷ config → [TypeEvalCheckError uni fun] → Doc ann Source #

ann ~ () ⇒ AsError (TypeEvalCheckError uni fun) uni fun ann Source # 
Instance details

Defined in PlutusCore.Generators.Hedgehog.TypeEvalCheck

Methods

_Error ∷ Prism' (TypeEvalCheckError uni fun) (Error uni fun ann) Source #

_ParseErrorE ∷ Prism' (TypeEvalCheckError uni fun) ParserErrorBundle Source #

_UniqueCoherencyErrorE ∷ Prism' (TypeEvalCheckError uni fun) (UniqueError ann) Source #

_TypeErrorE ∷ Prism' (TypeEvalCheckError uni fun) (TypeError (Term TyName Name uni fun ()) uni fun ann) Source #

_NormCheckErrorE ∷ Prism' (TypeEvalCheckError uni fun) (NormCheckError TyName Name uni fun ann) Source #

_FreeVariableErrorE ∷ Prism' (TypeEvalCheckError uni fun) FreeVariableError Source #

ann ~ () ⇒ AsTypeError (TypeEvalCheckError uni fun) (Term TyName Name uni fun ann) uni fun ann Source # 
Instance details

Defined in PlutusCore.Generators.Hedgehog.TypeEvalCheck

Methods

_TypeError ∷ Prism' (TypeEvalCheckError uni fun) (TypeError (Term TyName Name uni fun ann) uni fun ann) Source #

_KindMismatch ∷ Prism' (TypeEvalCheckError uni fun) (ann, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ()) Source #

_TypeMismatch ∷ Prism' (TypeEvalCheckError uni fun) (ann, Term TyName Name uni fun ann, ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ())) Source #

_TyNameMismatch ∷ Prism' (TypeEvalCheckError uni fun) (ann, TyName, TyName) Source #

_NameMismatch ∷ Prism' (TypeEvalCheckError uni fun) (ann, Name, Name) Source #

_FreeTypeVariableE ∷ Prism' (TypeEvalCheckError uni fun) (ann, TyName) Source #

_FreeVariableE ∷ Prism' (TypeEvalCheckError uni fun) (ann, Name) Source #

_UnknownBuiltinFunctionE ∷ Prism' (TypeEvalCheckError uni fun) (ann, fun) Source #

data TypeEvalCheckResult uni fun Source #

Type-eval checking of a term results in a value of this type.

Constructors

TypeEvalCheckResult 

Fields

type TypeEvalCheckM uni fun = Either (TypeEvalCheckError uni fun) Source #

The monad type-eval checking runs in.

typeEvalCheckBy Source #

Arguments

∷ (uni ~ DefaultUni, fun ~ DefaultFun, KnownTypeAst TyName uni a, MakeKnown (Term TyName Name uni fun ()) a, PrettyPlc structural) 
⇒ (Term TyName Name uni fun () → Either (EvaluationException structural operational (Term TyName Name uni fun ())) (Term TyName Name uni fun ()))

An evaluator.

TermOf (Term TyName Name uni fun ()) a 
TypeEvalCheckM uni fun (TermOf (Term TyName Name uni fun ()) (TypeEvalCheckResult uni fun)) 

Type check and evaluate a term and check that the expected result is equal to the actual one.

unsafeTypeEvalCheck ∷ (uni ~ DefaultUni, fun ~ DefaultFun, KnownTypeAst TyName uni a, MakeKnown (Term TyName Name uni fun ()) a) ⇒ TermOf (Term TyName Name uni fun ()) a → TermOf (Term TyName Name uni fun ()) (EvaluationResult (Term TyName Name uni fun ())) Source #

Type check and evaluate a term and check that the expected result is equal to the actual one. Throw an error in case something goes wrong.

getSampleTermValue ∷ (uni ~ DefaultUni, fun ~ DefaultFun, KnownTypeAst TyName uni a, MakeKnown (Term TyName Name uni fun ()) a) ⇒ TermGen a → IO (TermOf (Term TyName Name uni fun ()) (EvaluationResult (Term TyName Name uni fun ()))) Source #

Generate a term using a given generator and check that it's well-typed and evaluates correctly.

getSampleProgramAndValue ∷ (uni ~ DefaultUni, fun ~ DefaultFun, KnownTypeAst TyName uni a, MakeKnown (Term TyName Name uni fun ()) a) ⇒ TermGen a → IO (Program TyName Name uni fun (), EvaluationResult (Term TyName Name uni fun ())) Source #

Generate a program using a given generator and check that it's well-typed and evaluates correctly.

printSampleProgramAndValue ∷ (uni ~ DefaultUni, fun ~ DefaultFun, KnownTypeAst TyName uni a, MakeKnown (Term TyName Name uni fun ()) a) ⇒ TermGen a → IO () Source #

Generate a program using a given generator, check that it's well-typed and evaluates correctly and pretty-print it to stdout using the default pretty-printing mode.

sampleProgramValueGolden Source #

Arguments

∷ (uni ~ DefaultUni, fun ~ DefaultFun, KnownTypeAst TyName uni a, MakeKnown (Term TyName Name uni fun ()) a) 
String
folder
String
name
TermGen a

A term generator.

IO () 

Generate a pair of files: folder.name.plc and folder.name.plc.golden. The first file contains a term generated by a term generator (wrapped in Program), the second file contains the result of evaluation of the term.

propEvaluate Source #

Arguments

∷ (uni ~ DefaultUni, fun ~ DefaultFun, KnownTypeAst TyName uni a, MakeKnown (Term TyName Name uni fun ()) a, PrettyPlc structural) 
⇒ (Term TyName Name uni fun () → Either (EvaluationException structural operational (Term TyName Name uni fun ())) (Term TyName Name uni fun ()))

An evaluator.

TermGen a

A term/value generator.

Property 

A property-based testing procedure for evaluators. Checks whether a term generated along with the value it's supposed to compute to indeed computes to that value according to the provided evaluate.