aboutsummaryrefslogtreecommitdiff
path: root/test/Tests
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-06-03 18:49:08 +0200
committerTom Smeding <tom@tomsmeding.com>2024-06-03 19:24:48 +0200
commit30d5f7a84c5bf516785a95de51cd0176367df450 (patch)
tree0543c7761fc216b911a2e9077c5ef2e4ace224ce /test/Tests
parentcc193feee38429e1a853cc23365b95e96b206672 (diff)
Test permInverse
Diffstat (limited to 'test/Tests')
-rw-r--r--test/Tests/Permutation.hs39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/Tests/Permutation.hs b/test/Tests/Permutation.hs
new file mode 100644
index 0000000..1e7ad13
--- /dev/null
+++ b/test/Tests/Permutation.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE ImportQualifiedPost #-}
+-- {-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
+-- {-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
+module Tests.Permutation where
+
+import Data.Type.Equality
+
+import Data.Array.Mixed.Permutation
+
+import Hedgehog
+import Hedgehog.Gen qualified as Gen
+import Hedgehog.Range qualified as Range
+import Test.Tasty
+import Test.Tasty.Hedgehog
+
+-- import Debug.Trace
+
+import Gen
+
+
+tests :: TestTree
+tests = testGroup "Permutation"
+ [testProperty "permCheckPermutation" $ property $ do
+ n <- forAll $ Gen.int (Range.linear 0 10)
+ list <- forAll $ genPermR n
+ let r = permFromList list $ \perm ->
+ permCheckPermutation perm ()
+ case r of
+ Just () -> return ()
+ Nothing -> failure
+ ,testProperty "permInverse" $ property $
+ genRank $ \n ->
+ genPerm n $ \perm ->
+ genStaticShX n $ \ssh ->
+ permInverse perm $ \_invperm proof ->
+ case proof ssh of
+ Refl -> return ()
+ ]