File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 35
35
))
36
36
37
37
(run-tests module-test))
38
+
39
+ (provide make-account)
Original file line number Diff line number Diff line change
1
+ #lang racket
2
+ (require "exercise3-3.rkt " )
3
+ (define (make-joint account old-password new-password)
4
+ (lambda (pwd m)
5
+ (if (eq? pwd new-password)
6
+ (account old-password m)
7
+ (error "Incorrect joint account password " ))))
8
+
9
+ (module+ test
10
+ (require rackunit)
11
+ (require rackunit/text-ui)
12
+ (define peter-acc (make-account 100 'open-sesame ))
13
+ (define paul-acc (make-joint peter-acc 'open-sesame 'rosebud ))
14
+
15
+ (define module-test
16
+ (test-suite
17
+ "Tests for make-joint "
18
+ (check-equal? ((peter-acc 'open-sesame 'withdraw ) 40 ) 60 "Test original account with old password " )
19
+ (check-equal? ((paul-acc 'rosebud 'withdraw ) 40 ) 20 "Test joint account with new password " )
20
+ (check-exn (regexp "Incorrect joint account password " )
21
+ (lambda () ((paul-acc 'wrong-password 'deposit ) 50 )))
22
+ (check-equal? ((peter-acc 'open-sesame 'deposit ) 30 ) 50 "Test original account with old password still works " )
23
+ ))
24
+
25
+ (run-tests module-test))
You can’t perform that action at this time.
0 commit comments