;;;;;;;;;;;;;;;;;;; TEST CASES: M2 ;;;;;;;;;;;;;;;; ;;; The following is used by 'hw07-test-helpers.ss': ;;; Paste this into your solution-code for M2, ;;; and then have hw07-test-helpers.ss 'require' that file. (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). `{; Some basic one-variable lets: ["let y be (3) in (7)" 7] ["let y be (3) in (y)" 3] ["let y be (3) in ((y + y))" 6] ["let x be ((2 + 3)) in (x)" 5] ["let x be (5) in ((4 + 3))" 7] ["let x be (5) in ((x + 3))" 8] ;; Two variables, not shadowing: ["let y be (3) in (let x be (5) in ((x + y)))" 8] ["let y be (3) in (let x be (y) in ((x + y)))" 6] ;; Two variables, shadowing in the body: ["let x be (5) in (let x be (3) in (x))" 3] ["let x be (5) in (let x be (x) in (x))" 5] ["let x be (5) in (let x be ((x + 1)) in (x))" 6] ["let x be (5) in (let x be ((x + 1)) in (x + 2))" 8] ["let x be (5) in (let y be (3) in ((let x be (y) in ((x + y)) + x)))" 11] ["let y be (let z be (4) in (let y be (99) in (z))) in (let z be (5) in ((let z be (10) in (y) + (y + z))))" 13] ;; Check that we don't substitute Expr0: ["let x be (let x be (5) in (x)) in ((x + 4))" 9] ["let x be (let y be (5) in (y)) in ((x + 4))" 9] ["let x be (let x be (5) in ((x + 1))) in ((x + -4))" 2] ["let x be (let y be (5) in ((y + 1))) in ((x + -4))" 2] ["let x be (let x be (5) in (x)) in (x)" 5] ["let x be (let x be (5) in ((x + 1))) in (x)" 6] ["let x be (let y be (5) in ((y + 1))) in (x)" 6] ;; These cases are *not* necessarily comprehensive. ;; To really understand what your code needs to do, ;; you'll have to work out some of these by hand, ;; and/or make your own test cases (make them complicated, ;; but only complicated enough to do something interesting -- ;; shadow a variable in one place, or shadow something from 2 levels above, or ... })