12 echo -e "" >> $out |
12 echo -e "" >> $out |
13 echo -e "Below is the feedback and provisional marks for your submission" >> $out |
13 echo -e "Below is the feedback and provisional marks for your submission" >> $out |
14 echo -e "for Part 5 (Scala). Please note all marks are provisional until" >> $out |
14 echo -e "for Part 5 (Scala). Please note all marks are provisional until" >> $out |
15 echo -e "ratified by the assessment board -- this is not an official" >> $out |
15 echo -e "ratified by the assessment board -- this is not an official" >> $out |
16 echo -e "results transcript." >> $out |
16 echo -e "results transcript." >> $out |
17 echo -e "" >> $out |
17 |
|
18 #echo -e "" >> $out |
|
19 #echo -e "XXX needs to have own version of load_bff in the testing code" >> $out |
|
20 #echo -e "" >> $out |
18 |
21 |
19 # marks for CW10 part 1 |
22 # marks for CW10 part 1 |
20 marks=$(( 0.0 )) |
23 marks=$(( 0.0 )) |
21 |
24 |
22 # compilation tests |
25 # compilation tests |
23 |
26 |
24 function scala_compile { |
27 function scala_compile { |
25 (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out) |
28 (JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out) |
26 } |
29 } |
27 |
30 |
28 # functional tests |
31 # functional tests |
29 |
32 |
30 function scala_assert { |
33 function scala_assert { |
31 (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) |
34 (JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) |
32 } |
35 } |
33 |
36 |
34 function scala_assert_thirty { |
37 function scala_assert_thirty { |
35 (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) |
38 (JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) |
36 } |
39 } |
37 |
40 |
38 # purity test |
41 # purity test |
39 function scala_vars { |
42 function scala_vars { |
40 (sed 's/immutable/ok/g' c$out > cb$out; |
43 (sed 's/immutable/ok/g' c$out > cb$out; |
125 echo -e " jumpRight(\"[xx[xxx]xxx\", 1, 0) == 11" | tee -a $out |
128 echo -e " jumpRight(\"[xx[xxx]xxx\", 1, 0) == 11" | tee -a $out |
126 echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" | tee -a $out |
129 echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" | tee -a $out |
127 echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" | tee -a $out |
130 echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" | tee -a $out |
128 echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" | tee -a $out |
131 echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" | tee -a $out |
129 echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" | tee -a $out |
132 echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" | tee -a $out |
130 |
133 START=$(date +%s) |
|
134 |
131 if (scala_assert "bf.scala" "bf_test3.scala") |
135 if (scala_assert "bf.scala" "bf_test3.scala") |
132 then |
136 then |
133 echo -e " --> success" | tee -a $out |
137 END=$(date +%s) |
|
138 DIFF=$(( $END - $START )) |
|
139 echo -e " --> success (+ 2 Marks)\n" | tee -a $out |
134 marks=$(( marks + 2.0 )) |
140 marks=$(( marks + 2.0 )) |
135 else |
141 else |
|
142 END=$(date +%s) |
|
143 DIFF=$(( $END - $START )) |
|
144 echo -e " This test ran for $DIFF seconds" | tee -a $out |
136 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
145 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
137 fi |
146 fi |
138 fi |
147 fi |
139 |
148 |
140 |
149 |
149 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
158 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
150 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
159 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
151 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
160 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
152 echo -e " run(hello, Map()) == " | tee -a $out |
161 echo -e " run(hello, Map()) == " | tee -a $out |
153 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
162 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
|
163 START=$(date +%s) |
154 |
164 |
155 if (scala_assert "bf.scala" "bf_test4.scala") |
165 if (scala_assert "bf.scala" "bf_test4.scala") |
156 then |
166 then |
157 echo -e " --> success (mark 1%)" | tee -a $out |
167 END=$(date +%s) |
158 marks=$(( marks + 1.0 )) |
168 DIFF=$(( $END - $START )) |
159 else |
169 echo -e " This test ran for $DIFF seconds" | tee -a $out |
160 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
170 echo -e " --> success (+ 1 Mark)\n" | tee -a $out |
161 fi |
171 marks=$(( marks + 1.0 )) |
162 fi |
172 else |
163 |
173 END=$(date +%s) |
164 |
174 DIFF=$(( $END - $START )) |
165 if [ $tsts -eq 0 ] |
175 echo -e " This test ran for $DIFF seconds" | tee -a $out |
166 then |
176 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
|
177 fi |
|
178 fi |
|
179 |
|
180 |
|
181 if [ $tsts -eq 0 ] |
|
182 then |
|
183 echo -e " Is run fast enough?" | tee -a $out |
167 echo -e " val bench_small = \"\"\">+[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++" | tee -a $out |
184 echo -e " val bench_small = \"\"\">+[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++" | tee -a $out |
168 echo -e " [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++" | tee -a $out |
185 echo -e " [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++" | tee -a $out |
169 echo -e " ++++++++[>++++++++++[>++++++++++[>++++++++++[>+" | tee -a $out |
186 echo -e " ++++++++[>++++++++++[>++++++++++[>++++++++++[>+" | tee -a $out |
170 echo -e " +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.\"\"\"" | tee -a $out |
187 echo -e " +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.\"\"\"" | tee -a $out |
171 echo -e " run(bench_small, Map()) == " | tee -a $out |
188 echo -e " run(bench_small, Map()) == " | tee -a $out |
240 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
273 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
241 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
274 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
242 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
275 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
243 echo -e " run2(hello, Map()) == " | tee -a $out |
276 echo -e " run2(hello, Map()) == " | tee -a $out |
244 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
277 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
|
278 START=$(date +%s) |
245 |
279 |
246 if (scala_assert "bfc.scala" "bf_test5.scala") |
280 if (scala_assert "bfc.scala" "bf_test5.scala") |
247 then |
281 then |
248 echo -e " --> success" | tee -a $out |
282 END=$(date +%s) |
249 marks=$(( marks + 1.0 )) |
283 DIFF=$(( $END - $START )) |
250 else |
284 echo -e " This test ran for $DIFF seconds" | tee -a $out |
|
285 echo -e " --> success (+ 1 Mark)\n" | tee -a $out |
|
286 marks=$(( marks + 1.0 )) |
|
287 else |
|
288 END=$(date +%s) |
|
289 DIFF=$(( $END - $START )) |
|
290 echo -e " This test ran for $DIFF seconds" | tee -a $out |
251 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
291 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
252 fi |
292 fi |
253 fi |
293 fi |
254 |
294 |
255 |
295 |
256 ### bfc6 test |
296 ### bfc6 test |
257 |
297 |
258 if [ $tsts -eq 0 ] |
298 if [ $tsts -eq 0 ] |
259 then |
299 then |
260 echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out |
300 echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out |
261 echo -e " optimise(load_bff(\"mandelbrot.bf\")).length == 11205" | tee -a $out |
301 echo -e " optimise(load_bff(\"sierpinski.bf\")).length == 110" | tee -a $out |
262 echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out |
302 echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out |
263 echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out |
303 echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out |
264 echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out |
304 echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out |
265 echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out |
305 echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out |
266 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
306 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
267 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
307 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
268 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
308 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
269 echo -e " run3(hello, Map()) == " | tee -a $out |
309 echo -e " run3(hello, Map()) == " | tee -a $out |
270 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
310 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
|
311 START=$(date +%s) |
271 |
312 |
272 if (scala_assert "bfc.scala" "bf_test6.scala") |
313 if (scala_assert "bfc.scala" "bf_test6.scala") |
273 then |
314 then |
274 echo -e " --> success" | tee -a $out |
315 END=$(date +%s) |
275 marks=$(( marks + 1.0 )) |
316 DIFF=$(( $END - $START )) |
276 else |
317 echo -e " This test ran for $DIFF seconds" | tee -a $out |
|
318 echo -e " --> success (+ 1 Mark)\n" | tee -a $out |
|
319 marks=$(( marks + 1.0 )) |
|
320 else |
|
321 END=$(date +%s) |
|
322 DIFF=$(( $END - $START )) |
|
323 echo -e " This test ran for $DIFF seconds" | tee -a $out |
277 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
324 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
278 fi |
325 fi |
279 fi |
326 fi |
280 |
327 |
281 ### bfc7 test |
328 ### bfc7 test |
282 |
329 |
283 if [ $tsts -eq 0 ] |
330 if [ $tsts -eq 0 ] |
284 then |
331 then |
285 echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out |
332 echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out |
286 echo -e " combine(optimise(load_bff(\"mandelbrot.bf\"))).length == 6511" | tee -a $out |
333 echo -e " combine(optimise(load_bff(\"sierpinski.bf\"))).length == 122" | tee -a $out |
287 echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out |
334 echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out |
288 echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out |
335 echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out |
289 echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out |
336 echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out |
290 echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out |
337 echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out |
291 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
338 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
292 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
339 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
293 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
340 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
294 echo -e " run4(hello, Map()) == " | tee -a $out |
341 echo -e " run4(hello, Map()) == " | tee -a $out |
295 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
342 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
|
343 START=$(date +%s) |
296 |
344 |
297 if (scala_assert "bfc.scala" "bf_test7.scala") |
345 if (scala_assert "bfc.scala" "bf_test7.scala") |
298 then |
346 then |
299 echo -e " --> success (+ 2%)" | tee -a $out |
347 END=$(date +%s) |
|
348 DIFF=$(( $END - $START )) |
|
349 echo -e " This test ran for $DIFF seconds" | tee -a $out END=$(date +%s) |
|
350 echo -e " --> success (+ 2 Marks)" | tee -a $out |
300 marks=$(( marks + 2.0 )) |
351 marks=$(( marks + 2.0 )) |
301 else |
352 else |
|
353 END=$(date +%s) |
|
354 DIFF=$(( $END - $START )) |
|
355 echo -e " This test ran for $DIFF seconds" | tee -a $out |
302 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
356 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
303 fi |
357 fi |
304 fi |
358 fi |
305 |
359 |
306 |
360 |