Sto avendo una sorprendente quantità di difficoltà a ottenere i test di unità per l'esecuzione in cabala. Ho copiato il codice di prova testualmente the cabal documentation, con l'eccezione di cambiare il nome del moduloCome utilizzare dettagliata-0,9 nei test cabala
{-# LANGUAGE FlexibleInstances #-}
module Test.Integral (tests) where
import Distribution.TestSuite
instance TestOptions (String, Bool) where
name = fst
options = const []
defaultOptions _ = return (Options [])
check _ _ = []
instance PureTestable (String, Bool) where
run (name, result) _ | result == True = Pass
| result == False = Fail (name ++ " failed!")
test :: (String, Bool) -> Test
test = pure
-- In actual usage, the instances 'TestOptions (String, Bool)' and
-- 'PureTestable (String, Bool)', as well as the function 'test', would be
-- provided by the test framework.
tests :: [Test]
tests =
[ test ("bar-1", True)
, test ("bar-2", False)
]
Tuttavia, quando provo a costruire i test, ottengo i seguenti messaggi:
Test/Integral.hs:6:10:
Not in scope: type constructor or class `TestOptions'
Test/Integral.hs:12:10:
Not in scope: type constructor or class `PureTestable'
I provato a importarli direttamente da Distribution.TestSuite, ma ha affermato che non sono stati esportati. Questo è abbastanza semplice da dover fare qualcosa di stupido, ma non riesco a vedere cosa sia.
'TestOptions' et al sembrano essere riferimento a una vecchia versione vecchia QuickCheck. Vi suggerisco di utilizzare un moderno framework di test (sembra che quello che state guardando sia solo un framework per far funzionare la suite di test via cabal, non costruire la suite attuale - imparare un framework gustoso o di test). –