summaryrefslogtreecommitdiff
path: root/files/practicum/StdStackTest.icl
diff options
context:
space:
mode:
authorMart Lubbers2015-02-06 08:39:37 +0100
committerMart Lubbers2015-02-06 08:39:37 +0100
commit379b6353396ca2401241d714733d570629835ffe (patch)
tree26652c854a79c627b5f50bc8ac26f9b84f8e196d /files/practicum/StdStackTest.icl
parentMerge branch 'master' of https://github.com/dopefishh/fp1 (diff)
added practicum files, updated gitignore
Diffstat (limited to 'files/practicum/StdStackTest.icl')
-rw-r--r--files/practicum/StdStackTest.icl60
1 files changed, 60 insertions, 0 deletions
diff --git a/files/practicum/StdStackTest.icl b/files/practicum/StdStackTest.icl
new file mode 100644
index 0000000..8127f53
--- /dev/null
+++ b/files/practicum/StdStackTest.icl
@@ -0,0 +1,60 @@
+module StdStackTest
+
+/* Test module StdStack
+ Voor werken met Gast:
+ (*) gebruik Environment 'Gast'
+ (*) zet Project Options op 'Basic Values Only' en '2M' Maximum Heap Size
+*/
+
+import gast
+import StdStack
+
+Start
+ = testn 1000
+ (\x n ->
+ newStack_is_empty /\
+ stack_is_reverse n /\
+ pop_empty_is_ok /\
+ top_na_push n x /\
+ pop_na_push x /\
+ count_counts n x /\
+ pop_maakt_stack_korter n /\
+ True
+ )
+
+newStack_is_empty :: Property
+newStack_is_empty = name "newStack_is_empty" (isEmpty (elements empty))
+
+stack_is_reverse :: Int -> Property
+stack_is_reverse n = name "stack_is_reverse"
+ (elements (pushes [1..n`] newStack) == reverse [1..n`])
+where n` = min (abs n) 100
+
+pop_empty_is_ok :: Property
+pop_empty_is_ok = name "pop_empty_is_ok" (count (pop empty) == 0)
+
+top_na_push :: Int Int -> Property
+top_na_push x n = name "top_na_push"
+ (top (push x (pushes [1..n`] newStack)) == x)
+where n` = min (abs n) 100
+
+pop_na_push :: Int -> Property
+pop_na_push a = name "pop_na_push"
+ (top (pop (pop (pushes [a,b,c] newStack))) == a)
+where b = a + a + one
+ c = b + a + one
+
+count_counts :: Int Int -> Property
+count_counts n x = name "count_counts"
+ (length (elements stack) == count stack)
+where stack = pushes [1..n`] newStack
+ n` = min (abs n) 100
+
+pop_maakt_stack_korter :: Int -> Property
+pop_maakt_stack_korter n = name "pop_maakt_stack_korter"
+ (count stack == 0 || count (pop stack) == count stack - 1)
+where stack = pushes [1..n`] newStack
+ n` = min (abs n) 100
+
+empty :: Stack Int
+empty = newStack