145 if (scala_assert "bf.scala" "bf_test4.scala") |
145 if (scala_assert "bf.scala" "bf_test4.scala") |
146 then |
146 then |
147 echo -e " --> success" | tee -a $out |
147 echo -e " --> success" | tee -a $out |
148 marks=$(( marks + 2 )) |
148 marks=$(( marks + 2 )) |
149 else |
149 else |
150 echo -e " --> \n ONE TEST FAILED\n" | tee -a $out |
150 echo -e " --> TEST FAILED\n" | tee -a $out |
|
151 fi |
|
152 fi |
|
153 |
|
154 |
|
155 # var, return, ListBuffer test |
|
156 # |
|
157 echo "bfc.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out |
|
158 |
|
159 if (scala_vars bfc.scala) |
|
160 then |
|
161 echo -e " --> TEST FAILED\n" | tee -a $out |
|
162 tsts0=$(( 1 )) |
|
163 else |
|
164 echo -e " --> success" | tee -a $out |
|
165 tsts0=$(( 0 )) |
|
166 fi |
|
167 |
|
168 |
|
169 # compilation test |
|
170 if [ $tsts0 -eq 0 ] |
|
171 then |
|
172 echo "bfc.scala runs?" | tee -a $out |
|
173 |
|
174 if (scala_compile bfc.scala) |
|
175 then |
|
176 echo -e " --> success" | tee -a $out |
|
177 tsts1=$(( 0 )) |
|
178 else |
|
179 echo -e " --> SCALA DID NOT RUN bfc.scala\n" | tee -a $out |
|
180 tsts1=$(( 1 )) |
|
181 fi |
|
182 else |
|
183 tsts1=$(( 1 )) |
|
184 fi |
|
185 |
|
186 |
|
187 ### bfc5 test |
|
188 |
|
189 if [ $tsts1 -eq 0 ] |
|
190 then |
|
191 echo -e " val p1 = \"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\"\"\"" | tee -a $out |
|
192 echo -e " jtable(p1) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6)" | tee -a $out |
|
193 echo -e " val p2 = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
|
194 echo -e " jtable(p2) == Map(14 -> 34, 33 -> 15, 45 -> 44, 48 -> 9, 43 -> 46, 8 -> 49)" | tee -a $out |
|
195 echo -e " run2(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out |
|
196 echo -e " run2(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out |
|
197 echo -e " run2(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out |
|
198 echo -e " run2(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out |
|
199 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
|
200 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
|
201 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
|
202 echo -e " run2(hello, Map()) == " | tee -a $out |
|
203 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
|
204 |
|
205 if (scala_assert "bfc.scala" "bf_test5.scala") |
|
206 then |
|
207 echo -e " --> success" | tee -a $out |
|
208 marks=$(( marks + 1 )) |
|
209 else |
|
210 echo -e " --> TEST FAILED\n" | tee -a $out |
|
211 fi |
|
212 fi |
|
213 |
|
214 |
|
215 ### bfc6 test |
|
216 |
|
217 if [ $tsts1 -eq 0 ] |
|
218 then |
|
219 echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out |
|
220 echo -e " optimise(load_bff(\"mandelbrot.bf\")).length == 11203" | tee -a $out |
|
221 echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out |
|
222 echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out |
|
223 echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out |
|
224 echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out |
|
225 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
|
226 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
|
227 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
|
228 echo -e " run3(hello, Map()) == " | tee -a $out |
|
229 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
|
230 |
|
231 if (scala_assert "bfc.scala" "bf_test6.scala") |
|
232 then |
|
233 echo -e " --> success" | tee -a $out |
|
234 marks=$(( marks + 1 )) |
|
235 else |
|
236 echo -e " --> TEST FAILED\n" | tee -a $out |
|
237 fi |
|
238 fi |
|
239 |
|
240 ### bfc7 test |
|
241 |
|
242 if [ $tsts1 -eq 0 ] |
|
243 then |
|
244 echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out |
|
245 echo -e " combine(optimise(load_bff(\"mandelbrot.bf\"))).length == 6509" | tee -a $out |
|
246 echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out |
|
247 echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out |
|
248 echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out |
|
249 echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out |
|
250 echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out |
|
251 echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out |
|
252 echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out |
|
253 echo -e " run4(hello, Map()) == " | tee -a $out |
|
254 echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out |
|
255 |
|
256 if (scala_assert "bfc.scala" "bf_test7.scala") |
|
257 then |
|
258 echo -e " --> success" | tee -a $out |
|
259 marks=$(( marks + 2 )) |
|
260 else |
|
261 echo -e " --> TEST FAILED\n" | tee -a $out |
151 fi |
262 fi |
152 fi |
263 fi |
153 |
264 |
154 |
265 |
155 ## final marks |
266 ## final marks |
156 echo -e "Overall mark for CW 10, Part 1" | tee -a $out |
267 echo -e "Overall mark for CW 10" | tee -a $out |
157 echo -e "$marks" | tee -a $out |
268 echo -e "$marks" | tee -a $out |
158 |
269 |