/
Spec.hs
65 lines (51 loc) · 1.89 KB
/
Spec.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fplugin PlutusTx.Plugin #-}
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-}
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:max-simplifier-iterations=0 #-}
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:no-context #-}
module Budget.Spec where
import Budget.Lib (goldenBudget)
import Common
import Lib (goldenPir)
import PlutusTx.Code
import PlutusTx.Prelude qualified as PlutusTx
import PlutusTx.TH (compile)
tests :: TestNested
tests = testNested "Budget" [
goldenBudget "sum" compiledSum
, goldenPir "sum" compiledSum
, goldenBudget "any" compiledAny
, goldenPir "any" compiledAny
, goldenBudget "find" compiledFind
, goldenPir "find" compiledFind
, goldenBudget "filter" compiledFilter
, goldenPir "filter" compiledFilter
, goldenBudget "elem" compiledElem
, goldenPir "elem" compiledElem
]
compiledSum :: CompiledCode Integer
compiledSum = $$(compile [||
let ls = [1,2,3,4,5,6,7,8,9,10] :: [Integer]
in PlutusTx.sum ls ||])
compiledAny :: CompiledCode Bool
compiledAny = $$(compile [||
let ls = [1,2,3,4,5,6,7,8,9,10] :: [Integer]
in PlutusTx.any ((PlutusTx.>) 10) ls ||])
compiledFind :: CompiledCode (Maybe Integer)
compiledFind = $$(compile [||
let ls = [1,2,3,4,5,6,7,8,9,10] :: [Integer]
in PlutusTx.find ((PlutusTx.>) 10) ls ||])
compiledFilter :: CompiledCode [Integer]
compiledFilter = $$(compile [||
let ls = [1,2,3,4,5,6,7,8,9,10] :: [Integer]
in PlutusTx.filter PlutusTx.even ls ||])
compiledElem :: CompiledCode Bool
compiledElem = $$(compile [||
let ls = [1,2,3,4,5,6,7,8,9,10] :: [Integer]
in PlutusTx.elem 0 ls ||])