-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.rkt
executable file
·48 lines (39 loc) · 1.11 KB
/
tests.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#lang racket
(require "cascade.rkt")
(require test-engine/racket-tests)
(define (cad0 v)
(cas-cad-e v))
(define (cas0 v)
(case v))
(check-expect (cad0 'anything) (cas0 'anything))
(define (cas1 v)
(cas-cad-e v
((1) (display "1"))
((2) (display "2") (break 2))
((3) 3)))
(check-expect (cas1 1) 2) "12"
(check-expect (cas1 2) 2) "2"
(check-expect (cas1 3) 3)
(define (cas2 v)
(cas-cad-e v
((0 1) (display "0/1"))
((2 ) (display "2") (break 2))
((3 ) (display "3"))
((4 ) (display "4") (break 4))
((5 6) (display "5/6") 6)))
(check-expect (cas2 0) 2) "0/12"
(check-expect (cas2 1) 2) "0/12"
(check-expect (cas2 2) 2) "2"
(check-expect (cas2 3) 4) "34"
(check-expect (cas2 4) 4) "4"
(check-expect (cas2 5) 6) "5/6"
(check-expect (cas2 6) 6) "5/6"
(check-expect (cas2 7) (void))
(define (cas3 v)
(let ([w true])
(cas-cad-e v
[(0) (set! w false)]
[(1) (if w (break 1) (break 0))])))
(check-expect (cas3 0) 0)
(check-expect (cas3 1) 1)
(test)