Conformance.Term.ConstantCase.Data

Conformance tests generated from plutus-conformance/test-cases/uplc/evaluation/term/constant-case/data. See Conformance.Eval for how they are run.

module Conformance.Term.ConstantCase.Data where

open import Conformance.Eval

data-01

-- term/constant-case/data/data-01
-- case on Data.Constr with no fields
test-data-01 : Untyped
test-data-01 = (UCase (UCon (tagCon pdata (ConstrDATA (ℤ.pos 0) ([])))) ((ULambda (UCon (tagCon integer (ℤ.pos 42)))) ∷ []))

expected-data-01 : Result
expected-data-01 = success (UCon (tagCon integer (ℤ.pos 42)))

_ : evalRaw test-data-01 ≡ expected-data-01
_ = refl

data-02

-- term/constant-case/data/data-02
-- select the second Data.Constr branch and pass its fields to the handler
test-data-02 : Untyped
test-data-02 = (UCase (UCon (tagCon pdata (ConstrDATA (ℤ.pos 1) ((iDATA (ℤ.pos 42)) ∷ (bDATA (mkByteString "\171\205")) ∷ (ListDATA ((iDATA (ℤ.pos 7)) ∷ [])) ∷ [])))) ((ULambda (UCon (tagCon integer (ℤ.pos 0)))) ∷ (ULambda (UVar 0)) ∷ []))

expected-data-02 : Result
expected-data-02 = success (UCon (tagCon (list pdata) ((iDATA (ℤ.pos 42)) ∷ (bDATA (mkByteString "\171\205")) ∷ (ListDATA ((iDATA (ℤ.pos 7)) ∷ [])) ∷ [])))

-- Pending: bytestring inside a `data` constant.
pending-data-02 : Set
pending-data-02 = Pending (evalRaw test-data-02 ≡ expected-data-02)

data-03

-- term/constant-case/data/data-03
-- Data.Constr tag is out of bounds
test-data-03 : Untyped
test-data-03 = (UCase (UCon (tagCon pdata (ConstrDATA (ℤ.pos 2) ([])))) ((ULambda (UVar 0)) ∷ (ULambda (UVar 0)) ∷ []))

expected-data-03 : Result
expected-data-03 = failure

_ : evalRaw test-data-03 ≡ expected-data-03
_ = refl

data-04

-- term/constant-case/data/data-04
-- the selected handler must accept the Data.Constr fields
test-data-04 : Untyped
test-data-04 = (UCase (UCon (tagCon pdata (ConstrDATA (ℤ.pos 0) ([])))) ((UCon (tagCon integer (ℤ.pos 42))) ∷ []))

expected-data-04 : Result
expected-data-04 = failure

_ : evalRaw test-data-04 ≡ expected-data-04
_ = refl

data-05

-- term/constant-case/data/data-05
-- case on Data only supports Data.Constr values
test-data-05 : Untyped
test-data-05 = (UCase (UCon (tagCon pdata (iDATA (ℤ.pos 42)))) ((ULambda (UVar 0)) ∷ []))

expected-data-05 : Result
expected-data-05 = failure

_ : evalRaw test-data-05 ≡ expected-data-05
_ = refl