Learning tests for CHICKEN Scheme

test/booleans: pass

(define (test/booleans _)
  (⊦= 'fail (if #f 'succeed 'fail))
  (⊦= 'succeed (if '() 'succeed 'fail))
  (⊦= 'succeed (if `(,#f ,#f) 'succeed 'fail))
  (⊦= 'else (cond ((and #t #f) => (λ (y) #t)) (else 'else))))
((eta 0.0) (memory #(6291456 1960280 1048576)) (stdout "") (stderr ""))

test/hash-table: pass

(define (test/hash-table _)
  (let1 (H (make-hash-table))
        (hash-table-set! H 'hello 'world)
        (⊦= #t (hash-table-exists? H 'hello)))
  (let1 (H (make-hash-table))
        (hash-table-set! H 'hello 'world)
        (hash-table-set! H 'hello 'new-world)
        (⊦= 'new-world (hash-table-ref H 'hello)))
  (⊦= '(3 4 5)
      (sort (hash-table-fold
              (alist->hash-table '((a . 3) (b . 4) (c . 5)))
              (λ (k v acc) (cons v acc))
              '())
            <)))
((eta 0.0) (memory #(6291456 1967072 1048576)) (stdout "") (stderr ""))

test/output-ports: pass

(define (test/output-ports _)
  (let* ((str-port (open-output-string))
         (result
           (with-output-to-port
             str-port
             (λ () (display "hello world") "succeed"))))
    (⊦= "hello world" (get-output-string str-port))
    (⊦= "succeed" result))
  (call+stdout
    (λ () (display "hello world") '(hello world))
    (λ (r s) (⊨ (and (equal? '(hello world) r) (equal? "hello world" s)))))
  (⊦= "succeed" (with-output-to-string (λ () (display 'succeed) #t)))
  (⊦= "hello-world"
      (call-with-output-string (λ (port) (display 'hello-world port) #t))))
((eta 0.0) (memory #(6291456 1963760 1048576)) (stdout "") (stderr ""))

test/multiple-values: pass

(define (test/multiple-values _)
  (⊦= '(hello world)
      (call-with-values (λ () (values 'hello 'world)) identity*))
  (⊦= 'succeed (values 'succeed))
  (⊦= 'fail (values 'fail 'succeed)))
((eta 0.0) (memory #(6291456 1964456 1048576)) (stdout "") (stderr ""))

test/keyword-arguments: pass

(define (test/keyword-arguments _)
  (define-syntax
    add-key-args
    (syntax-rules
      ()
      ((_ name) (define name (lambda (#!key (hello 0)) (add1 hello))))))
  (add-key-args f)
  (define g (lambda (#!key (hello 0)) (add1 hello)))
  (⊦= 1 (f))
  (⊦= 4 (f #:hello 3))
  (⊦= 1 (f #:hello₁ 3))
  (⊦error (identity 0 #:hello 3))
  (⊦= 1 (g))
  (⊦= 4 (g #:hello 3))
  (⊦= 1 (g #:hello₁ 3)))
((eta 0.0) (memory #(6291456 1970256 1048576)) (stdout "") (stderr ""))

test/eval-ignores-lexical-scope: pass

(define (test/eval-ignores-lexical-scope _) (let1 (x 4) (⊦error (eval 'x))))
((eta 0.0) (memory #(6291456 1970504 1048576)) (stdout "") (stderr ""))
Categories: scheme 

See also

The (aux anthropic) module The Anthropic Messages API, offline The (aux cml) module Events, threads, synchronous variables, the library and I/O The (aux hakaru10) modules Random sources, distributions, the language, exact inference and examples The (aux kanren) modules Arithmetic, dates, presentation of answers and a union-find miniKanren The (aux games dice-of-doom) module Dice of Doom The (aux machine) modules Environments, the SC machine and the SECD machine The (aux schemer seasoned) module The Seasoned Schemer The (aux continuation) modules Classic operators, escapers, amb and Collatz sequences The (aux category) modules Monads: list, maybe, probability, ziplist, difference lists and state The (aux timsort) module Sorting and the trace buffer The (aux fds) modules Functional queues and union-find The (aux sxml) module Rendering SXML to HTML The (aux variable) module Logic variables introduced by fresh The (aux tabling) module Memoization and tabled definitions The (aux commons) module Promises delay and make-promise The Ackermann function On unary numbers, as lists Concurrent ML for CHICKEN Scheme Porting SML/NJ CML as the (aux cml) library CHICKEN Scheme Versions and implementation notes The SBRAL data structure Skew Binary Random-Access Lists Pattern matching Scheme macrology: a generalized pattern matcher The (aux hansei) modules Inference, random sources, lazy lists, logic programming and example models The (aux nondeterministic) module Learning tests for Scheme The (aux stream) modules Streams, streams after SICP, and sequences and power series The (aux unittest) module Bootstrapping a unittest framework Scheme lang: Chez, 48 and Chicken Some docs, refs and containers, respectively. The Reasoned Schemer miniKanren, microKanren and some implementations Aggregation predicates for µkanren Groups, window functions, sets and enumerations miniKanren, live and untagged Quine generation via relational interpreters Pure, declarative, and constructive arithmetic relations A declarative pearl Final shift for call/cc Direct implementation of shift and reset Call with Current Continuation Patterns Cogen in six lines The Seasoned Schemer The Little Schemer Adding generic functions to Scheme Handling control