aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYann Herklotz Grave <git@yannherklotzgrave.com>2019-02-16 21:35:51 +0000
committerYann Herklotz Grave <git@yannherklotzgrave.com>2019-02-16 21:36:16 +0000
commitf9159b9e1dfaf9a0b449b632913c8efa1b6674ad (patch)
tree40f4fb9de12e785d4258cffb8af00c0cf29468cc /test
parent6175945fcacbb37573158ab80ccf3312ff068b33 (diff)
downloadverismith-f9159b9e1dfaf9a0b449b632913c8efa1b6674ad.tar.gz
verismith-f9159b9e1dfaf9a0b449b632913c8efa1b6674ad.zip
[Fix #7] Add property test to parser
Diffstat (limited to 'test')
-rw-r--r--test/Property.hs33
1 files changed, 32 insertions, 1 deletions
diff --git a/test/Property.hs b/test/Property.hs
index 3edf5d4..8aa2ec3 100644
--- a/test/Property.hs
+++ b/test/Property.hs
@@ -3,10 +3,12 @@ module Property
)
where
+import Data.Either (isRight)
import qualified Data.Graph.Inductive as G
import Data.Graph.Inductive.PatriciaTree (Gr)
import Test.Tasty
import qualified Test.Tasty.QuickCheck as QC
+import Text.Parsec
import VeriFuzz
import qualified VeriFuzz.RandomAlt as V
@@ -16,6 +18,14 @@ newtype TestGraph = TestGraph { getGraph :: Gr Gate () }
newtype AltTestGraph = AltTestGraph { getAltGraph :: Gr Gate () }
deriving (Show)
+newtype ModDeclSub = ModDeclSub { getModDecl :: ModDecl }
+
+instance Show ModDeclSub where
+ show = show . GenVerilog . getModDecl
+
+instance QC.Arbitrary ModDeclSub where
+ arbitrary = ModDeclSub <$> randomMod 3 10
+
instance QC.Arbitrary TestGraph where
arbitrary = TestGraph <$> QC.resize 30 randomDAG
@@ -30,5 +40,26 @@ simpleAltGraph :: TestTree
simpleAltGraph = QC.testProperty "simple alternative graph generation check" $ \graph -> simp graph
where simp = G.isSimple . getAltGraph
+parserInput' :: ModDeclSub -> Bool
+parserInput' (ModDeclSub v) =
+ isRight $ parse parseModDecl "input_test.v" str
+ where
+ str = show . GenVerilog $ v
+
+--parserIdempotent' :: (GenVerilog VerilogSrc) -> Bool
+--parserIdempotent' v =
+-- p sv == (p . p) sv
+-- where
+-- sv = show v
+-- p = show . fromRight (VerilogSrc []) . parse parseVerilogSrc "idempotent_test.v"
+
+parserInput :: TestTree
+parserInput = QC.testProperty "parser input" $
+ parserInput'
+
+--parserIdempotent :: TestTree
+--parserIdempotent = QC.testProperty "parser idempotence" $
+-- parserIdempotent'
+
propertyTests :: TestTree
-propertyTests = testGroup "Property Tests" [simpleGraph, simpleAltGraph]
+propertyTests = testGroup "Property Tests" [simpleGraph, simpleAltGraph, parserInput]