learning-suite

Thu Apr 24 12:09:13+0200 2025

Creative Commons LicenseCreative Commons LicenseCreative Commons License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

Table of contents
  1. test-alist-ref: pass
  2. test/len: pass
  3. test/c-apply: pass
  4. test-null-eq?: pass

Tests summary

scheme code
((ran 4) (failed 0))

1. test-alist-ref: pass

scheme code
(define (test-alist-ref _)
  (let ((alst '((a 3) (b 2))))
    (⊦= '(3) (alist-ref 'a alst))
    (⊦= '(2) (alist-ref 'b alst))
    (⊦= #f (alist-ref 'c alst))))

2. test/len: pass

scheme code
(define (test/len _)
  (let ((my-strlen
          (foreign-lambda*
            int
            ((scheme-object cons))
            "C_return(C_header_size(cons));")))
    (⊦= 2 (my-strlen (cons 1 '())))
    (⊦= 2 (my-strlen (cons 1 (cons 2 (cons 3 '())))))
    (⊦= 11 (my-strlen "hello world"))))

3. test/c-apply: pass

scheme code
(define (test/c-apply _)
  (let ((witness (gensym))
        (my-strlen
          (foreign-safe-lambda*
            scheme-object
            ((scheme-object f))
            "\t\t\t\t\t  C_word res;\n\t\t\t\t\t  int s = CHICKEN_apply(f, C_SCHEME_END_OF_LIST, &res);\n\t\t\t\t\t  printf(\"code: %d\\n\", s);\n\t\t\t\t\t  C_return (res);")))
    (⊦= witness (car (my-strlen (lambda () (list witness 4)))))))

4. test-null-eq?: pass

scheme code
(define (test-null-eq? _) (⊨ (eq? '() '())))