added practicum files, updated gitignore
[fp1415.git] / files / practicum / StdAssocListTest.icl
1 module StdAssocListTest
2
3 /* Test module StdAssocList
4 Voor werken met Gast:
5 (*) gebruik Environment 'Gast'
6 (*) zet Project Options op 'Basic Values Only' en '2M' Maximum Heap Size
7 */
8
9 import gast
10 import StdAssocList
11
12 Start
13 = testn 1000
14 (\x ->
15 newAssocList_is_leeg /\
16 aantal_elementen_klopt x /\
17 lookup_after_update x /\
18 lookup_after_update2 x /\
19 keys_zijn_uniek x /\
20 True
21 )
22
23 newIntStringAssocList :: AssocList Int String
24 newIntStringAssocList = newAssocList
25
26 vulIntStringAssocList :: (AssocList Int String) Int -> AssocList Int String
27 vulIntStringAssocList l n = seq [updateKey k (toString k) \\ k <- [1..n]] l
28
29 newAssocList_is_leeg :: Property
30 newAssocList_is_leeg = name "newAssocList_is_leeg"
31 (countValues newIntStringAssocList == 0)
32
33 aantal_elementen_klopt :: Int -> Property
34 aantal_elementen_klopt n = name "aantal_elementen_klopt"
35 (countValues (vulIntStringAssocList newIntStringAssocList n`) == max 0 n`)
36 where n` = min n 100
37
38 lookup_after_update :: Int -> Property
39 lookup_after_update n = name "lookup_after_update"
40 (lookupKey k (updateKey k v (vulIntStringAssocList newIntStringAssocList n`)) == [v])
41 where n` = min n 100
42 k = n+1
43 v = toString k
44
45 lookup_after_update2 :: Int -> Property
46 lookup_after_update2 n = name "lookup_after_update"
47 (lookupKey k (vulIntStringAssocList (updateKey k v newIntStringAssocList) n`) == [v])
48 where n` = min n 100
49 k = n+1
50 v = toString k
51
52 keys_zijn_uniek :: Int -> Property
53 keys_zijn_uniek n = name "keys_zijn_uniek"
54 (lookupKey k (removeKey k (vulIntStringAssocList newIntStringAssocList n`)) == [])
55 where n` = min n 100
56 k = n/2