forked from mighty-gerbils/gerbil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests for the always & repeat procedures
- Loading branch information
1 parent
62b46ef
commit 77ab0f8
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(export func-test) | ||
|
||
(import | ||
:gerbil/gambit/exceptions | ||
:std/error :std/misc/func :std/test) | ||
|
||
(def (make-counter) | ||
(let (x 0) | ||
(lambda () | ||
(set! x (1+ x)) | ||
x))) | ||
|
||
(def func-test | ||
(test-suite "test :std/misc/func" | ||
(test-case "test repeat" | ||
(check-equal? (repeat 2 3) '(2 2 2)) | ||
(check-equal? (repeat (make-counter) 2) '(1 2)) | ||
(check-equal? (repeat identity 2 10) '(10 10)) | ||
(check-equal? (repeat 2 -1) '(2))) | ||
(test-case "test always" | ||
;; make sure passed function is called multiple times | ||
(check-equal? | ||
(let (fn (always (make-counter))) | ||
[(fn) (fn)]) '(1 2)) | ||
(check-equal? | ||
(let (fn (always identity 'foo)) | ||
(fn)) 'foo) | ||
(check-equal? | ||
(let (fn (always 5)) (fn)) 5)))) |
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