~ chicken-core (master) /tests/module-tests-compiled.scm
Trap1;;;; module-tests-compiled.scm234(include "test.scm")56(test-begin "modules/compiled")789;; inlines where walked twice (once for extracting mutable constants)10;; and then when expanded, this caused inline function names to be11;; aliased/renamed twice - also, aliasing in syntax-defs could make12;; inline func unrecognizable for canonicalizer.1314(module m1 (f1)15 (import scheme (chicken base))16 (define-inline (bar x) (cons x '(foo)))17 (define-syntax s118 (syntax-rules ()19 ((_ x) (list (bar x)))))20 (define (f1 x) (s1 x)))2122(import m1)23(test-equal "inline in syntax" (f1 'ok) '((ok foo)))242526;; here, the identical names of alias/real id pairs in primitive27;; modules with prefix applied would cause the second to be marked28;; ##core#aliase'd. That would avoid renaming of the newly defined29;; vector-fill!.3031(module m2 (vector-fill!)32 (import (except scheme vector-fill!)33 (prefix (only scheme vector-fill!) %))34 (define (vector-fill! x v)35 (%vector-fill! v x)36 v))3738(import m2)39(define v (vector 1 2 3))40(test-equal "unmarked primitive exports" (vector-fill! 99 v) '#(99 99 99))4142(module m3 (op)43 (import scheme)44 (define op -))4546(module m4 (op)47 (import scheme)48 (define op +))4950;; Lexically scoped import, see #14375152(import m4)53(test-equal "lexically scoped import uses imported module"54 3 (let () (import m3) (op 5 2)))5556(test-equal "After leaving scope, fall back to old import" 7 (op 5 2))5758(eval '(import m4))59(test-equal "Interpreted code behaves identically on lexical import"60 3 (eval '(let () (import m3) (op 5 2))))6162(test-equal "Interpreted code behaves identically after leaving scope"63 7 (eval '(op 5 2)))6465;; This was the remaining bug: imports would be evaluated during66;; macro expansion, mutating ##sys#current-environment, but the67;; code walker would keep the old syntax environment.68(begin69 (import m3)70 (test-equal "In begin, imports are seen immediately" 3 (op 5 2)))7172(test-equal "begin splices; imports still active afterwards" 3 (op 5 2))7374(test-end "modules")7576(test-exit)