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
  • shownParseError :: Text #

    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.

shownEvaluationFailure :: 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 #

Arguments

:: UplcEvaluator

The evaluator to be tested.

-> CostModelParams 
-> (FilePath -> Bool)

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.

-> (FilePath -> Bool)

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.

-> TestTree 

Walk a file tree, making test groups for directories with subdirectories, and test cases for directories without. We expect every test directory to contain a single `.uplc` file whose name matches that of the directory. For example, the directory `modInteger-15` should contain `modInteger-15.uplc`, and that file should contain a textual UPLC program. The directory should also contain golden files `modInteger-15.uplc.expected`, containing the expected output of the program, and `modInteger-15.uplc.budget.expected`, containing the expected execution budget, although these will be created by the testing machinery if they aren't already present.

expectedToProg :: Text UplcProg #

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

getTestedValue :: UplcEvaluatorFun res -> Text res) #

Get the tested value from a file (in this case a textual UPLC source file). The tested value is either the shown parse error or evaluation error, or a UplcProg.

compareAlphaEq #

Arguments

:: 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 #

Arguments

:: Text UplcProg 
-> IO () 

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

runUplcEvalTests #

Arguments

:: UplcEvaluator

The action to run the input through for the tests.

-> (FilePath -> Bool)

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

-> (FilePath -> Bool)

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.