---------------------------- |CS 314 - Project 2 - Scheme | |----------------------------| | Test Cases | | mcasella@cs.rutgers.edu | | | ---------------------------- Here are some test cases to run with your Scheme interpreter. Know that your output should EXACTLY match the output shown here (except in the case of the Environment variable, where the content of the variables must be the same, however the order of the variables may be different), as your program will be graded by a grading program. Also note that these test cases do not cover everything that I will test for, but it should give you a good idea of what I will be looking for. Again, I will not pass syntactically or semantically incorrect statements to the interpreter. Also note that if your fun-list-minus-list uses the provided member? function, in order for it to work with lists of lists, you most likely have to change eq? to equal? (which allows for the comparison of lists). If you see a test case that you think is incorrect, please let me know as soon as possible. I simply cut and paste input/output from my solution so there may be typographical errors. If there is any test case that you think of that is not covered or you are unsure of the expected behavior, feel free to contact me. **************************** * env-lookup * * * **************************** (env-lookup '((a (NUM 1))) 'a) (NUM 1) (env-lookup '((a (NUM1))(b (LIST '(1 2 3)))) 'b) (LIST '(1 2 3)) (env-lookup '((b (NUM 2))(c (NUM 3))(d (NUM 4))) 'c) (NUM 3) (env-lookup '((b (NUM 2))(c (NUM 3))(d (NUM 4))) 'd) (NUM 4) (env-lookup '((b (NUM 2))(c (NUM 3))(d (NUM 4))) 'e) (ERROR: undefined variable) **************************** * env-update * * * **************************** (env-update '((a (NUM 1))) '(a (NUM 10))) ((a (NUM 10))) (env-update '((a (NUM 1))) '(newvar (NUM 3))) ((newvar (NUM 3)) (a (NUM 1))) (env-update '((a (NUM 1))) '(newlist (LIST '(1 2 3)))) ((newlist (LIST '(1 2 3))) (a (NUM 1))) (env-update '((a (NUM 1))) '(a (LIST '(1 2 3)))) ((a (LIST '(1 2 3)))) (env-update '((a (NUM 1)) (list (LIST '(2 3 4)))) '(list (LIST '(10 20 30 40)))) ((list (LIST '(10 20 30 40))) (a (NUM 1))) (env-update '((a (NUM 1)) (b (NUM 2))(c (NUM 3))) '(c (NUM 10))) ((c (NUM 10)) (a (NUM 1)) (b (NUM 2))) **************************** * fun-num-plus-num * * * **************************** (fun-num-plus-num '(NUM 1) '(NUM 3)) (NUM 4) (fun-num-plus-num '(NUM -1) '(NUM 6)) (NUM 5) **************************** * fun-num-minus-num * * * **************************** (fun-num-minus-num '(NUM 2) '(NUM 5)) (NUM -3) (fun-num-minus-num '(NUM 10) '(NUM 9)) (NUM 1) **************************** * fun-list-plus-list * * * **************************** (fun-list-plus-list '(LIST (a b c d)) '(LIST (1 2 3 4))) (LIST ((a 1) (b 2) (c 3) (d 4))) (fun-list-plus-list '(LIST (1 a 2 b)) '(LIST (3 e 4 d))) (LIST ((1 3) (a e) (2 4) (b d))) (fun-list-plus-list '(LIST ((a 1) (b 2) (c 3) (d 4))) '(LIST (1 2 3 4))) (LIST (((a 1) 1) ((b 2) 2) ((c 3) 3) ((d 4) 4))) **************************** * fun-list-minus-list * * * **************************** (fun-list-minus-list '(LIST (1 2 3 4 5 6 7)) '(LIST (1 3 5 7))) (LIST (2 4 6)) (fun-list-minus-list '(LIST (2 4 6 8 10 12)) '(LIST (2 4 5))) (LIST (6 8 10 12)) (fun-list-minus-list '(LIST (10 9 8 7 6 5 4 3 2 1)) '(LIST (6 2 4 8 10))) (LIST (9 7 5 3 1)) (fun-list-minus-list '(LIST ((a 1)(b 2))) '(LIST ((a 1)))) (LIST ((b 2))) (fun-list-minus-list '(LIST ((a 1)(b 2)(c 3)(d 4))) '(LIST ((a 1)(d 4)))) (LIST ((b 2) (c 3))) **************************** * eval-expression * * * **************************** (eval-expression '((a (NUM 1)) (b (NUM 2))) '(a + b)) (NUM 3) (eval-expression '((a (NUM 1)) (b (NUM 2)) (c (NUM 3))) '(a + c)) (NUM 4) (eval-expression '((a (NUM 1)) (b (NUM 2)) (c (NUM 3))) '(a - c)) (NUM -2) (eval-expression '((numlist (LIST (1 2 3))) (letterlist (LIST (a b c)))) '(numlist + letterlist)) (LIST ((1 a) (2 b) (3 c))) (eval-expression '((list1 (LIST (1 2 3 4 5 6 7 8 9 10))) (evenlist (LIST (2 4 6 8 10)))) '(list1 - evenlist)) (LIST (1 3 5 7 9)) **************************** * eval-statement * * * **************************** (eval-statement '((a (NUM 5))) '(a <- 2 + 4)) ((a (NUM 6))) (eval-statement '((a (NUM 5))(b (NUM 10))) '(b <- 6 + 6)) ((b (NUM 12)) (a (NUM 5))) (eval-statement '((a (NUM 5))(b (NUM 10))) '(c <- 6 + 6)) ((c (NUM 12)) (a (NUM 5)) (b (NUM 10))) (eval-statement '((a (NUM 5))(b (NUM 10))) '(c <- a + b)) ((c (NUM 15)) (a (NUM 5)) (b (NUM 10))) (eval-statement '((a (NUM 5))(b (NUM 10))(c (NUM 15))) '(a <- c + b)) ((a (NUM 25)) (b (NUM 10)) (c (NUM 15))) (eval-statement '((a (NUM 5))(l (LIST (1 2 3 4)))) '(l <- (10 9 8 7))) ((l (LIST (10 9 8 7))) (a (NUM 5))) (eval-statement '((a (NUM 5))(l (LIST (1 2 3 4)))) '(a <- (10 9 8 7))) ((a (LIST (10 9 8 7))) (l (LIST (1 2 3 4)))) (eval-statement '((list1 (LIST (1 2 3 4)))(list2 (LIST (a b c d)))) '(newlist <- list1 + list2)) ((newlist (LIST ((1 a) (2 b) (3 c) (4 d)))) (list1 (LIST (1 2 3 4))) (list2 (LIST (a b c d)))) (eval-statement '((list1 (LIST (1 2 3 4 5 6)))(evenlist (LIST (2 4 6)))) '(oddlist <- list1 - evenlist)) ((oddlist (LIST (1 3 5))) (list1 (LIST (1 2 3 4 5 6))) (evenlist (LIST (2 4 6)))) (eval-statement '((list1 (LIST ((a 1)(b 2)(c 3))))(list2 (LIST (9 9 9)))) '(list3 <- list1 + list2)) ((list3 (LIST (((a 1) 9) ((b 2) 9) ((c 3) 9)))) (list1 (LIST ((a 1) (b 2) (c 3)))) (list2 (LIST (9 9 9)))) **************************** * eval-statements * * * **************************** (eval-statements '((a (NUM 1))(b (NUM 2))(c (NUM 3))) '((a <- c + c))) ((a (NUM 6)) (b (NUM 2)) (c (NUM 3))) (eval-statements '((a (NUM 1))(b (NUM 2))(c (NUM 3))) '((a <- 10 + a)(b <- 100 + b)(c <- c + 1000))) ((c (NUM 1003)) (b (NUM 102)) (a (NUM 11))) (eval-statements '((a (NUM 1))(b (NUM 2))(c (NUM 3))) '((a <- b + c)(b <- a + a)(c <- b + b))) ((c (NUM 20)) (b (NUM 10)) (a (NUM 5))) (eval-statements '((a (NUM 1))(b (NUM 2))(c (NUM 3))) '((a <- 100 - 40)(b <- a - b)(c <- b + b))) ((c (NUM 116)) (b (NUM 58)) (a (NUM 60))) (eval-statements '((a (NUM 1))(b (NUM 2))(c (NUM 3))) '((a <- d + e))) ((a (ERROR: undefined function)) (b (NUM 2)) (c (NUM 3))) (eval-statements '((list1 (LIST (1 2 3 4 5 6)))(evenlist (LIST (2 4 6)))) '((oddlist <- list1 - evenlist))) ((oddlist (LIST (1 3 5))) (list1 (LIST (1 2 3 4 5 6))) (evenlist (LIST (2 4 6)))) (eval-statements '((countdownlist (LIST (10 9 8 7 6 5 4 3 2 1)))(countuplist (LIST (1 2 3 4 5 6 7 8 9 10)))) '((newlist <- countdownlist + countuplist))) ((newlist (LIST ((10 1) (9 2) (8 3) (7 4) (6 5) (5 6) (4 7) (3 8) (2 9) (1 10)))) (countdownlist (LIST (10 9 8 7 6 5 4 3 2 1))) (countuplist (LIST (1 2 3 4 5 6 7 8 9 10)))) (eval-statements '((countdownlist (LIST (10 9 8 7 6 5 4)))(countuplist (LIST (1 2 3 4 5)))(letterlist (LIST (a b c d e)))) '((newlist <- countdownlist - countuplist)(combinedlist <- newlist + letterlist))) ((combinedlist (LIST ((10 a) (9 b) (8 c) (7 d) (6 e)))) (newlist (LIST (10 9 8 7 6))) (countdownlist (LIST (10 9 8 7 6 5 4))) (countuplist (LIST (1 2 3 4 5))) (letterlist (LIST (a b c d e))))