Partial and tentative grading policy for the term project: 10 marks for each testcase. 8 marks for compilation and (correct) objectfile. 2 marks for comments etc. 6 points for compilation and incorrect objectfile, e.g., output 1 when 113 is expected. 4 marks if testcase just compiles. If none of the testcases compile, then 20 marks. Each of the extra test cases are worth 2 extra credit points. Test files (in order: repeat, for, case, var, string, index) ! This tests the repeat command (Ex.9.6(a)) let var i: Integer; var sum : Integer in begin i := 1; sum := 0; repeat sum := sum + i until (sum > 10); putint (sum) ! sum should be 11 end !Extra test for Ex. 9.6(a): !Test: Check a correct repeat command !Expected result: Print the numbers 1-20 let var i:Integer; var sum : Integer in begin sum := 0; repeat sum := sum + 1; putint(sum); puteol() until (sum >= 20) end !Extra test for Ex. 9.6(a): !Test: Invalid type of expression used in the repeat !Expected result: The error is caught at compilation time. let var i:Integer; var sum : Integer in begin sum := 0; repeat sum := sum + 1 until (sum) end !Extra test for Ex. 9.6(a): !Test: Provide an expression that is false from the beginning !Expected result: The repeat is going to execute at least once ! before checking the expression. Prints 2 !Note: The specifications of repeat...until are ambiguous. The example below ! assumes a Command between repeat and until, as in the Pascal language. ! If you assume a single-Command (as for the Triangle while command), then ! you need to add "begin" after "repeat" and "end" before "until" ! The ssme comment applies to other tests that have a Command between ! repeat and until let var i:Integer; var sum : Integer in begin sum := 1; repeat sum := sum + 1; putint(sum); puteol() until (sum > 0) end ! This tests the for command (Ex.9.6(b)) let var i : Integer; var sum : Integer in begin sum := 0; for i from 1 to 12 do sum := sum + 1; putint (sum) ! sum should be 12 end !Extra test for Ex. 9.6(b): !Test: Check that the use of an expression leading to an integer value is valid !as !expression in the for command !Expected result: Print the number from 5 to 20. !NOTE: the specifications of "for I from E1 to E2 do C" are ambiguous. Please try to ! specify in such a way that the example below is correct. So: C is a simple-Command, ! I is implicitly declared and has as its scope the "for" command. If you have already ! done otherwise, change the test example, and provide a note with your project ! submission explaining your decision. let var sum : Integer; var A : Integer in begin A := 10/2; sum := 0; for i from A to 20 do begin sum := sum + 1; putint(i) end end ! This tests the case command (Ex.9.7) let var i: Integer; var sum : Integer in begin sum := 15; i := 2; case i of 1: putint(1); 2: putint(sum); else: putint(3) ! should print 15 end ! This tests the string type (Ex.9.12a) let var mystr: string 10; var mystr1: string 3; var mystr2: string 3 in begin mystr[1] := 'a'; mystr[2] := 'b'; put(mystr[2]); ! should print b mystr1 := "foo"; mystr2 := "bar"; if (mystr1 << mystr2) then putint(1) else putint(0); ! Should print 0 if (mystr1 = mystr2) then putint(1) else putint(0) ! Should print 0 end ! This tests recursive data types (Ex. 9.13) ! NOTE: modified at 19:38 on 2008-04-26 ! further modified (added begin after in); removed "))" on 2008-05-06 let rec type IntList ~ record head: Integer, tail : IntList end; func cons (n: Integer, ns: IntList) : IntList ~ {head ~ n , tail ~ ns}; proc putints (ns: IntList) ~ if ns \= nil then begin putint (ns.head); put(' '); putints (ns.tail) end else ; var primes: IntList in begin primes := cons(2, (cons (3, cons(5, cons(7, (cons (11, nil))))))); putints(primes) end ! This tests the run-time index check. (Ex. 9.15) let var name: array 4 of Char; var i: Integer in begin i := 5; name[i] := ' ' end !Extra test for Ex. 9.15: !Test: Try to access and out of bounds value of an array. !Expected result: Prints D let var myArray : array 4 of Char; var i : Integer in begin i := 3; myArray[0] := 'A'; myArray[1] := 'B'; myArray[2] := 'C'; myArray[3] := 'D'; put(myArray[i]) end !Extra test for Ex. 9.15: !Test: Try to access and out of bounds value of an array. !Expected result: Runtime error of range check. let var myArray : array 4 of Char; var i : Integer in begin i := 4; myArray[0] := 'A'; myArray[1] := 'B'; myArray[2] := 'C'; myArray[3] := 'D'; myArray[i] := 'E'; !put(myArray[i]) end