From 481884fb892f949478dad8d801ced704baea986c Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 18 Nov 2019 18:36:57 +0100 Subject: Automatic testing of examples --- tests/stdlib.lisp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/stdlib.lisp (limited to 'tests/stdlib.lisp') 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 "")) + ))) -- cgit v1.2.3-54-g00ecf