Skip to content

Commit c529c9e

Browse files
committed
Test the stepper with check-satisfied
1 parent dc4ada4 commit c529c9e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

htdp-test/tests/stepper/test-cases.rkt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,42 @@
11351135
:: 9 false (check-expect {(+ 1 1)} 2) -> 9 false (check-expect {2} 2)
11361136
:: 9 false true (check-expect {(+ 2 2)} 4) -> 9 false true (check-expect {4} 4))
11371137

1138+
;; check-satisfied is generally skipped
1139+
;; UPDATE ME when the stepper supports check-satisfied
1140+
(t 'check-satisfied-identifier m:upto-int/lam
1141+
(check-expect 1 (+ 1 1)) (check-satisfied (* 2 2) even?) (check-expect 3 (+ 1 2))
1142+
:: (check-expect 1 {(+ 1 1)}) -> (check-expect 1 {2})
1143+
:: false (check-expect 3 {(+ 1 2)}) -> false (check-expect 3 {3}))
1144+
1145+
;; non-identifier predicate in check-satisfied
1146+
;; UPDATE ME when the stepper supports check-satisfied
1147+
(t 'check-satisfied-lambda m:intermediate-lambda/both
1148+
(check-satisfied (+ 2 3) (lambda (n) (even? (sub1 n)))) (check-expect 3 (+ 1 2))
1149+
:: (check-expect 3 {(+ 1 2)}) -> (check-expect 3 {3}))
1150+
1151+
;; defined function in check-satisfied
1152+
;; define/lambda from user code is stepped
1153+
;; UPDATE ME when the stepper supports check-satisfied
1154+
(let* ([defs '(;; add2minus1 is stepped
1155+
(define (add2minus1 n) (+ 2 n -1))
1156+
;; the (lambda (j) ...) part is also stepped since it has cms
1157+
(define (curried-mul3 i) (lambda (j) (* 3 i j))))])
1158+
(t 'check-satisfied-defined m:intermediate-lambda/both
1159+
(define (add2minus1 n) (+ 2 n -1))
1160+
(define (curried-mul3 i) (lambda (j) (* 3 i j)))
1161+
(check-satisfied (add2minus1 5) even?)
1162+
(check-satisfied (curried-mul3 1) procedure?)
1163+
(check-satisfied (number? ((curried-mul3 2) 3)) boolean?)
1164+
(check-satisfied (curried-mul3 4) (lambda (f) (= (f 5) 60)))
1165+
:: ,@defs {(+ 2 5 -1)} -> ,@defs {6}
1166+
:: ... -> ,@defs {(lambda (j) (* 3 1 j))}
1167+
:: ... -> ,@defs {(lambda (j) (* 3 2 j))}
1168+
:: ... -> ,@defs {(* 3 2 3)}
1169+
:: ,@defs {(* 3 2 3)} -> ,@defs {18}
1170+
:: ... -> ,@defs {(lambda (j) (* 3 4 j))} ;; (f 5) is inside user code, so it is
1171+
:: ... -> ,@defs {(* 3 4 5)} ;; stepped through by the stepper; but
1172+
:: ,@defs {(* 3 4 5)} -> ,@defs {60})) ;; but (= (f 5) 60) is not.
1173+
11381174
(t 'check-random m:upto-int/lam
11391175
(check-random (+ 3 4) (+ 2 5)) (+ 4 5)
11401176
:: {(+ 4 5)} -> {9}

0 commit comments

Comments
 (0)