Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Plutus conformance test suite library.
Synopsis
- shownParseError ∷ Text
- shownEvaluationFailure ∷ Text
- parseTxt ∷ Text → Either ParserErrorBundle (Program Name DefaultUni DefaultFun SrcSpan)
- type UplcProg = Program Name DefaultUni DefaultFun ()
- type UplcEvaluatorFun res = UplcProg → Maybe res
- data UplcEvaluator
- discoverTests ∷ UplcEvaluator → CostModelParams → (FilePath → Bool) → (FilePath → Bool) → FilePath → IO TestTree
- expectedToProg ∷ Text → Either Text UplcProg
- getTestedValue ∷ UplcEvaluatorFun res → FilePath → IO (Either Text res)
- compareAlphaEq ∷ Either Text UplcProg → Either Text UplcProg → Maybe String
- updateGoldenFile ∷ FilePath → Either Text UplcProg → IO ()
- runUplcEvalTests ∷ UplcEvaluator → (FilePath → Bool) → (FilePath → Bool) → IO ()
Documentation
shownParseError ∷ Text 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.
shownEvaluationFailure ∷ Text Source #
The default shown text when evaluation fails.
parseTxt ∷ Text → Either 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.
type UplcEvaluatorFun res = UplcProg → Maybe res Source #
data UplcEvaluator Source #
The evaluator to be tested.
UplcEvaluatorWithoutCosting (UplcEvaluatorFun UplcProg) | An evaluator that just produces an output program, or fails. |
UplcEvaluatorWithCosting (CostModelParams → UplcEvaluatorFun (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. |
∷ 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. |
→ 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.
expectedToProg ∷ Text → Either Text UplcProg Source #
Turn the expected file content in text to a UplcProg
unless the expected result
is a parse or evaluation error.
getTestedValue ∷ UplcEvaluatorFun res → FilePath → IO (Either Text res) Source #
Get the tested value. The tested value is either the shown parse or evaluation error,
or a UplcProg
.
∷ Either Text UplcProg | golden value |
→ Either Text UplcProg | tested value |
→ Maybe String | If two values are the same, it returns |
The comparison function used for the golden test. This function checks alpha-equivalence of programs when the output is a program.
Update the golden file with the tested value. TODO abstract out for other tests.
∷ 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 |
→ (FilePath → Bool) | A function that takes a test name and returns
whether it should labelled as |
→ IO () |
Run the UPLC evaluation tests given an evaluator
that evaluates UPLC programs.