;;;;;;;;;;;;;;;;;;; TEST CASES: L2 ;;;;;;;;;;;;;;;; ;;; The following is used by 'hw06-test-helpers.ss': (define tests ; Each entry in the list is either ; [str val] (where val is the result of interpreting the string str), or ; [str val expr] (as above, but expr is the internal (struct) representation. ; (You might need to adjust that third field, if you use a different ; internal representation than my solution.) `{["{with x 5 9}" 9 ,(make-with 'x 5 9)] ["{with x 5 x}" 5 ,(make-with 'x 5 'x)] ["{with x {plus 2 3} x}" 5 ,(make-with 'x (make-sum 2 3) 'x)] ["{with x 5 {plus 4 3}}" 7] ["{with x 5 {plus x 3}}" 8] ["{with y 3 {with x 5 {plus x y}}}" 8] ["{with y 3 {with x y {plus x y}}}" 6] ["{with x 5 {with y 3 {plus {with x y {plus x y}} x}}}" 11] ["{with y {with z 4 {with y 99 z}} {with z 5 {plus {with z 10 y} {plus y z}}}}" 13] ; Check that we don't substitute Expr0: ["{with x {with x 5 x} {plus x 4}}" 9] ["{with x {with x 5 {plus x 1}} {plus x -4}}" 2] ["{with x {with y 5 {plus y 1}} {plus x -4}}" 2] ["{with x {with x 5 x} x}" 5 ,(make-with 'x (make-with 'x 5 'x) 'x)] ["{with x {with x 5 {plus x 1}} x}" 6 ,(make-with 'x (make-with 'x 5 (make-sum 'x 1)) 'x)] ["{with x {with y 5 {plus y 1}} x}" 6] })