Skip to content

Commit

Permalink
[Test] [Builtins] Add golden tests with unlifting errors (#6189)
Browse files Browse the repository at this point in the history
This refactors a file with tests so that unit tests that are supposed to result in evaluation failure also become golden tests with the error message printed to a golden file. Need it to demonstrate that #6181 does indeed allow us to preserve operational unlifting errors.
  • Loading branch information
effectfully committed Aug 6, 2024
1 parent 840ecce commit c6bd1c2
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 166 deletions.
4 changes: 2 additions & 2 deletions plutus-core/plutus-core/src/PlutusCore/Builtin/HasConstant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class HasConstant term where
type HasConstantIn uni term = (UniOf term ~ uni, HasConstant term)

-- | Wrap a Haskell value (given its explicit type tag) as a @term@.
fromValueOf :: HasConstant term => UniOf term (Esc a) -> a -> term
fromValueOf :: forall a term. HasConstant term => UniOf term (Esc a) -> a -> term
fromValueOf uni = fromConstant . someValueOf uni
{-# INLINE fromValueOf #-}

-- | Wrap a Haskell value (provided its type is in the universe) as a @term@.
fromValue :: (HasConstant term, UniOf term `HasTermLevel` a) => a -> term
fromValue :: forall a term. (HasConstant term, UniOf term `HasTermLevel` a) => a -> term
fromValue = fromValueOf knownUni
{-# INLINE fromValue #-}

Expand Down
382 changes: 218 additions & 164 deletions plutus-core/untyped-plutus-core/test/Evaluation/Builtins/Definition.hs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: (force headList [])
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: (force tailList [])
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: (consByteString 256 #68656c6c6f20776f726c64)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: (indexByteString # 0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: (indexByteString #68656c6c6f20776f726c64 12)

0 comments on commit c6bd1c2

Please sign in to comment.