diff options
| author | Chaos Eternal <chaos@shlug.org> | 2017-08-24 18:54:20 +0800 | 
|---|---|---|
| committer | Chaos Eternal <chaos@shlug.org> | 2017-08-27 15:03:43 +0800 | 
| commit | e038c289b15d6895c78d7694c12e75129bd2f4aa (patch) | |
| tree | 85bb38a58c1a8130e572f78c8f3410cc014207ff /scheme/chez/geiser/test.ss | |
| parent | 6a83beef6b949bcc51ae56bff7bdb3acf67ae69b (diff) | |
| download | geiser-chez-e038c289b15d6895c78d7694c12e75129bd2f4aa.tar.gz geiser-chez-e038c289b15d6895c78d7694c12e75129bd2f4aa.tar.bz2  | |
more reduction on geiser:eval, add test
Diffstat (limited to 'scheme/chez/geiser/test.ss')
| -rw-r--r-- | scheme/chez/geiser/test.ss | 90 | 
1 files changed, 90 insertions, 0 deletions
diff --git a/scheme/chez/geiser/test.ss b/scheme/chez/geiser/test.ss new file mode 100644 index 0000000..ac5503b --- /dev/null +++ b/scheme/chez/geiser/test.ss @@ -0,0 +1,90 @@ +(import (geiser) +	(chezscheme)) + + +(define-syntax get-result +  (syntax-rules () +    ((_ form) +     (with-output-to-string +       (lambda () +	 (geiser:eval #f form)))))) + +(define-syntax do-test +  (syntax-rules () +    ((_ form result) +     (assert +      (equal? +       (get-result form) +       result))))) + +;; (something-doesnot-exist) +;;=> Error: Exception: variable something-doesnot-exist is not bound +(do-test + '(something-doesnot-exist) + "((result \"\") (output . \"\") (error (key . \"Exception: variable something-doesnot-exist is not bound\")))\n" + ) + +;; (make-violation) +;;=> #<condition &violation> +(do-test + '(make-violation)  + "((result \"#<condition &violation>\\n\") (output . \"\"))\n") + +;; (values 1 2 3) +;;==> (1 2 3) +(do-test + '(values 1 2 3) + "((result \"(1 2 3)\\n\") (output . \"\"))\n") + +;; 1 +;;=> 1 +(do-test '1 "((result \"1\\n\") (output . \"\"))\n") + + +;; '(case-lambda +;;    [(x1 x2) (+ x1 x2)] +;;    [(x1 x2 x3) (+ (+ x1 x2) x3)] +;;    [(x1 x2 . rest) +;;     ((letrec ([loop (lambda (x1 x2 rest) +;; 		      (let ([x (+ x1 x2)]) +;; 			(if (null? rest) +;; 			    x +;; 			    (loop x (car rest) (cdr rest)))))]) +;;        loop) +;;      x1 +;;      x2 +;;      rest)] +;;    [(x1) (+ x1)] +;;    [() (+)]) +#|=> (case-lambda +  [(x1 x2) (+ x1 x2)] +  [(x1 x2 x3) (+ (+ x1 x2) x3)] +  [(x1 x2 . rest) +   ((letrec ([loop (lambda (x1 x2 rest) +                     (let ([x (+ x1 x2)]) +                       (if (null? rest) +                           x +                           (loop x (car rest) (cdr rest)))))]) +      loop) +     x1 +     x2 +     rest)] +  [(x1) (+ x1)] +  [() (+)]) +  |# +(do-test (quote '(case-lambda +  [(x1 x2) (+ x1 x2)] +  [(x1 x2 x3) (+ (+ x1 x2) x3)] +  [(x1 x2 . rest) +   ((letrec ([loop (lambda (x1 x2 rest) +                     (let ([x (+ x1 x2)]) +                       (if (null? rest) +                           x +                           (loop x (car rest) (cdr rest)))))]) +      loop) +     x1 +     x2 +     rest)] +  [(x1) (+ x1)] +  [() (+)])) "((result \"(case-lambda\\n  [(x1 x2) (+ x1 x2)]\\n  [(x1 x2 x3) (+ (+ x1 x2) x3)]\\n  [(x1 x2 . rest)\\n   ((letrec ([loop (lambda (x1 x2 rest)\\n                     (let ([x (+ x1 x2)])\\n                       (if (null? rest)\\n                           x\\n                           (loop x (car rest) (cdr rest)))))])\\n      loop)\\n     x1\\n     x2\\n     rest)]\\n  [(x1) (+ x1)]\\n  [() (+)])\\n\") (output . \"\"))\n") +  | 
