This commit is contained in:
13
test/Main.hs
13
test/Main.hs
@@ -31,8 +31,8 @@ goldenTests = testGroup "golden tests"
|
||||
]
|
||||
, t "type" ([Word, Long, Single, Double], [BaseTy Word, Byte, HalfWord])
|
||||
, t "const"
|
||||
[ CInt True 1
|
||||
, CInt False 2
|
||||
[ CInt (-1)
|
||||
, CInt 2
|
||||
, CSingle 0.1
|
||||
, CDouble (-0.2)
|
||||
, CGlobal "global"
|
||||
@@ -45,7 +45,7 @@ goldenTests = testGroup "golden tests"
|
||||
, t "opaque" $ Opaque "t" 8 16
|
||||
, t "data" $ DataDef [Export] "d" (Just 8)
|
||||
[ FieldZero 16
|
||||
, FieldExtTy Byte $ Symbol "g" (Just 32) :| [String "foo\nbar\0baz", Const $ CInt True 1]
|
||||
, FieldExtTy Byte $ Symbol "g" (Just 32) :| [String "foo\nbar\0baz", Const $ CInt (-1)]
|
||||
]
|
||||
, t "function" $ FuncDef [Export] (Just $ AbiAggregateTy "t") "f"
|
||||
(Just "env") [Param (AbiBaseTy Word) "a", Param (AbiBaseTy Double) "b"] Variadic $
|
||||
@@ -92,8 +92,7 @@ goldenTests = testGroup "golden tests"
|
||||
(renderStrict . layoutPretty defaultLayoutOptions)
|
||||
|
||||
valInt :: Int -> Val
|
||||
valInt i | i >= 0 = ValConst $ CInt False $ fromIntegral i
|
||||
| otherwise = ValConst $ CInt True $ fromIntegral $ negate i
|
||||
valInt i = ValConst $ CInt $ fromIntegral i
|
||||
|
||||
one, two :: Val
|
||||
one = valInt 1
|
||||
@@ -107,7 +106,7 @@ helloWorld = Program [] [helloString] [helloMain]
|
||||
where
|
||||
helloString = DataDef [] "str" Nothing
|
||||
[ FieldExtTy Byte $ String "hello world" :| []
|
||||
, FieldExtTy Byte $ Const (CInt False 0) :| []
|
||||
, FieldExtTy Byte $ Const (CInt 0) :| []
|
||||
]
|
||||
helloMain = FuncDef [Export] (Just $ AbiBaseTy Word) "main"
|
||||
Nothing [] NoVariadic $
|
||||
@@ -118,5 +117,5 @@ helloWorld = Program [] [helloString] [helloMain]
|
||||
[Arg (AbiBaseTy Long) $ ValGlobal "str"]
|
||||
[]
|
||||
]
|
||||
(Ret $ Just $ ValConst $ CInt False 0)
|
||||
(Ret $ Just $ ValConst $ CInt 0)
|
||||
:| []
|
||||
|
||||
Reference in New Issue
Block a user