1
Fork 0
mirror of https://github.com/Jaxan/ons-hs.git synced 2025-04-27 14:47:45 +02:00
ons-hs/test/Spec.hs
2024-11-05 10:59:40 +01:00

33 lines
1.1 KiB
Haskell

{-# OPTIONS_GHC -Wno-orphans #-}
import Test.Tasty
import Test.Tasty.HUnit hiding (assert)
import Test.Tasty.QuickCheck as QC
import Prelude (Eq (..), IO, Int, length, show, (!!), ($), (<>))
import Nominal (Nominal (..))
import OrbitList (repeatRationals, size)
import Support (Rat (..))
import SpecMap
import SpecSet
import SpecUtils ()
main :: IO ()
main = defaultMain allTests
allTests :: TestTree
allTests = testGroup "main" [setTests, mapTests, countingTests, qcTests]
-- Verifying that the number of orbits is correct. Up to length 7, because
-- length 8 and longer take at least one second.
countingTests :: TestTree
countingTests = testGroup "OrbitList" [testCase ("count " <> show n) $ length (OrbitList.size (repeatRationals n)) @?= (a000670 !! n) | n <- [0 .. 7]]
-- A000670: Ordered Bell numbers or Fubini numbers
a000670 :: [Int]
a000670 = [1, 1, 3, 13, 75, 541, 4683, 47293, 545835, 7087261, 102247563, 1622632573, 28091567595]
-- TODO: Add more quickcheck tests
qcTests :: TestTree
qcTests = testGroup "QuickCheck" [QC.testProperty "all atoms in same orbit" $ \p q -> toOrbit (p :: Rat) == toOrbit (q :: Rat)]