Set 9a Ex 4: add examples as test cases

closes #101
This commit is contained in:
Joel Kaasinen
2024-05-14 08:22:24 +03:00
parent a454ad731a
commit 3861406ad3
+6 -1
View File
@@ -16,7 +16,7 @@ main = score tests
tests = [(1,"workload",[ex1_small, ex1_medium, ex1_big])
,(2,"echo",[ex2_examples, ex2_random])
,(3,"countValid",[ex3])
,(4,"repeated",[ex4_unrepeated_int, ex4_repeated_char, ex4_repeated_int])
,(4,"repeated",[ex4_examples, ex4_unrepeated_int, ex4_repeated_char, ex4_repeated_int])
,(5,"sumSuccess",[ex5])
,(6,"Lock",[ex6_examples, ex6_gen])
,(7,"Eq Text",[ex7])
@@ -78,6 +78,11 @@ ex3 = forAllShrinkBlind (listOf valid) subterms $ \vs ->
forAllBlind (shuffle (vs++is)) $ \ns ->
$(testing [|countValid ns|]) (?==length vs)
ex4_examples = conjoin
[$(testing [|repeated [1,2,3]|]) (?==Nothing)
,$(testing [|repeated [1,2,2,3,3]|]) (?==Just 2)
,$(testing [|repeated [1,2,1,2,3,3]|]) (?==Just 3)]
ex4_unrepeated_int = forAll_ $ \ls ->
$(testing [|repeated (nub (ls :: [Int]))|]) (?==Nothing)