Created
November 14, 2013 23:05
-
-
Save yamanetoshi/7475991 to your computer and use it in GitHub Desktop.
EoPL Ex.2.19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use gauche.test) | |
(add-load-path ".") | |
(load "stacks") | |
(test-start "stack") | |
(test-section "empty-stack") | |
(test* "empty-stack" | |
(test-error) | |
(stack-access 'pop (empty-stack))) | |
(test-section "empty-stack?") | |
(test* "empty-stack" | |
#t | |
(empty-stack? (empty-stack))) | |
(test-section "push") | |
(test* "pushed stack is not empty" | |
#f | |
(empty-stack? (push 1 (empty-stack)))) | |
(test-section "pop") | |
(test* "cannot pop from empty-stack" | |
(test-error) | |
(pop (empty-stack))) | |
(test* "get top of stack" | |
(empty-stack) | |
(pop (push 1 (empty-stack)))) | |
(test* "after pop" | |
#t | |
(empty-stack? (pop (push 1 (empty-stack))))) | |
(test-section "top") | |
(test* "cannot get from empty-stack" | |
(test-error) | |
(top (empty-stack))) | |
(test* "top of _not empty-stack_ check" | |
1 | |
(top (push 1 (empty-stack)))) | |
(test* "top not pop" | |
#f | |
(let ((s (push 1 (empty-stack)))) | |
(top s) | |
(empty-stack? s))) | |
(test-end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment