diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-examples/1-test.rkt b/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-examples/1-test.rkt index 6547a7de94..b05ab3b750 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-examples/1-test.rkt +++ b/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-examples/1-test.rkt @@ -10,7 +10,7 @@ (test-suite "manager" (test-equal? "id lookup" "matthias" (name 'mf)) - (test-equal? "count" 4 count) + (test-equal? "count" 4 (get-count)) (test-true "active?" (active? 'mf)) (test-false "active? 2" (active? 'kk)) (test-true "set name" (void? (set-name 'mf "matt"))))) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-examples/1b.rkt b/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-examples/1b.rkt index 97877eb3a6..77c6182bcc 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-examples/1b.rkt +++ b/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-examples/1b.rkt @@ -18,6 +18,7 @@ (define not-active? (compose not active? basic-customer-id)) (define count 0) +(define (get-count) count) (define (add c) (set! all (cons (list c 'secret) all)) @@ -37,23 +38,20 @@ (provide (contract-out ;; how many customers are in the db? - [count natural-number/c] + [get-count (-> natural-number/c)] ;; is the customer with this id active? - [active? (-> id? boolean?)] + [active? (-> id? boolean?)] ;; what is the name of the customer with this id? - [name (-> (and/c id? active?) string?)] + [name (-> (and/c id? active?) string?)] ;; change the name of the customer with this id - [set-name (->d ([id id?] [nn string?]) - () - [result any/c] ;; result contract - #:post-cond - (string=? (name id) nn))] + [set-name (->i ([id id?] [nn string?]) + [result any/c] ;; result contract + #:post (id nn) (string=? (name id) nn))] - [add (->d ([bc (and/c basic-customer? not-active?)]) - () - ;; A pre-post condition contract must use - ;; a side-effect to express this contract - ;; via post-conditions - #:pre-cond (set! c0 count) - [result any/c] ;; result contract - #:post-cond (> count c0))])) + [add (->i ([bc (and/c basic-customer? not-active?)]) + ;; A pre-post condition contract must use + ;; a side-effect to express this contract + ;; via post-conditions + #:pre () (set! c0 count) + [result any/c] ;; result contract + #:post () (> count c0))])) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-utils.rkt b/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-utils.rkt index e1fca63fb9..bc40b94cc5 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-utils.rkt +++ b/pkgs/racket-pkgs/racket-doc/scribblings/guide/contracts-utils.rkt @@ -2,6 +2,7 @@ (require scribble/basic (for-syntax racket/port) + (for-label racket rackunit rackunit/text-ui) racket/include scribble/eval (except-in scribble/manual link)) @@ -31,22 +32,6 @@ (define (solution) (bold (format "Solution to exercise ~a" exercise-number))) -#; -(define-syntax (external-file stx) - (syntax-case stx () - [(_ filename) - (call-with-input-file (build-path "contracts-examples" (format "~a.rkt" (syntax-e #'filename))) - (λ (port) - (define prefix "#reader scribble/comment-reader\n[racketmod\nracket\n") - (define suffix "]") - (with-syntax ([s (parameterize ([read-accept-reader #t]) - (read-syntax 'contract-examples - (input-port-append #f - (open-input-string prefix) - port - (open-input-string suffix))))]) - #'s)))])) - (require (for-syntax (only-in scribble/comment-reader [read-syntax comment-reader]))) (define-for-syntax (comment-racketmod-reader path port) (let ([pb (peek-byte port)]) diff --git a/pkgs/racket-pkgs/racket-test/tests/racket/contract/contract-out.rkt b/pkgs/racket-pkgs/racket-test/tests/racket/contract/contract-out.rkt index 70a8bfa745..fb4677119a 100644 --- a/pkgs/racket-pkgs/racket-test/tests/racket/contract/contract-out.rkt +++ b/pkgs/racket-pkgs/racket-test/tests/racket/contract/contract-out.rkt @@ -938,26 +938,6 @@ (eval '(require 'provide/contract48-m1))) "provide/contract48-m1") - (test/spec-passed/result - 'provide/contract49 - '(let () - (eval '(module provide/contract49-m1 racket/base - (require racket/contract/base) - (define count 0) - (define (add) (set! count (+ count 1))) - (provide - add - (contract-out - [count natural-number/c])))) - (eval '(module provide/contract49-m2 racket/base - (require 'provide/contract49-m1) - (add) - (define (provide/contract49-x) count) - (provide provide/contract49-x))) - (eval '(require 'provide/contract49-m2)) - (eval '(provide/contract49-x))) - 1) - (contract-error-test 'contract-error-test8 #'(begin