aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-12-29 22:29:45 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-12-29 22:29:45 +0100
commit2c84e82a0263c9bf87cc660a9aabeb5f69828253 (patch)
tree21a92bf7e9852e9f1639b16f913c27d2745307e2 /src
parent08f10a6f6cbc4fc8235beacedd587c56a9534f34 (diff)
downloadverismith-2c84e82a0263c9bf87cc660a9aabeb5f69828253.tar.gz
verismith-2c84e82a0263c9bf87cc660a9aabeb5f69828253.zip
Add new generation method
Diffstat (limited to 'src')
-rw-r--r--src/Test/VeriFuzz/Graph/Random.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Test/VeriFuzz/Graph/Random.hs b/src/Test/VeriFuzz/Graph/Random.hs
index 8d3eb50..7f9e3e6 100644
--- a/src/Test/VeriFuzz/Graph/Random.hs
+++ b/src/Test/VeriFuzz/Graph/Random.hs
@@ -12,9 +12,10 @@ Define the random generation for the directed acyclic graph.
module Test.VeriFuzz.Graph.Random where
-import Data.Graph.Inductive (Graph, LEdge, mkGraph)
-import Test.QuickCheck (Arbitrary, Gen)
-import qualified Test.QuickCheck as QC
+import Data.Graph.Inductive (Graph, LEdge, mkGraph)
+import Data.Graph.Inductive.PatriciaTree (Gr)
+import Test.QuickCheck (Arbitrary, Gen)
+import qualified Test.QuickCheck as QC
-- | Gen instance to create an arbitrary edge, where the edges are limited by
-- `n` that is passed to it.
@@ -28,19 +29,18 @@ arbitraryEdge n = do
with = QC.suchThat $ QC.resize n QC.arbitrary
-- | Gen instance for a random acyclic DAG.
-randomDAG :: (Arbitrary l, Arbitrary e, Graph gr)
- => Int -- ^ The number of nodes
- -> Gen (gr l e) -- ^ The generated graph. It uses Arbitrary to
+randomDAG :: (Arbitrary l, Arbitrary e)
+ => Gen (Gr l e) -- ^ The generated graph. It uses Arbitrary to
-- generate random instances of each node
-randomDAG n = do
+randomDAG = do
list <- QC.infiniteListOf QC.arbitrary
- l <- QC.infiniteListOf $ arbitraryEdge n
- return . mkGraph (nodes list) $ take (10*n) l
+ l <- QC.infiniteListOf $ aE
+ QC.sized (\n -> return . mkGraph (nodes list n) $ take (10*n) l)
where
- nodes l = zip [0..n] $ take n l
+ nodes l n = zip [0..n] $ take n l
+ aE = QC.sized arbitraryEdge
-- | Generate a random acyclic DAG with an IO instance.
-genRandomDAG :: (Arbitrary l, Arbitrary e, Graph gr)
- => Int
- -> IO (gr l e)
-genRandomDAG = QC.generate . randomDAG
+genRandomDAG :: (Arbitrary l, Arbitrary e)
+ => IO (Gr l e)
+genRandomDAG = QC.generate randomDAG