(use s48-modules test) (module chicken-exports (a1 b1) (import scheme) (define a1 1) (define b1 2)) ;; We're using EVAL everywhere because we want to have the TEST form ;; trap all errors, including those raised at macro expansion time. (test-group "basics" (test "import s48 module" 3 (eval '(begin (define-structure s48-exports (export c1) (open scheme) (begin (define c1 3) (define d1 4))) (import s48-exports) c1))) (test-error "non-exported symbols not accessible" (begin (define-structure s48-exports (export c1) (open scheme) (begin (define c1 3) (define d1 4))) (import s48-exports) d1)) (test "importing from chicken modules" 11 (eval '(begin (define-structure s48-import-from-chicken (export e1) (open scheme chicken-exports) (begin (define e1 (+ a1 10)))) (import s48-import-from-chicken) e1))) (test-error "error on undefined variable (ignore warning)" (eval '(define-structure missing-chicken-import (export g1) (open scheme) (begin (define f1 a1))))) (test-error "error when not importing core scheme (ignore warning)" (eval '(define-structure missing-scheme-import (export h1) (begin (define h1 1))))) (test "prefixed import" 101 (eval '(begin (define-structure prefixed-import (export i1) (open scheme (with-prefix chicken-exports p:)) (begin (define i1 (+ p:a1 100)))) (import prefixed-import) i1)))) (test-group "include-relative" (test "include file in current dir" 102 (eval '(begin (define-structure simple-file-import (export j1) (open scheme) (files simple-file-import)) (import simple-file-import) j1))) (test "include file in subdir" 103 (eval '(begin (define-structure subdir-file-import (export k1) (open scheme) (files subdir/subdir-file-import)) (import subdir-file-import) k1))) (test "include file in subsubdir" 104 (eval '(begin (include-relative "subdir/direct-inclusion.scm") (import subsubdir-file-import) l1))) (test "indirectly include file in subsubdir" 105 (eval '(begin (include-relative "subdir/indirect-inclusion.scm") (import subsubdir-indirect-file-import) m1))) (test "include file in two different subdirs" 106 (eval '(begin (define-structure subdir-file-import (export k1) (open scheme) (files subdir/subdir-file-import)) (define-structure subdir2-file-import (export n1) (open scheme) (files subdir2/subdir2-file-import)) (import subdir2-file-import) n1))))