6 |
6 |
7 echo -e "" > $out |
7 echo -e "" > $out |
8 |
8 |
9 |
9 |
10 echo -e "Below is the feedback and provisional marks for your submission" >> $out |
10 echo -e "Below is the feedback and provisional marks for your submission" >> $out |
11 echo -e "the preliminary part for assignment 9. Please note all marks are provisional until" >> $out |
11 echo -e "of Preliminar 9. Please note all marks are provisional until" >> $out |
12 echo -e "ratified by the assessment board -- this is not an official" >> $out |
12 echo -e "ratified by the assessment board -- this is not an official" >> $out |
13 echo -e "results transcript." >> $out |
13 echo -e "results transcript." >> $out |
14 echo -e "" > $out |
14 echo -e "" >> $out |
15 |
15 |
16 # marks for CW9 part 2 |
16 # marks for CW9 preliminary |
17 marks=$(( 0 )) |
17 marks=$(( 0 )) |
18 |
18 |
19 |
19 |
20 # compilation tests |
20 # compilation tests |
21 |
21 |
24 } |
24 } |
25 |
25 |
26 # functional tests |
26 # functional tests |
27 |
27 |
28 function scala_assert { |
28 function scala_assert { |
29 (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2") #2> /dev/null 1> /dev/null) |
29 (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null) |
30 } |
30 } |
31 |
31 |
32 # purity test |
32 # purity test |
33 |
33 |
34 function scala_vars { |
34 function scala_vars { |
35 (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) |
35 # (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) |
|
36 (egrep '\bvar\b|\breturn\b|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) |
36 } |
37 } |
|
38 |
37 |
39 |
38 |
40 |
39 # var, return, ListBuffer test |
41 # var, return, ListBuffer test |
40 # |
42 # |
41 echo -e "postfix.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out |
43 echo -e "postfix.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out |
42 |
44 |
43 if (scala_vars postfix.scala) |
45 if (scala_vars postfix.scala) |
44 then |
46 then |
45 echo -e " --> FAIL (make triple-sure your program conforms to the required format)\n" | tee -a $out |
47 echo -e " --> FAIL\n" | tee -a $out |
46 tsts0=$(( 1 )) |
48 tsts0=$(( 1 )) |
47 else |
49 else |
48 echo -e " --> success" | tee -a $out |
50 echo -e " --> success" | tee -a $out |
49 tsts0=$(( 0 )) |
51 tsts0=$(( 0 )) |
50 fi |
52 fi |
113 # |
115 # |
114 echo -e "postfix2.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out |
116 echo -e "postfix2.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out |
115 |
117 |
116 if (scala_vars postfix2.scala) |
118 if (scala_vars postfix2.scala) |
117 then |
119 then |
118 echo -e " --> FAIL (make triple-sure your program conforms to the required format)\n" | tee -a $out |
120 echo -e " --> FAIL\n" | tee -a $out |
119 tsts0=$(( 1 )) |
121 tsts0=$(( 1 )) |
120 else |
122 else |
121 echo -e " --> success" | tee -a $out |
123 echo -e " --> success" | tee -a $out |
122 tsts0=$(( 0 )) |
124 tsts0=$(( 0 )) |
123 fi |
125 fi |
124 |
126 |
125 |
127 |
126 # compilation test |
128 # compilation test |
127 |
129 |
128 # compilation test |
|
129 if [ $tsts0 -eq 0 ] |
130 if [ $tsts0 -eq 0 ] |
130 then |
131 then |
131 echo -e "postfix2.scala runs?" | tee -a $out |
132 echo -e "postfix2.scala runs?" | tee -a $out |
132 |
133 |
133 if (scala_compile postfix2.scala) |
134 if (scala_compile postfix2.scala) |
149 echo -e " syard(split(\"( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )\")) == List(\"3\", \"4\", \"5\", \"+\", \"+\")" | tee -a $out |
150 echo -e " syard(split(\"( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )\")) == List(\"3\", \"4\", \"5\", \"+\", \"+\")" | tee -a $out |
150 echo -e " syard(split(\"5 + 7 / 2\")) == List(\"5\", \"7\", \"2\", \"/\", \"+\")" | tee -a $out |
151 echo -e " syard(split(\"5 + 7 / 2\")) == List(\"5\", \"7\", \"2\", \"/\", \"+\")" | tee -a $out |
151 echo -e " syard(split(\"5 * 7 / 2\")) == List(\"5\", \"7\", \"*\", \"2\", \"/\")" | tee -a $out |
152 echo -e " syard(split(\"5 * 7 / 2\")) == List(\"5\", \"7\", \"*\", \"2\", \"/\")" | tee -a $out |
152 echo -e " syard(split(\"3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3\")) == " | tee -a $out |
153 echo -e " syard(split(\"3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3\")) == " | tee -a $out |
153 echo -e " List(\"3\", \"4\", \"8\", \"*\", \"5\", \"1\", \"-\", \"2\", \"3\", \"^\", \"^\", \"/\", \"+\")" | tee -a $out |
154 echo -e " List(\"3\", \"4\", \"8\", \"*\", \"5\", \"1\", \"-\", \"2\", \"3\", \"^\", \"^\", \"/\", \"+\")" | tee -a $out |
154 echo -e " " | tee -a $out |
155 |
|
156 if (scala_assert "postfix2.scala" "postfix_test9.scala") |
|
157 then |
|
158 echo -e " --> success" | tee -a $out |
|
159 marks=$(( marks + 1 )) |
|
160 else |
|
161 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
|
162 fi |
|
163 fi |
|
164 |
|
165 if [ $tsts1 -eq 0 ] |
|
166 then |
155 echo -e " compute(syard(split(\"3 + 4 * ( 2 - 1 )\"))) == 7" | tee -a $out |
167 echo -e " compute(syard(split(\"3 + 4 * ( 2 - 1 )\"))) == 7" | tee -a $out |
156 echo -e " compute(syard(split(\"10 + 12 * 33\"))) == 406" | tee -a $out |
168 echo -e " compute(syard(split(\"10 + 12 * 33\"))) == 406" | tee -a $out |
157 echo -e " compute(syard(split(\"( 5 + 7 ) * 2\"))) == 24" | tee -a $out |
169 echo -e " compute(syard(split(\"( 5 + 7 ) * 2\"))) == 24" | tee -a $out |
158 echo -e " compute(syard(split(\"5 + 7 / 2\"))) == 8" | tee -a $out |
170 echo -e " compute(syard(split(\"5 + 7 / 2\"))) == 8" | tee -a $out |
159 echo -e " compute(syard(split(\"5 * 7 / 2\"))) == 17" | tee -a $out |
171 echo -e " compute(syard(split(\"5 * 7 / 2\"))) == 17" | tee -a $out |
161 echo -e " compute(syard(split(\"4 ^ 3 ^ 2\"))) == 262144" | tee -a $out |
173 echo -e " compute(syard(split(\"4 ^ 3 ^ 2\"))) == 262144" | tee -a $out |
162 echo -e " compute(syard(split(\"4 ^ ( 3 ^ 2 )\"))) == 262144" | tee -a $out |
174 echo -e " compute(syard(split(\"4 ^ ( 3 ^ 2 )\"))) == 262144" | tee -a $out |
163 echo -e " compute(syard(split(\"( 4 ^ 3 ) ^ 2\"))) == 4096" | tee -a $out |
175 echo -e " compute(syard(split(\"( 4 ^ 3 ) ^ 2\"))) == 4096" | tee -a $out |
164 echo -e " compute(syard(split(\"( 3 + 1 ) ^ 2 ^ 3\"))) == 65536" | tee -a $out |
176 echo -e " compute(syard(split(\"( 3 + 1 ) ^ 2 ^ 3\"))) == 65536" | tee -a $out |
165 |
177 |
166 if (scala_assert "postfix2.scala" "postfix_test9.scala") |
178 if (scala_assert "postfix2.scala" "postfix_test10.scala") |
167 then |
179 then |
168 echo -e " --> success" | tee -a $out |
180 echo -e " --> success" | tee -a $out |
169 marks=$(( marks + 2 )) |
181 marks=$(( marks + 1 )) |
170 else |
182 else |
171 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
183 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
172 fi |
184 fi |
173 fi |
185 fi |
174 |
186 |