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/FragsTest.icl | |
parent | week6 camil: working positioning of lines by putting empties at left and righ... (diff) |
Diffstat (limited to '1415/files/practicum/FragsTest.icl')
-rw-r--r-- | 1415/files/practicum/FragsTest.icl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/1415/files/practicum/FragsTest.icl b/1415/files/practicum/FragsTest.icl new file mode 100644 index 0000000..c146994 --- /dev/null +++ b/1415/files/practicum/FragsTest.icl @@ -0,0 +1,39 @@ +module FragsTest
+
+/* Test module Frags
+ Voor werken met Gast:
+ (*) gebruik Environment 'Gast'
+ (*) zet Project Options op 'Basic Values Only'
+*/
+
+import StdEnv
+import gast
+import Frags
+
+Start = testn 1000
+ ( \xs -> alle_lengtes_komen_voor xs /\
+ alle_elementen_zijn_frag 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 (frags xs))) == [0..n]
+ )
+
+alle_elementen_zijn_frag :: [Int] -> Property
+alle_elementen_zijn_frag xs = name "alle_elementen_zijn_frag"
+ (and [is_frag f xs \\ f <- frags xs])
+
+/* is_frag fragment lijst is True alleen als fragment een strikte deellijst is
+ van lijst, dwz: de elementen van fragment komen direct achter elkaar in lijst voor.
+*/
+is_frag :: [a] [a] -> Bool | Eq a
+is_frag [] _ = True
+is_frag _ [] = False
+is_frag [f:fs] [x:xs]
+| f == x
+ | is_frag fs xs = True
+ | otherwise = is_frag [f:fs] xs
+| otherwise = is_frag [f:fs] xs
|