set svn:eol-style
svn: r8875
This commit is contained in:
parent
1f5a7bf90a
commit
db62afaadc
|
@ -14,4 +14,4 @@
|
|||
(idraw:installer plthome)
|
||||
(graph:installer plthome))
|
||||
|
||||
)
|
||||
)
|
||||
|
|
|
@ -16,4 +16,3 @@
|
|||
(test-true "active?" (active? 'mf))
|
||||
(test-false "active? 2" (active? 'kk))
|
||||
(test-true "set name" (void? (set-name 'mf "matt")))))
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
(require "1.ss") ;; the module just above
|
||||
|
||||
;; implementation
|
||||
;; implementation
|
||||
;; [listof (list basic-customer? secret-info)]
|
||||
(define all '())
|
||||
|
||||
(define (find c)
|
||||
(define (has-c-as-key p)
|
||||
(define (find c)
|
||||
(define (has-c-as-key p)
|
||||
(id-equal? (basic-customer-id (car p)) c))
|
||||
(define x (filter has-c-as-key all))
|
||||
(if (pair? x) (car x) x))
|
||||
|
@ -33,27 +33,27 @@
|
|||
(set-basic-customer-name! (car bc-with-id) name))
|
||||
|
||||
(define c0 0)
|
||||
;; end of implementation
|
||||
;; end of implementation
|
||||
|
||||
(provide/contract
|
||||
;; how many customers are in the db?
|
||||
;; how many customers are in the db?
|
||||
[count natural-number/c]
|
||||
;; is the customer with this id active?
|
||||
;; is the customer with this id active?
|
||||
[active? (-> id? boolean?)]
|
||||
;; what is the name of the customer with this id?
|
||||
;; what is the name of the customer with this id?
|
||||
[name (-> (and/c id? active?) string?)]
|
||||
;; change the name of the customer with this id
|
||||
;; change the name of the customer with this id
|
||||
[set-name (->d ([id id?] [nn string?])
|
||||
()
|
||||
[result any/c] ;; result contract
|
||||
[result any/c] ;; result contract
|
||||
#:post-cond
|
||||
(string=? (name id) nn))]
|
||||
|
||||
|
||||
[add (->d ([bc (and/c basic-customer? not-active?)])
|
||||
()
|
||||
;; A pre-post condition contract must use
|
||||
;; 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
|
||||
[result any/c] ;; result contract
|
||||
#:post-cond (> count c0))])
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
(define s2 (push (push s0 2) 1))
|
||||
|
||||
(test/text-ui
|
||||
(test-suite
|
||||
(test-suite
|
||||
"stack"
|
||||
(test-true
|
||||
"empty"
|
||||
(test-true
|
||||
"empty"
|
||||
(is-empty? (initialize (flat-contract integer?) =)))
|
||||
(test-true "push" (stack? s2))
|
||||
(test-true
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
(define d (put (put (put d0 'a 2) 'b 2) 'c 1))
|
||||
|
||||
(test/text-ui
|
||||
(test-suite
|
||||
(test-suite
|
||||
"dictionaries"
|
||||
(test-equal? "value for" 2 (value-for d 'b))
|
||||
(test-false "has?" (has? (rem d 'b) 'b))
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
(define s (put (put (initialize (flat-contract integer?) =) 2) 1))
|
||||
|
||||
(test/text-ui
|
||||
(test-suite
|
||||
(test-suite
|
||||
"queue"
|
||||
(test-true
|
||||
(test-true
|
||||
"empty"
|
||||
(is-empty? (initialize (flat-contract integer?) =)))
|
||||
(test-true "put" (queue? s))
|
||||
|
|
Loading…
Reference in New Issue
Block a user