diff options
author | Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> | 2000-05-08 17:42:03 +0000 |
---|---|---|
committer | Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> | 2000-05-08 17:42:03 +0000 |
commit | 57e7f2700111e71e03df288af4494fc63ab27c2b (patch) | |
tree | c8b8dac77386c86a77e40808e5be75bb6a770bcd /test-suite/tests/hooks.test | |
parent | 1a45015332da33e4974bd18ea77cc4c1c8bdb12d (diff) | |
download | guile-57e7f2700111e71e03df288af4494fc63ab27c2b.tar.gz |
Adopted a couple of nice ideas from Greg.
Diffstat (limited to 'test-suite/tests/hooks.test')
-rw-r--r-- | test-suite/tests/hooks.test | 211 |
1 files changed, 105 insertions, 106 deletions
diff --git a/test-suite/tests/hooks.test b/test-suite/tests/hooks.test index 5d328b422..bdd5e58e2 100644 --- a/test-suite/tests/hooks.test +++ b/test-suite/tests/hooks.test @@ -70,114 +70,113 @@ `(pass-if ,string (not ,form))) ;; {The tests} -(catch-test-errors (let ((proc1 (lambda (x) (+ x 1))) - (proc2 (lambda (x) (- x 1))) - (bad-proc (lambda (x y) #t))) - (with-test-prefix "hooks" - (pass-if "make-hook" - (catch-error-returning-false - #t - (define x (make-hook 1)))) + (proc2 (lambda (x) (- x 1))) + (bad-proc (lambda (x y) #t))) + (with-test-prefix "hooks" + (pass-if "make-hook" + (catch-error-returning-false + #t + (define x (make-hook 1)))) - (pass-if "add-hook!" - (catch-error-returning-false - #t - (let ((x (make-hook 1))) - (add-hook! x proc1) - (add-hook! x proc2)))) - - (with-test-prefix "add-hook!" - (pass-if "append" - (let ((x (make-hook 1))) - (add-hook! x proc1) - (add-hook! x proc2 #t) - (eq? (cadr (hook->list x)) - proc2))) - (pass-if "illegal proc" - (catch-error-returning-true - #t - (let ((x (make-hook 1))) - (add-hook! x bad-proc)))) - (pass-if "illegal hook" - (catch-error-returning-true - 'wrong-type-arg - (add-hook! '(foo) proc1)))) - (pass-if "run-hook" - (let ((x (make-hook 1))) - (catch-error-returning-false #t - (add-hook! x proc1) - (add-hook! x proc2) - (run-hook x 1)))) - (with-test-prefix "run-hook" - (pass-if "bad hook" - (catch-error-returning-true - #t - (let ((x (cons 'a 'b))) - (run-hook x 1)))) - (pass-if "too many args" - (let ((x (make-hook 1))) - (catch-error-returning-true - #t - (add-hook! x proc1) - (add-hook! x proc2) - (run-hook x 1 2)))) + (pass-if "add-hook!" + (catch-error-returning-false + #t + (let ((x (make-hook 1))) + (add-hook! x proc1) + (add-hook! x proc2)))) - (pass-if - "destructive procs" - (let ((x (make-hook 1)) - (dest-proc1 (lambda (x) - (set-car! x - 'i-sunk-your-battleship))) - (dest-proc2 (lambda (x) (set-cdr! x 'no-way!))) - (val '(a-game-of battleship))) - (add-hook! x dest-proc1) - (add-hook! x dest-proc2 #t) - (run-hook x val) - (and (eq? (car val) 'i-sunk-your-battleship) - (eq? (cdr val) 'no-way!))))) + (with-test-prefix "add-hook!" + (pass-if "append" + (let ((x (make-hook 1))) + (add-hook! x proc1) + (add-hook! x proc2 #t) + (eq? (cadr (hook->list x)) + proc2))) + (pass-if "illegal proc" + (catch-error-returning-true + #t + (let ((x (make-hook 1))) + (add-hook! x bad-proc)))) + (pass-if "illegal hook" + (catch-error-returning-true + 'wrong-type-arg + (add-hook! '(foo) proc1)))) + (pass-if "run-hook" + (let ((x (make-hook 1))) + (catch-error-returning-false #t + (add-hook! x proc1) + (add-hook! x proc2) + (run-hook x 1)))) + (with-test-prefix "run-hook" + (pass-if "bad hook" + (catch-error-returning-true + #t + (let ((x (cons 'a 'b))) + (run-hook x 1)))) + (pass-if "too many args" + (let ((x (make-hook 1))) + (catch-error-returning-true + #t + (add-hook! x proc1) + (add-hook! x proc2) + (run-hook x 1 2)))) - (pass-if "make-hook-with-name" - (catch-error-returning-false - #t - (let ((x (make-hook-with-name 'x 1))) - (add-hook! x proc1)))) - (pass-if "make-hook-with-name: bad name" - (catch-error-returning-true - 'wrong-type-arg - (define x (make-hook-with-name '(a b) 1)))) + (pass-if + "destructive procs" + (let ((x (make-hook 1)) + (dest-proc1 (lambda (x) + (set-car! x + 'i-sunk-your-battleship))) + (dest-proc2 (lambda (x) (set-cdr! x 'no-way!))) + (val '(a-game-of battleship))) + (add-hook! x dest-proc1) + (add-hook! x dest-proc2 #t) + (run-hook x val) + (and (eq? (car val) 'i-sunk-your-battleship) + (eq? (cdr val) 'no-way!))))) - (with-test-prefix "remove-hook!" - (pass-if "" - (let ((x (make-hook 1))) - (add-hook! x proc1) - (add-hook! x proc2) - (remove-hook! x proc1) - (not (memq proc1 (hook->list x))))) - ; Maybe it should error, but this is probably - ; more convienient - (pass-if "empty hook" - (catch-error-returning-false - #t - (let ((x (make-hook 1))) - (remove-hook! x proc1))))) - (pass-if "hook->list" - (let ((x (make-hook 1))) - (add-hook! x proc1) - (add-hook! x proc2) - (and (memq proc1 (hook->list x) ) - (memq proc2 (hook->list x))))) - (pass-if "reset-hook!" - (let ((x (make-hook 1))) - (add-hook! x proc1) - (add-hook! x proc2) - (reset-hook! x) - (null? (hook->list x)))) - (with-test-prefix "reset-hook!" - (pass-if "empty hook" - (let ((x (make-hook 1))) - (reset-hook! x))) - (pass-if "bad hook" - (catch-error-returning-true - #t - (reset-hook! '(a b)))))))) + (pass-if "make-hook-with-name" + (catch-error-returning-false + #t + (let ((x (make-hook-with-name 'x 1))) + (add-hook! x proc1)))) + (pass-if "make-hook-with-name: bad name" + (catch-error-returning-true + 'wrong-type-arg + (define x (make-hook-with-name '(a b) 1)))) + + (with-test-prefix "remove-hook!" + (pass-if "" + (let ((x (make-hook 1))) + (add-hook! x proc1) + (add-hook! x proc2) + (remove-hook! x proc1) + (not (memq proc1 (hook->list x))))) + ; Maybe it should error, but this is probably + ; more convienient + (pass-if "empty hook" + (catch-error-returning-false + #t + (let ((x (make-hook 1))) + (remove-hook! x proc1))))) + (pass-if "hook->list" + (let ((x (make-hook 1))) + (add-hook! x proc1) + (add-hook! x proc2) + (and (memq proc1 (hook->list x) ) + (memq proc2 (hook->list x))))) + (pass-if "reset-hook!" + (let ((x (make-hook 1))) + (add-hook! x proc1) + (add-hook! x proc2) + (reset-hook! x) + (null? (hook->list x)))) + (with-test-prefix "reset-hook!" + (pass-if "empty hook" + (let ((x (make-hook 1))) + (reset-hook! x))) + (pass-if "bad hook" + (catch-error-returning-true + #t + (reset-hook! '(a b))))))) |