diff options
author | Camil Staps | 2016-02-02 19:24:50 +0100 |
---|---|---|
committer | Camil Staps | 2016-02-02 19:24:50 +0100 |
commit | a7d7542dc646a5fd124ef71e71ce260889f1701b (patch) | |
tree | 04ed89503bbb3cc9933273a1326a53ca724c3492 /1415/files/practicum/SubsTest.icl | |
parent | week6 camil: working positioning of lines by putting empties at left and righ... (diff) |
Diffstat (limited to '1415/files/practicum/SubsTest.icl')
-rw-r--r-- | 1415/files/practicum/SubsTest.icl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/1415/files/practicum/SubsTest.icl b/1415/files/practicum/SubsTest.icl new file mode 100644 index 0000000..6092bc0 --- /dev/null +++ b/1415/files/practicum/SubsTest.icl @@ -0,0 +1,40 @@ +module SubsTest
+
+/* Test module Subs
+ Voor werken met Gast:
+ (*) gebruik Environment 'Gast'
+ (*) zet Project Options op 'Basic Values Only'
+*/
+
+import StdEnv
+import gast
+import Subs
+
+Start
+ = testn 1000
+ (\xs -> alle_lengtes_komen_voor xs /\
+ alle_elementen_zijn_sub xs /\
+ subs_xs_bevat_xs xs /\
+ True
+ )
+
+alle_lengtes_komen_voor :: [Int] -> Property
+alle_lengtes_komen_voor xs = name "alle_lengtes_komen_voor"
+ (let n = length xs
+ in sort (removeDup (map length (subs xs))) == [0..n]
+ )
+
+alle_elementen_zijn_sub :: [Int] -> Property
+alle_elementen_zijn_sub xs = name "alle_elementen_zijn_sub" (and [is_sub f xs \\ f <- subs xs])
+
+subs_xs_bevat_xs :: [Int] -> Property
+subs_xs_bevat_xs xs = name "subs_xs_bevat_xs" (isMember xs (subs xs))
+
+/* is_sub sub lijst is True alleen als alle elementen van sub achtereenvolgens voorkomen in lijst.
+*/
+is_sub :: [a] [a] -> Bool | Eq a
+is_sub [] _ = True
+is_sub _ [] = False
+is_sub [x:xs] [y:ys]
+| x == y = is_sub xs ys
+| otherwise = is_sub [x:xs] ys
|