;;;; dynamic-import-test.scm -*- Scheme -*- ;;;; Kon Lovett, Feb '22 (import test) (import (test-utils gloss)) (import (only (chicken format) format)) (test-begin "Dynamic Import") ;;; (import dynamic-import) ;; No Dependencies ;(srfi 1) (import (chicken fixnum)) (define (make-list len elt) ;elt optional but here always provided (do ((i len (fx- i 1)) (ans '() (cons elt ans))) ((fx<= i 0) ans)) ) (define (make-list/as df) (case-lambda (() df) ((n) (cond ((fixnum? n) (make-list n df)) ((list? n) (make-list (length n) df)) (else (error 'make-list/as "invalid length specification" n df)) ) ) ) ) (test-group "\"Catching\" Warnings" (define +warns+ '()) ;NOTE disable to see warnings during the test (enable-warnings #f) (dynamic-import-warning (lambda args (set! +warns+ (cons args +warns+)))) (define falses (make-list/as #f)) #| ;FIXME catch syntax errors (dynamic-import () foo) (dynamic-import m1) (dynamic-import srfi-1 ()) |# (dynamic-import srfi-1 append-reverse! falses) (test-assert (procedure? append-reverse!)) (dynamic-import (foo bar baz srfi-1) (delete-duplicates delete-duplicates!) falses) (test-assert (procedure? delete-duplicates)) (test-assert (procedure? delete-duplicates!)) (dynamic-import (m1 (m1 sm1) (srfi 1)) foobar (default 23)) (test 23 foobar) (gloss "warnings" +warns+) (test "\"Caught\" warnings" 1 (length +warns+)) ) ;;; (test-end "Dynamic Import") (test-exit)