
Changes: - Allow unit contracts to import and export the same signature. - Add "invoke" contracts that will wrap the result of invoking a unit contract, no wrapping occurs when a body contract is not specified - Improve error messages - Support for init-depend clauses in unit contracts. - Fix documentation to refelct the above - Overhaul of unit related tests Handling init-depend clauses in unit contracts is a rather large and somewhat non-backwards-compatible change to unit contracts. Unit contracts must now specify at least as many initialization dependencies as the unit value being contracted, but may include more. These new dependencies are now actually specified in the unit wrapper so that they will be checked by compound-unit expressions. This commit also adds more information to the first-order-check error messages. If a unit imports tagged signatures, previously the errror message did not specify which tag was missing from the unit contract. Now the tag is printed along with the signature name. Documentation has been edited to reflect the changes to unit/c contracts made by this commit. Additionally this commit overhauls all tests for units and unit contracts. Test cases now actually check that expected error messages are triggered when checking contract, syntax, and runtime errors. Test forms now expand into uses of rackunit's check-exn form so only test failures are reported and all tests in a file are run on every run of the test file.
57 lines
1.6 KiB
Racket
57 lines
1.6 KiB
Racket
#lang racket/load
|
|
|
|
(require "test-harness.rkt"
|
|
racket/private/unit-runtime)
|
|
|
|
;; check-unit
|
|
(test-runtime-error exn:fail:contract?
|
|
"result of unit expression was not a unit"
|
|
(check-unit 1 'check-unit))
|
|
|
|
(test (void)
|
|
(check-unit (make-unit 1 2 3 4 5) 'check-unit))
|
|
|
|
;; check-helper
|
|
(define sub-vector
|
|
#((a . #((t . r1) (t . r2) (t . r3)))
|
|
(a . #((#f . r1) (#f . r2) (#f . r3)))))
|
|
|
|
(test (void)
|
|
(check-helper sub-vector #() 'check-helper #f))
|
|
|
|
(test (void)
|
|
(check-helper sub-vector sub-vector 'check-helper #f))
|
|
|
|
(test (void)
|
|
(check-helper sub-vector
|
|
#((d . #((t . r2) (t . r3))))
|
|
'check-helper
|
|
#f))
|
|
|
|
(test-runtime-error exn:fail:contract?
|
|
"expects a unit with an export for tag t with signature c, which the given unit does not supply"
|
|
(check-helper sub-vector
|
|
#((c . #((t . r4) (t . r1) (t . r2) (t . r3))))
|
|
'check-helper
|
|
#f))
|
|
(define sub-vector2
|
|
#((a . #((t . r5) (t . r2) (t . r3)))
|
|
(b . #((t . r1) (t . r2) (t . r3)))))
|
|
|
|
(test (void)
|
|
(check-helper sub-vector2 sub-vector2 'check-helper #f))
|
|
|
|
(test (void)
|
|
(check-helper sub-vector2
|
|
#((a . #((t . r5) (t . r2) (t . r3))))
|
|
'check-helper #f))
|
|
|
|
(test-runtime-error exn:fail:contract?
|
|
"expects a unit with an export for tag t with signature c, which the given unit supplies multiple times"
|
|
(check-helper sub-vector2
|
|
#((c . #((t . r2) (t . r3))))
|
|
'check-helper #f))
|
|
|
|
;; check-deps
|
|
;;UNTESTED
|