Mam zaskakująco dużo trudności z uzyskaniem testów jednostkowych pod katalitem. Mam skopiowane kodu testowego dosłownie z the cabal documentation, z wyjątkiem zmiany nazwy modułuJak korzystać ze szczegółowych -0,9 w testach kablowi
{-# 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)
]
Jednak gdy próbuję zbudować testy, dostaję następujące komunikaty:
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 próbował importować je bezpośrednio z Distribution.TestSuite, ale powiedział, że nie zostały one wyeksportowane. Jest to dość proste, że muszę robić coś głupiego, ale nie widzę, co to jest.
'TestOptions' wsp wydają się odnosić do starej starej wersji QuickCheck. Sugeruję użycie nowoczesnego środowiska testowego (wygląda na to, że patrzysz tylko na ramy do uruchamiania zestawu testów za pomocą cabal, a nie na budowaniu rzeczywistego pakietu - poznaj smakowite lub testowe środowisko). –