35 function scala_assert_thirty { |
35 function scala_assert_thirty { |
36 (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) |
36 (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) |
37 } |
37 } |
38 |
38 |
39 # purity test |
39 # purity test |
40 |
|
41 function scala_vars { |
40 function scala_vars { |
42 (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null) |
41 (sed 's/immutable/ok/g' c$out > cb$out; |
|
42 egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null) |
43 } |
43 } |
44 |
44 |
45 |
45 |
46 echo -e "" >> $out |
46 echo -e "" >> $out |
47 echo -e "Below is the feedback for your submission danube.scala" >> $out |
47 echo -e "Below is the feedback for your submission danube.scala" >> $out |
109 echo -e " val good_ratings = process_ratings(ratings)" | tee -a $out |
109 echo -e " val good_ratings = process_ratings(ratings)" | tee -a $out |
110 echo -e " val movie_names = process_movies(movies)" | tee -a $out |
110 echo -e " val movie_names = process_movies(movies)" | tee -a $out |
111 echo -e " " | tee -a $out |
111 echo -e " " | tee -a $out |
112 echo -e " good_ratings.length == 48580 " | tee -a $out |
112 echo -e " good_ratings.length == 48580 " | tee -a $out |
113 echo -e " movie_names.length == 9742 " | tee -a $out |
113 echo -e " movie_names.length == 9742 " | tee -a $out |
|
114 echo -e " " | tee -a $out |
|
115 echo -e " val r_elems = List((\"1\",\"1\"), (\"1\",\"3\"), (\"1\",\"6\"), (\"1\",\"47\")) " | tee -a $out |
|
116 echo -e " r_elems.forall(good_ratings.contains(_)) == true" | tee -a $out |
114 |
117 |
115 if (scala_assert "danube.scala" "danube_test2.scala") |
118 if (scala_assert "danube.scala" "danube_test2.scala") |
116 then |
119 then |
117 echo -e " --> success" | tee -a $out |
120 echo -e " --> success" | tee -a $out |
118 marks=$(( marks + 1.0 )) |
121 marks=$(( marks + 1.0 )) |
199 else |
202 else |
200 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
203 echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out |
201 fi |
204 fi |
202 fi |
205 fi |
203 |
206 |
204 ### danube most_recommended 1 |
|
205 gd=$(( 0 )) |
|
206 |
|
207 if [ $tsts -eq 0 ] |
|
208 then |
|
209 echo -e " val rmap = Map(\"1\" -> List(\"b\", \"a\"), " | tee -a $out |
|
210 echo -e " \"2\" -> List(\"y\", \"x\"), " | tee -a $out |
|
211 echo -e " \"3\" -> List(\"c\", \"a\")) " | tee -a $out |
|
212 echo -e " val nmap = Map(\"a\" -> \"A\", \"b\" -> \"B\", \"c\" -> \"C\", " | tee -a $out |
|
213 echo -e " \"x\" -> \"X\", \"y\" -> \"Y\") " | tee -a $out |
|
214 echo -e " most_recommended(rmap, nmap).toSet == " | tee -a $out |
|
215 echo -e " Set((\"A\",2), (\"B\",1), (\"C\",1), (\"X\",1), (\"Y\",1)) " | tee -a $out |
|
216 |
|
217 if (scala_assert "danube.scala" "danube_test7a.scala") |
|
218 then |
|
219 echo -e " --> success (0.5% Marks)" | tee -a $out |
|
220 marks=$(( marks + 0.5 )) |
|
221 else |
|
222 echo -e " --> TEST FAILED\n" | tee -a $out |
|
223 gd=$(( 1 )) |
|
224 fi |
|
225 fi |
|
226 |
|
227 ### danube most_recommended 2 |
|
228 |
|
229 sleep 10 |
|
230 |
|
231 if [ $gd -eq 0 ] |
|
232 then |
|
233 if [ $tsts -eq 0 ] |
|
234 then |
|
235 echo -e " most_recommended(ratings_map, movie_map) runs within allocated time? " | tee -a $out |
|
236 START=$(date +%s) |
|
237 |
|
238 if (scala_assert_thirty "danube.scala" "danube_test7b.scala") |
|
239 then |
|
240 END=$(date +%s) |
|
241 DIFF=$(( $END - $START )) |
|
242 echo " This test ran for $DIFF seconds." | tee -a $out |
|
243 echo -e " --> success (0.5% Marks)" | tee -a $out |
|
244 marks=$(( marks + 0.5 )) |
|
245 else |
|
246 END=$(date +%s) |
|
247 DIFF=$(( $END - $START )) |
|
248 echo " This test ran for $DIFF seconds." | tee -a $out |
|
249 echo -e " --> TEST FAILED\n" | tee -a $out |
|
250 fi |
|
251 fi |
|
252 fi |
|
253 |
|
254 sleep 10 |
|
255 |
207 |
256 |
208 |
257 ## final marks |
209 ## final marks |
258 echo -e "Overall mark for Main Part 2 (Scala)" | tee -a $out |
210 echo -e "Overall mark for Main Part 2 (Scala)" | tee -a $out |
259 printf " %0.1f\n" $marks | tee -a $out |
211 printf " %0.1f\n" $marks | tee -a $out |