summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2024-01-27 23:04:26 +0300
committerdefanor <defanor@uberspace.net>2024-01-27 23:04:26 +0300
commit788de39262809040ebf1096aff22190ad526dc1b (patch)
treeb8a3a659821aac623b6232728e2d3b80cebbe335 /test
parentb09a00426c4f72892f7863bbaaf688c21592dd03 (diff)
Rewrite, version 0.2: use Parsec, focus on DSV
Diffstat (limited to 'test')
-rw-r--r--test/Test.hs33
1 files changed, 11 insertions, 22 deletions
diff --git a/test/Test.hs b/test/Test.hs
index b8d4121..f8476d7 100644
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -5,11 +5,9 @@ import Generic.Random (genericArbitraryU)
import Test.Tasty
import Test.Tasty.QuickCheck as QC
import Data.Proxy
-import Test.Tasty.Travis
import Data.Word
import Data.Int
import Data.Complex
-import Data.Either
import Coalpit
@@ -88,16 +86,11 @@ instance Arbitrary RecordStrings where arbitrary = genericArbitraryU
printAndParse :: (Coalpit a, Eq a)
=> Options -> Proxy a -> a -> Bool
-printAndParse opt _ r = Right r == fromArgs opt (toArgs opt r)
-
-printAndParseDSV :: (Coalpit a, Eq a)
- -- It would take a long time to test with [a], so
- -- just repeating it 0--2 times.
- => Options -> Proxy a -> (a, Int) -> Bool
-printAndParseDSV opt _ (x, n) =
- let xs = (replicate (n `mod` 3) x)
- in xs == (rights . map (readDSV opt) . lines . unlines . map (showDSV opt) $ xs)
+printAndParse opt _ r = Right r == fromDSV opt (toDSV opt r)
+printAndParseList :: (Coalpit a, Eq a)
+ => Options -> Proxy a -> [a] -> Bool
+printAndParseList opt _ l = Right l == fromDSVList opt (toDSVList opt l)
variousTypes :: (forall a. (Coalpit a, Eq a, Show a, Arbitrary a) =>
Proxy a -> String -> TestTree)
@@ -122,24 +115,20 @@ variousTypes f =
variousOptions :: (Options -> [TestTree]) -> [TestTree]
variousOptions tt =
- [ testGroup (concat [ "alwaysUseSelName = ", show ausn
- , ", omitNamedOptions = ", show ono])
- (tt defOpt { alwaysUseSelName = ausn
- , omitNamedOptions = ono })
- | ausn <- [True, False]
- , ono <- [True, False]
+ [ testGroup (concat [ "selNamePolicy = ", show snpol ])
+ (tt defOpt { selNamePolicy = snpol })
+ | snpol <- [SNDisable, SNAvoid, SNPrefer, SNRequire]
]
qcProps :: TestTree
qcProps = testGroup "Quickcheck properties"
- [ testGroup "Right == fromArgs opt . toArgs opt"
+ [ testGroup "Right == fromDSV opt . toDSV opt"
(variousOptions $ \opt ->
variousTypes $ \p n -> QC.testProperty n (printAndParse opt p))
- , testGroup
- "id == rights . map (readDSV opt) . lines . unlines . map (showDSV opt)"
+ , testGroup "Right == fromDSVList opt . toDSVList opt"
(variousOptions $ \opt ->
- variousTypes $ \p n -> QC.testProperty n (printAndParseDSV opt p))
+ variousTypes $ \p n -> QC.testProperty n (printAndParseList opt p))
]
main :: IO ()
-main = travisTestReporter defaultConfig [] qcProps
+main = defaultMain qcProps