plutus-conformance-1.0.0.0: Conformance Test Suite for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusConformance.Common

Description

Plutus conformance test suite library.

Synopsis

Documentation

shownParseErrorText Source #

The default shown text when a parse error occurs. We don't want to show the detailed parse errors so that users of the test suite can produce the expected output more easily.

shownEvaluationFailureText Source #

The default shown text when evaluation fails.

parseTxtTextEither ParserErrorBundle (Program Name DefaultUni DefaultFun SrcSpan) Source #

The default parser to parse UPLC program inputs.

type UplcProg = Program Name DefaultUni DefaultFun () Source #

The input/output UPLC program type.

data UplcEvaluator Source #

The evaluator to be tested.

Constructors

UplcEvaluatorWithoutCosting (UplcEvaluatorFun UplcProg)

An evaluator that just produces an output program, or fails.

UplcEvaluatorWithCosting (CostModelParamsUplcEvaluatorFun (UplcProg, ExBudget))

An evaluator that produces an output program along with the cost of evaluating it, or fails. Note that nothing cares about the cost of failing programs, so we don't test for conformance there.

discoverTests Source #

Arguments

UplcEvaluator

The evaluator to be tested.

CostModelParams 
→ (FilePathBool)

A function that takes a test directory and returns a Bool indicating whether the evaluation test for the file in that directory is expected to fail.

→ (FilePathBool)

A function that takes a test directory and returns a Bool indicating whether the budget test for the file in that directory is expected to fail.

FilePath

The directory to search for tests.

IO TestTree 

Walk a file tree, making test groups for directories with subdirectories, and test cases for directories without.

expectedToProgTextEither Text UplcProg Source #

Turn the expected file content in text to a UplcProg unless the expected result is a parse or evaluation error.

getTestedValueUplcEvaluatorFun res → FilePathIO (Either Text res) Source #

Get the tested value. The tested value is either the shown parse or evaluation error, or a UplcProg.

compareAlphaEq Source #

Arguments

Either Text UplcProg

golden value

Either Text UplcProg

tested value

Maybe String

If two values are the same, it returns Nothing. If they are different, it returns an error that will be printed to the user.

The comparison function used for the golden test. This function checks alpha-equivalence of programs when the output is a program.

updateGoldenFile Source #

Arguments

FilePath

the path to write the golden file to

Either Text UplcProg 
IO () 

Update the golden file with the tested value. TODO abstract out for other tests.

runUplcEvalTests Source #

Arguments

UplcEvaluator

The action to run the input through for the tests.

→ (FilePathBool)

A function that takes a test name and returns whether it should labelled as ExpectedFailure.

→ (FilePathBool)

A function that takes a test name and returns whether it should labelled as ExpectedBudgetFailure.

IO () 

Run the UPLC evaluation tests given an evaluator that evaluates UPLC programs.