Test output for continuations [ok]

Testing time: 0s

'/usr/home/chicken/salmonella/build/salmonella-run-publish/chicken/bin/csi' -script run.scm < /dev/null 2>&1

Testing continuations ...
----------------------------
(define 1+ #f)
... passed in (CONTINUATION-INTERFACE)
(define (init)
  (+ 1 (catch cont (set! 1+ (continuation->procedure cont)) (throw cont 0))))
... passed in (CONTINUATION-INTERFACE)
(define (init-again)
  (+ 1
     (let ((cc (continuation)))
       (cond ((continuation? cc)
              (set! 1+ (continuation->procedure cc))
              (throw cc 0))
             (else cc)))))
... passed in (CONTINUATION-INTERFACE)
(define (search ok? lst)
  (catch return
         (for-each (lambda (item) (if (ok? item) (throw return item))) lst)
         #f))
... passed in (CONTINUATION-INTERFACE)
(define (search-with-goto ok? lst)
  (let ((start (continuation)))
    (cond ((null? lst) #f)
          ((ok? (car lst)) (car lst))
          (else (set! lst (cdr lst)) (goto start)))))
... passed in (CONTINUATION-INTERFACE)
(define (treat ok?) (lambda (item cont) (if (ok? item) (throw cont item))))
... passed in (CONTINUATION-INTERFACE)
(define (handled-search handle lst)
  (catch return (for-each (lambda (item) (handle item return)) lst) #f))
... passed in (CONTINUATION-INTERFACE)
(= (search even? '(1 2 3)) 2)
... passed in (CONTINUATION-INTERFACE)
(not (search even? '(1 3)))
... passed in (CONTINUATION-INTERFACE)
(= (search-with-goto odd? '(0 1 2 3)) 1)
... passed in (CONTINUATION-INTERFACE)
(not (search-with-goto odd? '(0 2)))
... passed in (CONTINUATION-INTERFACE)
(= (handled-search (treat even?) '(1 2 3)) 2)
... passed in (CONTINUATION-INTERFACE)
(define (product . nums)
  (let ((cc (escape-procedure)))
    (cond ((escape-procedure? cc)
           (cond ((null? nums) 1)
                 ((zero? (car nums)) (cc 0))
                 (else (* (car nums) (apply product (cdr nums))))))
          ((number? cc) cc))))
... passed in (ESCAPE-PROCEDURE-INTERFACE)
(= (product 1 2 3 4 5) 120)
... passed in (ESCAPE-PROCEDURE-INTERFACE)
(= (product 1 0 3 4 5) 0)
... passed in (ESCAPE-PROCEDURE-INTERFACE)
(define amb (make-amb))
... passed in (AMB)
(define (pythagoras . choices)
  (let ((a (apply (amb 'choose) choices))
        (b (apply (amb 'choose) choices))
        (c (apply (amb 'choose) choices)))
    ((amb 'assert) (= (* c c) (+ (* a a) (* b b))))
    ((amb 'assert) (< b a))
    (list a b c)))
... passed in (AMB)
(equal? (pythagoras 1 2 3 4 5 6 7) '(4 3 5))
... passed in (AMB)
(define threads (make-threads))
... passed in (COOPERATIVE-THREADS)
(equal?
  (let ((result '()))
    (define make-thunk
      (let ((counter 10))
        (lambda (name)
          (rec (loop)
               (if (< counter 0) ((threads 'quit)))
               (set! result (cons (cons name counter) result))
               (set! counter (- counter 1))
               ((threads 'yield))
               (loop)))))
    ((threads 'spawn) (make-thunk 'a))
    ((threads 'spawn) (make-thunk 'aa))
    ((threads 'spawn) (make-thunk 'aaa))
    ((threads 'start))
    (reverse result))
  '((a . 10)
    (aa . 9)
    (aaa . 8)
    (a . 7)
    (aa . 6)
    (aaa . 5)
    (a . 4)
    (aa . 3)
    (aaa . 2)
    (a . 1)
    (aa . 0)))
... passed in (COOPERATIVE-THREADS)
(equal?
  (let ((tree-iterator
          (lambda (tree)
            (lambda (yield)
              (let walk ((tree tree))
                (if (pair? tree)
                  (begin (walk (car tree)) (walk (cdr tree)))
                  (yield tree))))))
        (result '()))
    (iterate
      var
      (tree-iterator '(3 (4 . 5) . 6))
      (set! result (cons var result)))
    (reverse result))
  '(3 4 5 6))
... passed in (ITERATORS)

Results of continuations
----------------------------
All tests passed