aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-05-13 01:15:44 +0100
committerYann Herklotz <git@yannherklotz.com>2020-05-13 01:15:44 +0100
commit501cac8b2eda9e68c200231bdabca17ac48264d7 (patch)
tree9be8adf9c93e430dcb1c0c6d3b39b0aa33a2ea15 /test
parentd79412813c44767df06bce0d33f7472b30814a30 (diff)
parentd50a0b5b57aae1c7558fa77c362ae2e36038b63c (diff)
downloadverismith-501cac8b2eda9e68c200231bdabca17ac48264d7.tar.gz
verismith-501cac8b2eda9e68c200231bdabca17ac48264d7.zip
Merge branch 'master' into dev/reducerdev/reducer
Diffstat (limited to 'test')
-rw-r--r--test/Distance.hs30
-rw-r--r--test/Property.hs4
2 files changed, 33 insertions, 1 deletions
diff --git a/test/Distance.hs b/test/Distance.hs
new file mode 100644
index 0000000..a59b401
--- /dev/null
+++ b/test/Distance.hs
@@ -0,0 +1,30 @@
+module Distance
+ ( distanceTests
+ )
+where
+
+import Hedgehog (Property, (===))
+import qualified Hedgehog as Hog
+import qualified Hedgehog.Gen as Hog
+import qualified Hedgehog.Range as Hog
+import Verismith.Verilog.Distance
+import Test.Tasty
+import Test.Tasty.Hedgehog
+
+distanceLess :: Property
+distanceLess = Hog.property $ do
+ x <- Hog.forAll (Hog.list (Hog.linear 0 15) Hog.alpha)
+ y <- Hog.forAll (Hog.list (Hog.linear 0 15) Hog.alpha)
+ Hog.assert $ udistance x y <= distance x y
+
+distanceEq :: Property
+distanceEq = Hog.property $ do
+ x <- Hog.forAll (Hog.list (Hog.linear 0 15) Hog.alpha)
+ distance x x === 0
+ udistance x x === 0
+
+distanceTests :: TestTree
+distanceTests = testGroup "Distance tests"
+ [ testProperty "Unordered distance <= distance" distanceLess
+ , testProperty "distance x x === 0" distanceEq
+ ]
diff --git a/test/Property.hs b/test/Property.hs
index ddbef0d..2d5dcc1 100644
--- a/test/Property.hs
+++ b/test/Property.hs
@@ -13,6 +13,7 @@ where
import Data.Either (either, isRight)
import qualified Data.Graph.Inductive as G
import Data.Text (Text)
+import Distance (distanceTests)
import Hedgehog ((===), Gen, Property)
import qualified Hedgehog as Hog
import qualified Hedgehog.Gen as Hog
@@ -47,5 +48,6 @@ propertyTests =
testGroup
"Property Tests"
[ testProperty "acyclic graph generation check" acyclicGraph,
- parserTests
+ parserTests,
+ distanceTests
]