Added student numbers
[fp1415.git] / week3 / camil / StdStackTest.icl
1 module StdStackTest
2
3 /* Test module StdStack
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 StdStack
11
12 Start
13 = testn 1000
14 (\x n ->
15 newStack_is_empty /\
16 stack_is_reverse n /\
17 pop_empty_is_ok /\
18 top_na_push n x /\
19 pop_na_push x /\
20 count_counts n x /\
21 pop_maakt_stack_korter n /\
22 True
23 )
24
25 newStack_is_empty :: Property
26 newStack_is_empty = name "newStack_is_empty" (isEmpty (elements empty))
27
28 stack_is_reverse :: Int -> Property
29 stack_is_reverse n = name "stack_is_reverse"
30 (elements (pushes [1..n`] newStack) == reverse [1..n`])
31 where n` = min (abs n) 100
32
33 pop_empty_is_ok :: Property
34 pop_empty_is_ok = name "pop_empty_is_ok" (count (pop empty) == 0)
35
36 top_na_push :: Int Int -> Property
37 top_na_push x n = name "top_na_push"
38 (top (push x (pushes [1..n`] newStack)) == x)
39 where n` = min (abs n) 100
40
41 pop_na_push :: Int -> Property
42 pop_na_push a = name "pop_na_push"
43 (top (pop (pop (pushes [a,b,c] newStack))) == a)
44 where b = a + a + one
45 c = b + a + one
46
47 count_counts :: Int Int -> Property
48 count_counts n x = name "count_counts"
49 (length (elements stack) == count stack)
50 where stack = pushes [1..n`] newStack
51 n` = min (abs n) 100
52
53 pop_maakt_stack_korter :: Int -> Property
54 pop_maakt_stack_korter n = name "pop_maakt_stack_korter"
55 (count stack == 0 || count (pop stack) == count stack - 1)
56 where stack = pushes [1..n`] newStack
57 n` = min (abs n) 100
58
59 empty :: Stack Int
60 empty = newStack