424
|
1 |
#!/bin/zsh
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
# to make the script fail safely
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
set -euo pipefail
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
out=${1:-output}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
echo -e "" > $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
echo -e `date` >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
echo -e "Below is the feedback and provisional marks for your submission" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
echo -e "for Part 5 (Scala). Please note all marks are provisional until" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
echo -e "ratified by the assessment board -- this is not an official" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
echo -e "results transcript." >> $out
|
463
|
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
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
# marks for CW10 part 1
|
424
|
23 |
marks=$(( 0.0 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
# compilation tests
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
27 |
function scala_compile {
|
463
|
28 |
(JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
# functional tests
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
function scala_assert {
|
463
|
34 |
(JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
function scala_assert_thirty {
|
463
|
38 |
(JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
40 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
41 |
# purity test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
42 |
function scala_vars {
|
424
|
43 |
(sed 's/immutable/ok/g' c$out > cb$out;
|
|
44 |
egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null)
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
45 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
46 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
47 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
48 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
49 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
50 |
echo -e "Below is the feedback for your submission of bf.scala" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
51 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
52 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
53 |
# compilation test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
54 |
echo -e "bf.scala runs?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
55 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
56 |
if (scala_compile bf.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
57 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
58 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
59 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
60 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
61 |
echo -e " --> SCALA DID NOT RUN bf.scala\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
62 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
63 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
64 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
65 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
66 |
# var, return, ListBuffer test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
67 |
#
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
68 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
69 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
70 |
echo -e "bf.scala does not contain VARS, RETURNS etc?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
71 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
72 |
if (scala_vars bf.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
73 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
74 |
echo -e " --> TEST FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
75 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
76 |
else
|
463
|
77 |
echo -e " --> success\n" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
78 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
79 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
80 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
81 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
82 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
83 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
84 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
85 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
86 |
### bf1 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
87 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
88 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
89 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
90 |
echo -e " load_bff(\"benchmark.bf\").length == 188" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
91 |
echo -e " load_bff(\"foobar.bf\") == \"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
92 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
93 |
if (scala_assert "bf.scala" "bf_test1.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
94 |
then
|
463
|
95 |
echo -e " --> success (+ 0.5 Marks)\n" | tee -a $out
|
424
|
96 |
marks=$(( marks + 0.5 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
97 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
98 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
99 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
100 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
101 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
102 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
103 |
### bf2 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
104 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
105 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
106 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
107 |
echo -e " sread(Map(), 2) == 0" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
108 |
echo -e " sread(Map(2 -> 1), 2) == 1" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
109 |
echo -e " write(Map(), 1, 2) == Map(1 -> 2)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
110 |
echo -e " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
111 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
112 |
if (scala_assert "bf.scala" "bf_test2.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
113 |
then
|
463
|
114 |
echo -e " --> success (+ 0.5 Marks)\n" | tee -a $out
|
424
|
115 |
marks=$(( marks + 0.5 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
116 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
117 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
118 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
119 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
120 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
121 |
### bf3 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
122 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
123 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
124 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
125 |
echo -e " jumpRight(\"[xxxxxx]xxx\", 1, 0) == 8" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
126 |
echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
127 |
echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
128 |
echo -e " jumpRight(\"[xx[xxx]xxx\", 1, 0) == 11" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
129 |
echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
130 |
echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
131 |
echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
132 |
echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" | tee -a $out
|
463
|
133 |
START=$(date +%s)
|
|
134 |
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
135 |
if (scala_assert "bf.scala" "bf_test3.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
136 |
then
|
463
|
137 |
END=$(date +%s)
|
|
138 |
DIFF=$(( $END - $START ))
|
|
139 |
echo -e " --> success (+ 2 Marks)\n" | tee -a $out
|
424
|
140 |
marks=$(( marks + 2.0 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
141 |
else
|
463
|
142 |
END=$(date +%s)
|
|
143 |
DIFF=$(( $END - $START ))
|
|
144 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
145 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
146 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
147 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
148 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
149 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
150 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
151 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
152 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
153 |
echo -e " run(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
154 |
echo -e " run(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
155 |
echo -e " run(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
156 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
157 |
echo -e " run(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
158 |
echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
159 |
echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
160 |
echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
161 |
echo -e " run(hello, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
162 |
echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
|
463
|
163 |
START=$(date +%s)
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
164 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
165 |
if (scala_assert "bf.scala" "bf_test4.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
166 |
then
|
463
|
167 |
END=$(date +%s)
|
|
168 |
DIFF=$(( $END - $START ))
|
|
169 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
|
170 |
echo -e " --> success (+ 1 Mark)\n" | tee -a $out
|
424
|
171 |
marks=$(( marks + 1.0 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
172 |
else
|
463
|
173 |
END=$(date +%s)
|
|
174 |
DIFF=$(( $END - $START ))
|
|
175 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
176 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
177 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
178 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
179 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
180 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
181 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
182 |
then
|
463
|
183 |
echo -e " Is run fast enough?" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
184 |
echo -e " val bench_small = \"\"\">+[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
185 |
echo -e " [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
186 |
echo -e " ++++++++[>++++++++++[>++++++++++[>++++++++++[>+" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
187 |
echo -e " +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
188 |
echo -e " run(bench_small, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
189 |
echo -e " Map(0 -> 10, 5 -> 0, 1 -> 0, 6 -> 0, 2 -> 0, 7 -> 0, 3 -> 0, 4 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
190 |
START=$(date +%s)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
191 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
192 |
if (scala_assert_thirty "bf.scala" "bf_test4b.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
193 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
194 |
END=$(date +%s)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
195 |
DIFF=$(( $END - $START ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
196 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
463
|
197 |
echo -e " --> success (+ 1 Mark)\n" | tee -a $out
|
424
|
198 |
marks=$(( marks + 1.0 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
199 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
200 |
END=$(date +%s)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
201 |
DIFF=$(( $END - $START ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
202 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
203 |
echo -e " --> TEST FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
204 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
205 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
206 |
|
463
|
207 |
if [ $tsts -eq 0 ]
|
|
208 |
then
|
|
209 |
echo -e " val str = \"\"\"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]\"\"\"" | tee -a $out
|
|
210 |
echo -e " " | tee -a $out
|
|
211 |
echo -e " run(generate(\"ABC\".toList)) == str" | tee -a $out
|
|
212 |
|
|
213 |
if (scala_assert_thirty "bf.scala" "bf_test4c.scala")
|
|
214 |
then
|
|
215 |
echo -e " --> success (+ 1 Mark)\n" | tee -a $out
|
|
216 |
marks=$(( marks + 1.0 ))
|
|
217 |
else
|
|
218 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
|
219 |
echo -e " --> TEST FAILED\n" | tee -a $out
|
|
220 |
fi
|
|
221 |
fi
|
|
222 |
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
223 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
224 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
225 |
echo -e "Below is the feedback for your submission of bfc.scala" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
226 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
227 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
228 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
229 |
# compilation test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
230 |
echo "bfc.scala runs?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
231 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
232 |
if (scala_compile bfc.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
233 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
234 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
235 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
236 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
237 |
echo -e " --> SCALA DID NOT RUN bfc.scala\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
238 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
239 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
240 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
241 |
# var, return, ListBuffer test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
242 |
#
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
243 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
244 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
245 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
246 |
echo "bfc.scala does not contain VARS, RETURNS etc?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
247 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
248 |
if (scala_vars bfc.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
249 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
250 |
echo -e " --> TEST FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
251 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
252 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
253 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
254 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
255 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
256 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
257 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
258 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
259 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
260 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
261 |
### bfc5 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
262 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
263 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
264 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
265 |
echo -e " val p1 = \"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
266 |
echo -e " jtable(p1) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
267 |
echo -e " val p2 = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
268 |
echo -e " jtable(p2) == Map(14 -> 34, 33 -> 15, 45 -> 44, 48 -> 9, 43 -> 46, 8 -> 49)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
269 |
echo -e " run2(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
270 |
echo -e " run2(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
271 |
echo -e " run2(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
272 |
echo -e " run2(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
273 |
echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
274 |
echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
275 |
echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
276 |
echo -e " run2(hello, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
277 |
echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
|
463
|
278 |
START=$(date +%s)
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
279 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
280 |
if (scala_assert "bfc.scala" "bf_test5.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
281 |
then
|
463
|
282 |
END=$(date +%s)
|
|
283 |
DIFF=$(( $END - $START ))
|
|
284 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
|
285 |
echo -e " --> success (+ 1 Mark)\n" | tee -a $out
|
424
|
286 |
marks=$(( marks + 1.0 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
287 |
else
|
463
|
288 |
END=$(date +%s)
|
|
289 |
DIFF=$(( $END - $START ))
|
|
290 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
291 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
292 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
293 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
294 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
295 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
296 |
### bfc6 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
297 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
298 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
299 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
300 |
echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out
|
463
|
301 |
echo -e " optimise(load_bff(\"sierpinski.bf\")).length == 110" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
302 |
echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
303 |
echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
304 |
echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
305 |
echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
306 |
echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
307 |
echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
308 |
echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
309 |
echo -e " run3(hello, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
310 |
echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
|
463
|
311 |
START=$(date +%s)
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
312 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
313 |
if (scala_assert "bfc.scala" "bf_test6.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
314 |
then
|
463
|
315 |
END=$(date +%s)
|
|
316 |
DIFF=$(( $END - $START ))
|
|
317 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
|
318 |
echo -e " --> success (+ 1 Mark)\n" | tee -a $out
|
424
|
319 |
marks=$(( marks + 1.0 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
320 |
else
|
463
|
321 |
END=$(date +%s)
|
|
322 |
DIFF=$(( $END - $START ))
|
|
323 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
324 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
325 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
326 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
327 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
328 |
### bfc7 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
329 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
330 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
331 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
332 |
echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out
|
463
|
333 |
echo -e " combine(optimise(load_bff(\"sierpinski.bf\"))).length == 122" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
334 |
echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
335 |
echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
336 |
echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
337 |
echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
338 |
echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
339 |
echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
340 |
echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
341 |
echo -e " run4(hello, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
342 |
echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
|
463
|
343 |
START=$(date +%s)
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
344 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
345 |
if (scala_assert "bfc.scala" "bf_test7.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
346 |
then
|
463
|
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
|
424
|
351 |
marks=$(( marks + 2.0 ))
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
352 |
else
|
463
|
353 |
END=$(date +%s)
|
|
354 |
DIFF=$(( $END - $START ))
|
|
355 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
356 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
357 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
358 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
359 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
360 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
361 |
## final marks
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
362 |
echo -e "Overall mark for Part 5 (Scala)" | tee -a $out
|
424
|
363 |
printf " %0.1f\n" $marks | tee -a $out
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
364 |
|