fixed error messages for create-world
This commit is contained in:
parent
ede83be3fb
commit
6b2419f100
|
@ -37,17 +37,18 @@
|
|||
;; -----------------------------------------------------------------------------
|
||||
;; packages for broadcasting information to the universe
|
||||
|
||||
(define-struct package (world message) #:transparent)
|
||||
|
||||
;; World Sexp -> Package
|
||||
(define (create-package w m)
|
||||
(check-arg 'make-package (sexp? m) 'sexp "second" m)
|
||||
(make-package w m))
|
||||
(define-values (make-package package? package-world package-message)
|
||||
(let ()
|
||||
(struct package (world message) #:transparent)
|
||||
(define (make-package w m)
|
||||
(check-arg 'make-package (sexp? m) 'sexp "second" m)
|
||||
(package w m))
|
||||
(values make-package package? package-world package-message)))
|
||||
|
||||
(provide
|
||||
(rename-out (create-package make-package)) ;; World S-expression -> Package
|
||||
package? ;; Any -> Package
|
||||
package-world
|
||||
make-package ;; World S-expression -> Package
|
||||
package? ;; Any -> Package
|
||||
package-world ;; Package -> World
|
||||
)
|
||||
|
||||
(define world%
|
||||
|
|
16
collects/2htdp/tests/error-messages.rkt
Normal file
16
collects/2htdp/tests/error-messages.rkt
Normal file
|
@ -0,0 +1,16 @@
|
|||
#lang racket
|
||||
|
||||
(require 2htdp/universe)
|
||||
|
||||
(with-handlers ((exn:fail:contract?
|
||||
(lambda (x)
|
||||
(unless (regexp-match "make-package" (exn-message x))
|
||||
(raise x)))))
|
||||
(make-package 1 2 3))
|
||||
|
||||
(with-handlers ((exn:fail:contract?
|
||||
(lambda (x)
|
||||
(unless (regexp-match "make-bundle" (exn-message x))
|
||||
(raise x)))))
|
||||
(make-bundle 1 2))
|
||||
|
|
@ -42,4 +42,4 @@ run name.rkt
|
|||
run pad1.rkt
|
||||
run pad1-handler.rkt
|
||||
run pad1-in-bsl.rkt
|
||||
|
||||
run error-messages.rkt
|
||||
|
|
Loading…
Reference in New Issue
Block a user