diff -r ef5f62bf5987 -r 9a04eb6a2291 testing2/danube_test.sh --- a/testing2/danube_test.sh Tue Oct 29 23:56:13 2019 +0000 +++ b/testing2/danube_test.sh Wed Oct 30 11:28:44 2019 +0000 @@ -37,7 +37,7 @@ if (scala_vars danube.scala) then - echo " --> fail (make triple-sure your program conforms to the required format)" >> $out + echo " --> FAIL (make triple-sure your program conforms to the required format)" >> $out tsts0=$(( 0 )) else echo " --> success" >> $out @@ -56,7 +56,7 @@ echo " --> success" >> $out tsts=$(( 0 )) else - echo " --> scala did not run danube.scala" >> $out + echo " --> SCALA DID NOT RUN danube.scala" >> $out tsts=$(( 1 )) fi else @@ -73,9 +73,9 @@ if (scala_assert "danube.scala" "danube_test1.scala") then - echo " --> success" >> $out + echo -e " --> success" >> $out else - echo " --> one of the tests failed" >> $out + echo -e " --> ONE OF THE TESTS FAILED\n" >> $out fi fi @@ -91,9 +91,85 @@ if (scala_assert "danube.scala" "danube_test2.scala") then - echo " --> success" >> $out + echo -e " --> success" >> $out else - echo " --> one of the tests failed" >> $out + echo -e " --> ONE OF THE TESTS FAILED\n" >> $out + fi +fi + +### danube groupById test + +if [ $tsts -eq 0 ] +then + echo -e " val ls1 = List((\"1\", \"a\"), (\"2\", \"a\"), (\"1\", \"c\"), (\"2\", \"a\"), (\"1\", \"c\"))" >> $out + echo -e " val ls2 = List((\"1\", \"a\"), (\"1\", \"b\"), (\"2\", \"x\"), (\"3\", \"a\"), (\"2\", \"y\"), (\"3\", \"c\"))" >> $out + echo -e " groupById(ls1, Map()) == Map(1 -> List(c, c, a), 2 -> List(a, a))" >> $out + echo -e " groupById(ls2, Map()) == Map(1 -> List(b, a), 2 -> List(x, y), 3 -> List(c, a))" >> $out + echo -e " where the order in the lists is unimportant" >> $out + echo -e " val ls3 = (1 to 1000).map(_.toString).toList" >> $out + echo -e " val ls4 = ls3 zip ls3.tail" >> $out + echo -e " val ls5 = ls4 ::: ls4.reverse" >> $out + echo -e " groupById(ls5, Map()) == Map(1 -> List(2,2), 2 -> List(3,3), ....)" >> $out + + if (scala_assert "danube.scala" "danube_test3.scala") + then + echo -e -e " --> success" >> $out + else + echo -e -e " --> ONE OF THE TESTS FAILED\n" >> $out fi fi +### danube favourites tests + +if [ $tsts -eq 0 ] +then + echo -e " val good_ratings = process_ratings(ratings)" >> $out + echo -e " val ratings_map = groupById(good_ratings, Map())" >> $out + echo -e " favourites(ratings_map, \"912\").length == 80 " >> $out + echo -e " favourites(ratings_map, \"858\").length == 158 " >> $out + echo -e " favourites(ratings_map, \"260\").length == 201 " >> $out + + if (scala_assert "danube.scala" "danube_test4.scala") + then + echo -e " --> success" >> $out + else + echo -e " --> ONE OF THE TESTS FAILED\n" >> $out + fi +fi + +### danube suggestions tests + +if [ $tsts -eq 0 ] +then + echo -e " val good_ratings = process_ratings(ratings)" >> $out + echo -e " val ratings_map = groupById(good_ratings, Map())" >> $out + echo -e " suggestions(ratings_map, \"912\").length == 4110 " >> $out + echo -e " suggestions(ratings_map, \"858\").length == 4883 " >> $out + echo -e " suggestions(ratings_map, \"260\").length == 4970 " >> $out + + if (scala_assert "danube.scala" "danube_test5.scala") + then + echo -e " --> success" >> $out + else + echo -e " --> ONE OF THE TESTS FAILED\n" >> $out + fi +fi + +### danube recommendation tests + +if [ $tsts -eq 0 ] +then + echo -e " recommendations(ratings_map, movies_map, \"1\").length == 2 " >> $out + echo -e " recommendations(ratings_map, movies_map, \"2\").length == 2 " >> $out + echo -e " recommendations(ratings_map, movies_map, \"3\").length == 2 " >> $out + echo -e " recommendations(ratings_map, movies_map, \"4\").length == 0 " >> $out + echo -e " recommendations(ratings_map, movies_map, \"5\").length == 2 " >> $out + + if (scala_assert "danube.scala" "danube_test6.scala") + then + echo -e " --> success" >> $out + else + echo -e " --> ONE OF THE TESTS FAILED\n" >> $out + fi +fi +