{-# LANGUAGE OverloadedStrings #-}{-# LANGUAGE RankNTypes #-}-- |-- Module : Main (tests)-- Copyright : 2019-2023 (c) Emily Pillmore-- License : BSD---- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>-- Stability : Experimental-- Portability : TypeFamilies--module Main( main) whereimport Data.Maybeimport Data.Vector (Vector)import Data.Vector.NonEmpty (NonEmptyVector)import qualified Data.Vector.NonEmpty as NEVimport Test.QuickCheckimport Test.Tastyimport Test.Tasty.QuickCheckmain :: IO ()main = defaultMain $ testGroup "NonEmptyVector constructor" [ testProperty "prop_reverse" prop_reverse , testProperty "prop_from_to_list" prop_from_to_list , testProperty "prop_from_to_vec" prop_from_to_vec ]genList :: Gen [Int]genList = listOf1 (choose (1, 100))genNEV :: Gen (NonEmptyVector Int)genNEV = fmap (fromJust . NEV.fromList) genListgenV :: Gen (Vector Int)genV = NEV.toVector <$> genNEVprop_reverse :: Propertyprop_reverse = forAll genNEV $ \t -> NEV.reverse (NEV.reverse t) == tprop_from_to_list :: Propertyprop_from_to_list = forAll genNEV $ \t -> forAll genList $ \u -> NEV.fromList (NEV.toList t) == Just t && fmap NEV.toList (NEV.fromList u) == Just uprop_from_to_vec :: Propertyprop_from_to_vec = forAll genNEV $ \t -> forAll genV $ \u -> NEV.fromVector (NEV.toVector t) == Just t && (NEV.toVector <$> NEV.fromVector u) == Just u