From a1592ca61fc84501703116457542d0239693339d Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 22 Apr 2015 17:49:53 -0400 Subject: [PATCH] testing --- test.scm | 100 +++++++++++++++++++------------------------------------ 1 file changed, 34 insertions(+), 66 deletions(-) diff --git a/test.scm b/test.scm index ce6998ac..d1ebdcd8 100644 --- a/test.scm +++ b/test.scm @@ -1,67 +1,35 @@ -1.1 -;((lambda (x) -; ((lambda () -; ((lambda (z) -; (+ x z)) 2));)) -; 1) -;((lambda (x y z) (+ x y)) 1 2 3) -(define x 1) -(define y 2) -(write (+ x y 3.3)) -((lambda () (+ 1 2))) -(+ x 2 3 4 1 34 2 5 2 -2 2 -10) - -;;; Temporary testing, delete this once it works -; Need to rewrite the code to use this, and preserve the global def -;(define (test) -; (call/cc -; (lambda (return) -; (return #t)))) -;(write (test)) -; -;; (write -;; (with-exception-handler -;; (lambda (con) -;; (cond -;; ((string? con) -;; (display con)) -;; (else -;; (display "a warning has been issued"))) -;; 42) -;; (lambda () -;; (+ (raise-continuable "should be a number") 23) -;; ))) -;; ;prints: should be a number -;; ;=> 65 -;; -;; (write -;; (call/cc -;; (lambda (k) -;; (with-exception-handler -;; (lambda (x) -;; (display "condition: ") -;; (write x) -;; ;(newline) -;; (k 'exception)) -;; (lambda () -;; (+ 1 (raise 'an-error))))))) -;; -;; (with-exception-handler -;; (lambda (x) -;; (display "something went wrong\n")) -;; (lambda () -;; (+ 1 (raise 'an-error)))) -;; -;; ;(define test '(a b)) -;; ;(set-car! test '(1 2 3)) -;; ;(write test) -;; ;(raise 'done) -;; ;(define (loop n) -;; ; (cond -;; ; ((= n 10000) -;; ; (write test) -;; ; (loop 0)) -;; ; (else -;; ; (loop (+ n 1))))) -;; ;(loop 0) +(define (test) + (call/cc + (lambda (k) + (write (list 'result + (with-exception-handler + (lambda (obj) + (display "Error: ") + (cond + ((pair? obj) + (for-each + (lambda (o) + (display o) + (display " ")) + obj)) + (else + (display obj))) + (display "\n") + (k #t)) + (lambda () + (repl)))))))) +(define (repl) + (display "cyclone> ") + (let ((c 'done)) ;(read)))) ;; fine with this line + ;(let ((c (eval 'done))) ;(read)))) ;; Crashes with this line + ;(let ((c (read))) + (cond + ((not (eof-object? c)) + (write c) + ;(test) + ) + (else + (exit 0) ;; TODO: crashes on this branch... WTF? + )))) +(test)