@@ -26,37 +26,37 @@ huddleSpec = describe "huddle" $ do
26
26
basicAssign :: Spec
27
27
basicAssign = describe " basic assignment" $ do
28
28
it " Can assign a primitive" $
29
- toCDDL [" port" =:= VUInt ]
29
+ toCDDLNoRoot [" port" =:= VUInt ]
30
30
`shouldMatchParseCDDL` " port = uint"
31
31
it " Can assign an int" $
32
- toCDDL [" one" =:= (int 1 )]
32
+ toCDDLNoRoot [" one" =:= (int 1 )]
33
33
`shouldMatchParseCDDL` " one = 1"
34
34
-- it "Can assign a float" $
35
- -- toCDDL ["onepointone" =:= (1.1 :: Float)]
35
+ -- toCDDLNoRoot ["onepointone" =:= (1.1 :: Float)]
36
36
-- `shouldMatchParseCDDL` "onepointone = 1.1"
37
37
it " Can assign a text string" $
38
- toCDDL [" hello" =:= (" Hello World" :: T. Text )]
38
+ toCDDLNoRoot [" hello" =:= (" Hello World" :: T. Text )]
39
39
`shouldMatchParseCDDL` " hello = \" Hello World\" "
40
40
it " Can handle multiple assignments" $
41
- toCDDL [" age" =:= VUInt , " location" =:= VText ]
41
+ toCDDLNoRoot [" age" =:= VUInt , " location" =:= VText ]
42
42
`shouldMatchParseCDDL` " age = uint\n location = text"
43
43
44
44
arraySpec :: Spec
45
45
arraySpec = describe " Arrays" $ do
46
46
it " Can assign a small array" $
47
- toCDDL [" asl" =:= arr [a VUInt , a VBool , a VText ]]
47
+ toCDDLNoRoot [" asl" =:= arr [a VUInt , a VBool , a VText ]]
48
48
`shouldMatchParseCDDL` " asl = [ uint, bool, text ]"
49
49
it " Can quantify an upper bound" $
50
- toCDDL [" age" =:= arr [a VUInt +> 64 ]]
50
+ toCDDLNoRoot [" age" =:= arr [a VUInt +> 64 ]]
51
51
`shouldMatchParseCDDL` " age = [ *64 uint ]"
52
52
it " Can quantify an optional" $
53
- toCDDL [" age" =:= arr [0 <+ a VUInt +> 1 ]]
53
+ toCDDLNoRoot [" age" =:= arr [0 <+ a VUInt +> 1 ]]
54
54
`shouldMatchParseCDDL` " age = [ ? uint ]"
55
55
it " Can handle a choice" $
56
- toCDDL [" ageOrSex" =:= arr [a VUInt ] / arr [a VBool ]]
56
+ toCDDLNoRoot [" ageOrSex" =:= arr [a VUInt ] / arr [a VBool ]]
57
57
`shouldMatchParseCDDL` " ageOrSex = [ uint // bool ]"
58
58
it " Can handle choices of groups" $
59
- toCDDL
59
+ toCDDLNoRoot
60
60
[ " asl"
61
61
=:= arr [a VUInt , a VBool , a VText ]
62
62
/ arr
@@ -69,27 +69,27 @@ arraySpec = describe "Arrays" $ do
69
69
mapSpec :: Spec
70
70
mapSpec = describe " Maps" $ do
71
71
it " Can assign a small map" $
72
- toCDDL [" asl" =:= mp [" age" ==> VUInt , " sex" ==> VBool , " location" ==> VText ]]
72
+ toCDDLNoRoot [" asl" =:= mp [" age" ==> VUInt , " sex" ==> VBool , " location" ==> VText ]]
73
73
`shouldMatchParseCDDL` " asl = { age : uint, sex : bool, location : text }"
74
74
it " Can quantify a lower bound" $
75
- toCDDL [" age" =:= mp [0 <+ " years" ==> VUInt ]]
75
+ toCDDLNoRoot [" age" =:= mp [0 <+ " years" ==> VUInt ]]
76
76
`shouldMatchParseCDDL` " age = { * years : uint }"
77
77
it " Can quantify an upper bound" $
78
- toCDDL [" age" =:= mp [" years" ==> VUInt +> 64 ]]
78
+ toCDDLNoRoot [" age" =:= mp [" years" ==> VUInt +> 64 ]]
79
79
`shouldMatchParseCDDL` " age = { *64 years : uint }"
80
80
it " Can handle a choice" $
81
- toCDDL [" ageOrSex" =:= mp [" age" ==> VUInt ] / mp [" sex" ==> VBool ]]
81
+ toCDDLNoRoot [" ageOrSex" =:= mp [" age" ==> VUInt ] / mp [" sex" ==> VBool ]]
82
82
`shouldMatchParseCDDL` " ageOrSex = { age : uint // sex : bool }"
83
83
it " Can handle a choice with an entry" $
84
- toCDDL [" mir" =:= arr [a (int 0 / int 1 ), a $ mp [0 <+ " test" ==> VUInt ]]]
84
+ toCDDLNoRoot [" mir" =:= arr [a (int 0 / int 1 ), a $ mp [0 <+ " test" ==> VUInt ]]]
85
85
`shouldMatchParseCDDL` " mir = [ 0 / 1, { * test : uint }]"
86
86
87
87
nestedSpec :: Spec
88
88
nestedSpec =
89
89
describe " Nesting" $
90
90
it " Handles references" $
91
91
let headerBody = " header_body" =:= arr [" block_number" ==> VUInt , " slot" ==> VUInt ]
92
- in toCDDL
92
+ in toCDDLNoRoot
93
93
[ headerBody,
94
94
" header" =:= arr [a headerBody, " body_signature" ==> VBytes ]
95
95
]
@@ -105,10 +105,10 @@ genericSpec =
105
105
dict = binding2 $ \ k v -> " dict" =:= mp [0 <+ asKey k ==> v]
106
106
in do
107
107
it " Should bind a single parameter" $
108
- toCDDL (collectFrom [" intset" =:= set VUInt ])
108
+ toCDDLNoRoot (collectFrom [" intset" =:= set VUInt ])
109
109
`shouldMatchParseCDDL` " intset = set<uint>\n set<a0> = [* a0]"
110
110
it " Should bind two parameters" $
111
- toCDDL (collectFrom [" mymap" =:= dict VUInt VText ])
111
+ toCDDLNoRoot (collectFrom [" mymap" =:= dict VUInt VText ])
112
112
`shouldMatchParseCDDL` " mymap = dict<uint, text>\n dict<a0, b0> = {* a0 => b0}"
113
113
114
114
--------------------------------------------------------------------------------
0 commit comments