From 2a9459f226f43e6fbf6e08c53ad7fe75f8aedbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20P=C3=A4tzel?= Date: Sat, 19 Oct 2019 15:57:55 +0200 Subject: [PATCH] Use noDupsList generator for more tests --- src/Seminar.hs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Seminar.hs b/src/Seminar.hs index 8af77cc..d62c309 100644 --- a/src/Seminar.hs +++ b/src/Seminar.hs @@ -182,20 +182,22 @@ unique xs = length xs == (length . nub) xs prop_valid_empty = valid [] -prop_valid_dupNoT ss = unique ss ==> valid (ss `zip` repeat NoT) +prop_valid_dupNoT = + forAll noDupsList $ \ss -> + valid (ss `zip` repeat NoT) -prop_valid_dupT ss ts = - unique ss - && unique ts - && length ss > length ts - && not (null ts) - && NoT `notElem` ts - ==> not . valid $ ss `zip` cycle ts +prop_valid_dupT = + forAll noDupsList $ \ss -> + forAll noDupsList $ \ts' -> + let ts = filter (/= NoT) ts' + in length ss > length ts && not (null ts) + ==> not . valid + $ ss `zip` cycle ts prop_valid_noDups = forAll noDupsList $ \ss -> forAll noDupsList $ \ts -> - valid $ ss `zip` ts + valid $ ss `zip` ts {-| Generator for lists fulfilling 'unique', that is, only containing unique