aboutsummaryrefslogtreecommitdiffstats
path: root/src/Test/VeriFuzz/CodeGen.hs
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-12-04 16:54:56 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-12-04 16:54:56 +0000
commitd08ff5fbf2b40746cacc8e799f6c7b5b0b932669 (patch)
treeaabda213406a77af5b8b1b59239cf9c174f89c78 /src/Test/VeriFuzz/CodeGen.hs
parent3d5626b32bb66b66a503dd60995d7ece80084d56 (diff)
downloadverismith-d08ff5fbf2b40746cacc8e799f6c7b5b0b932669.tar.gz
verismith-d08ff5fbf2b40746cacc8e799f6c7b5b0b932669.zip
[Fix #1] Fix the negative number generation
Diffstat (limited to 'src/Test/VeriFuzz/CodeGen.hs')
-rw-r--r--src/Test/VeriFuzz/CodeGen.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Test/VeriFuzz/CodeGen.hs b/src/Test/VeriFuzz/CodeGen.hs
index eb99d6b..85f1d1c 100644
--- a/src/Test/VeriFuzz/CodeGen.hs
+++ b/src/Test/VeriFuzz/CodeGen.hs
@@ -58,9 +58,12 @@ genExpr _ = "TODO"
genPrimary :: Primary -> Text
genPrimary (PrimNum num) =
- sh (num ^. numSize) <> "'d" <> sh (num ^. numVal)
+ neg <> sh (num ^. numSize) <> "'d" <> (sh . abs) n
where
sh = T.pack . show
+ abs x = if x <= 0 then -x else x
+ n = num ^. numVal
+ neg = if n <= 0 then "-" else ""
genPrimary (PrimId ident) = ident ^. getIdentifier
genBinaryOperator :: BinaryOperator -> Text