racket/pkgs/racket-test/tests/units/test-deps.rkt
Matthew Flatt be8f70fffb racket/unit: static checking of initialization dependencies
When using `compound-unit/infer` and similar, check the `link` clause
against each unit's static information for initialization dependencies.
Also, propagate dependency information in `define-compount-unit`.
2015-02-06 09:22:01 +01:00

58 lines
975 B
Racket

#lang racket/load
(define-signature a^ ())
(define-unit a
(import)
(export a^))
(define-unit u
(import a^)
(export)
(init-depend a^))
(define later-init-exn?
(lambda (x)
(and (exn? x)
(regexp-match? #rx"depends on initialization of later unit"
(exn-message x)))))
(with-handlers ([later-init-exn? void])
(eval '(define-compound-unit/infer x
(import)
(export)
(link
(() u A)
(([A : a^]) a)))))
(define-compound-unit/infer x
(import)
(export)
(link
(([A : a^]) a)
(() u A)))
(define-compound-unit/infer uc
(import a^)
(export)
(link
(() u)))
(with-handlers ([later-init-exn? void])
(eval '(define-compound-unit/infer xc
(import)
(export)
(link
(() uc A)
(([A : a^]) a)))))
(define-compound-unit/infer xc
(import)
(export)
(link
(([A : a^]) a)
(() uc A)))