diff options
author | tomsmeding <tom.smeding@gmail.com> | 2019-11-18 18:36:57 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2019-11-18 18:36:57 +0100 |
commit | 481884fb892f949478dad8d801ced704baea986c (patch) | |
tree | 8c5bcf1d306c8ad3d39d449da8def74cb24dca2d /tests/stdlib.lisp | |
parent | 4746aa52f85f4dc3ce8e195f0a5fd8afe2d54378 (diff) |
Automatic testing of examples
Diffstat (limited to 'tests/stdlib.lisp')
-rw-r--r-- | tests/stdlib.lisp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/stdlib.lisp b/tests/stdlib.lisp new file mode 100644 index 0000000..380fa2a --- /dev/null +++ b/tests/stdlib.lisp @@ -0,0 +1,28 @@ +(define cadr (x) (car (cdr x))) +(define caddr (x) (car (cdr (cdr x)))) +(define cadddr (x) (car (cdr (cdr (cdr x))))) + +(define YY (recur) (lambda (f) (lambda (a) (f ((recur recur) f) a)))) +(define Y (YY YY)) + +(define for (start end f) + (if (<= start end) + (do (f start) (for (+ start 1) end f)) + '())) + +(define with-open-file (path mode f) + (let ((fid (sys-open-file mode path))) + (let ((value (f fid))) + (do + (sys-close-file fid) + value)))) + +(define read-file (path) + (with-open-file path 0 (lambda (fid) + ; (print (sys-get-char fid)) + ; (print (let ((x (lambda (arg) fid))) (x 42))) + (let ((helper (Y (lambda (recur s) + (let ((ch (sys-get-char fid))) + (if (null? ch) s (recur (+ s ch)))))))) + (helper "")) + ))) |