|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-module (test-srfi-2) |
|
#:use-module (test-suite lib) |
|
#:use-module (srfi srfi-2)) |
|
|
|
(pass-if-equal 1 (and-let* () 1)) |
|
(pass-if-equal 2 (and-let* () 1 2)) |
|
(pass-if-equal #t (and-let* ())) |
|
|
|
(pass-if-equal #f (let ((x #f)) (and-let* (x)))) |
|
(pass-if-equal 1 (let ((x 1)) (and-let* (x)))) |
|
(pass-if-equal #f (and-let* ((x #f)))) |
|
(pass-if-equal 1 (and-let* ((x 1)))) |
|
(pass-if-exception "bad clause" '(syntax-error . "Bad clause") |
|
(eval '(and-let* (#f (x 1))) (current-module))) |
|
(pass-if-equal #f (and-let* ((#f) (x 1)))) |
|
(pass-if-exception "bad clause" '(syntax-error . "Bad clause") |
|
(eval '(and-let* (2 (x 1))) (current-module))) |
|
(pass-if-equal 1 (and-let* ((2) (x 1)))) |
|
(pass-if-equal 2 (and-let* ((x 1) (2)))) |
|
(pass-if-equal #f (let ((x #f)) (and-let* (x) x))) |
|
(pass-if-equal "" (let ((x "")) (and-let* (x) x))) |
|
(pass-if-equal "" (let ((x "")) (and-let* (x)))) |
|
(pass-if-equal 2 (let ((x 1)) (and-let* (x) (+ x 1)))) |
|
(pass-if-equal #f (let ((x #f)) (and-let* (x) (+ x 1)))) |
|
(pass-if-equal 2 (let ((x 1)) (and-let* (((positive? x))) (+ x 1)))) |
|
(pass-if-equal #t (let ((x 1)) (and-let* (((positive? x)))))) |
|
(pass-if-equal #f (let ((x 0)) (and-let* (((positive? x))) (+ x 1)))) |
|
(pass-if-equal 3 |
|
(let ((x 1)) (and-let* (((positive? x)) (x (+ x 1))) (+ x 1)))) |
|
|
|
|
|
|
|
|
|
|
|
(pass-if-equal 4 |
|
(let ((x 1)) |
|
(and-let* (((positive? x)) (x (+ x 1)) (x (+ x 1))) (+ x 1)))) |
|
|
|
(pass-if-equal 2 |
|
(let ((x 1)) (and-let* (x ((positive? x))) (+ x 1)))) |
|
(pass-if-equal 2 |
|
(let ((x 1)) (and-let* (((begin x)) ((positive? x))) (+ x 1)))) |
|
(pass-if-equal #f |
|
(let ((x 0)) (and-let* (x ((positive? x))) (+ x 1)))) |
|
(pass-if-equal #f |
|
(let ((x #f)) (and-let* (x ((positive? x))) (+ x 1)))) |
|
(pass-if-equal #f |
|
(let ((x #f)) (and-let* (((begin x)) ((positive? x))) (+ x 1)))) |
|
|
|
(pass-if-equal #f |
|
(let ((x 1)) (and-let* (x (y (- x 1)) ((positive? y))) (/ x y)))) |
|
(pass-if-equal #f |
|
(let ((x 0)) (and-let* (x (y (- x 1)) ((positive? y))) (/ x y)))) |
|
(pass-if-equal #f |
|
(let ((x #f)) (and-let* (x (y (- x 1)) ((positive? y))) (/ x y)))) |
|
(pass-if-equal 3/2 |
|
(let ((x 3)) (and-let* (x (y (- x 1)) ((positive? y))) (/ x y)))) |
|
|
|
|
|
|