File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
test/Test/Codec/CBOR/Cuddle Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -431,6 +431,10 @@ class IsSize a where
431431 sizeAsCDDL :: a -> C. Type2
432432 sizeAsString :: a -> String
433433
434+ instance IsSize Word where
435+ sizeAsCDDL = C. T2Value . C. VUInt . fromIntegral
436+ sizeAsString = show
437+
434438instance IsSize Word64 where
435439 sizeAsCDDL = C. T2Value . C. VUInt
436440 sizeAsString = show
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ huddleSpec = describe "huddle" $ do
2222 mapSpec
2323 nestedSpec
2424 genericSpec
25+ constraintSpec
2526
2627basicAssign :: Spec
2728basicAssign = describe " basic assignment" $ do
@@ -111,6 +112,12 @@ genericSpec =
111112 toSortedCDDL (collectFrom [" mymap" =:= dict VUInt VText ])
112113 `shouldMatchParseCDDL` " dict<a0, b0> = {* a0 => b0}\n mymap = dict<uint, text>"
113114
115+ constraintSpec :: Spec
116+ constraintSpec =
117+ describe " Constraints" $
118+ it " Size can take a Word" $
119+ toSortedCDDL (collectFrom [" sz" =:= VUInt `sized` (2 :: Word )])
120+ `shouldMatchParseCDDL` " sz = uint .size 2"
114121--------------------------------------------------------------------------------
115122-- Helper functions
116123--------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments