From 766528677f594b2bc914d58a93d135c083052a3e Mon Sep 17 00:00:00 2001 From: VegOwOtenks Date: Thu, 14 Aug 2025 10:45:08 +0200 Subject: [PATCH] feat[tests]: Use tasty for hierarchical tests --- package.yaml | 3 +++ scalie.cabal | 5 +++++ test/Spec.hs | 11 +++++++---- test/Test/Data/Map/Implicit.hs | 15 ++++++++++----- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/package.yaml b/package.yaml index e247398..67426df 100644 --- a/package.yaml +++ b/package.yaml @@ -22,6 +22,7 @@ default-extensions: - DerivingStrategies - ImportQualifiedPost - NoImplicitPrelude + - OverloadedStrings - StandaloneKindSignatures - RoleAnnotations @@ -60,3 +61,5 @@ tests: - -with-rtsopts=-N dependencies: - scalie + - tasty + - tasty-quickcheck diff --git a/scalie.cabal b/scalie.cabal index 9e834db..651b71d 100644 --- a/scalie.cabal +++ b/scalie.cabal @@ -33,6 +33,7 @@ library DerivingStrategies ImportQualifiedPost NoImplicitPrelude + OverloadedStrings StandaloneKindSignatures RoleAnnotations ghc-options: -Weverything -Wno-unsafe @@ -54,6 +55,7 @@ executable scalie-exe DerivingStrategies ImportQualifiedPost NoImplicitPrelude + OverloadedStrings StandaloneKindSignatures RoleAnnotations ghc-options: -Weverything -Wno-unsafe -threaded -rtsopts -with-rtsopts=-N @@ -79,6 +81,7 @@ test-suite scalie-test DerivingStrategies ImportQualifiedPost NoImplicitPrelude + OverloadedStrings StandaloneKindSignatures RoleAnnotations ghc-options: -Weverything -Wno-unsafe -threaded -rtsopts -with-rtsopts=-N @@ -87,6 +90,8 @@ test-suite scalie-test , base , containers , scalie + , tasty + , tasty-quickcheck , text , vector default-language: Haskell2010 diff --git a/test/Spec.hs b/test/Spec.hs index 0b0fab7..a3b14ce 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,9 +1,12 @@ {-# LANGUAGE Unsafe #-} -- unsafe: Uses functions imported from unsafe modules import System.IO (IO) -import Control.Applicative (pure) import Test.Data.Map.Implicit qualified +import Test.Tasty qualified as Tasty +import Data.Function (($)) main :: IO () -main = do - _ <- Test.Data.Map.Implicit.runTests - pure () +main = Tasty.defaultMain $ Tasty.testGroup "all" + [ Tasty.testGroup "Properties" + [ Test.Data.Map.Implicit.testGroup + ] + ] diff --git a/test/Test/Data/Map/Implicit.hs b/test/Test/Data/Map/Implicit.hs index c456df0..1c4cb3d 100644 --- a/test/Test/Data/Map/Implicit.hs +++ b/test/Test/Data/Map/Implicit.hs @@ -2,7 +2,7 @@ {-# LANGUAGE TemplateHaskell #-} -- for 'quickCheckAll' {-# OPTIONS_GHC -Wno-all-missed-specialisations #-} -- a lot of warnings for unspecialized 'read' and 'show', which I cannot specialize -- I wouldn't know how at least, they're not my datatypes, I cannot use the hint and add an 'INLINABLE' pragma -module Test.Data.Map.Implicit (prop_readShowIdentityRoundtrip, prop_readShowMaybeRoundtrip, runTests) where +module Test.Data.Map.Implicit (testGroup) where import Test.QuickCheck.Roundtrip (roundtrips) import Text.Show (show) import Text.Read (read) @@ -10,10 +10,12 @@ import Data.Map.Implicit (ImplicitMap) import Data.Bool (Bool) import Language.Scalie.Ast.Definition (Definition) import Data.Functor.Identity (Identity) -import Test.QuickCheck.All (quickCheckAll) -import System.IO (IO) +import Test.QuickCheck (Property, allProperties) +import Data.String (String) import Control.Applicative (pure) import Data.Maybe (Maybe) +import Test.Tasty.QuickCheck qualified as Tasty.QuickCheck +import Test.Tasty (TestTree) -- | This is testworthy since I have somehow hand-hacked the read/show de/serialization of 'ImplicitMap' @@ -24,5 +26,8 @@ prop_readShowMaybeRoundtrip :: ImplicitMap (Definition Maybe) -> Bool prop_readShowMaybeRoundtrip = roundtrips read show pure [] -runTests :: IO Bool -runTests = $quickCheckAll +allTests :: [(String, Property)] +allTests = $allProperties + +testGroup :: TestTree +testGroup = Tasty.QuickCheck.testProperties "Data.Map.Implicit" allTests