adding another example in the cs019 docs

This commit is contained in:
Danny Yoo 2011-11-11 16:26:58 -05:00
parent b2726d4591
commit f84f120cf2

View File

@ -33,6 +33,7 @@
current-output-port current-output-port
lambda lambda
true false true false
check-expect
...))) ...)))
@(define-runtime-path whalesong-path "..") @(define-runtime-path whalesong-path "..")
@ -678,6 +679,17 @@ can accept the event as an argument.
@defstruct[event ([kvpairs (listof (list symbol (or/c string number)))])]{} @defstruct[event ([kvpairs (listof (list symbol (or/c string number)))])]{}
You can construct events for testing purposes by using @racket[make-event].
@codeblock|{
#lang planet dyoo/whalesong/cs019
;; Synthesizing a location event
(define my-event (make-event '((latitude 41)
(longitude -71))))
(check-expect (event-ref my-event "latitude") 41)
(check-expect (event-ref my-event "longitude") -71)
}|
@defthing[Event$ sig]{The signature for an event.} @defthing[Event$ sig]{The signature for an event.}
@defproc[(event-ref [evt event?] [name (or/c symbol string)]) value]{ @defproc[(event-ref [evt event?] [name (or/c symbol string)]) value]{