main_testing2/danube_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 15 Jan 2021 02:40:57 +0000
changeset 384 6e1237691307
parent 379 5616b45d656f
child 389 4113d4d8cf62
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
# to make the script fail safely
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
set -euo pipefail
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
out=${1:-output}
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
echo "" > $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
echo "Below is the feedback for your submission danube.scala" >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
echo "" >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
# compilation tests
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
function scala_compile {
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    18
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
}
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
# functional tests
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
function scala_assert {
384
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
    24
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "") # 2> /dev/null 1> /dev/null)
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
}
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
# purity test
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
function scala_vars {
376
6cc36d0ef79e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 352
diff changeset
    30
   (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null)
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
}
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    34
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    35
### compilation test
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    36
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    37
echo "danube.scala runs?" >> $out
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    38
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    39
if (scala_compile danube.scala)
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    40
then
352
97bcf8efe4e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 347
diff changeset
    41
    echo "  --> passed" >> $out
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    42
    tsts=$(( 0 ))
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    43
else
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    44
    echo "  --> SCALA DID NOT RUN danube.scala" >> $out
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    45
    tsts=$(( 1 )) 
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    46
fi
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    47
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
# var, .par return, ListBuffer test
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
#
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    51
if [ $tsts -eq 0 ]
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
then
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    53
    echo "danube.scala does not contain vars, returns etc?" >> $out
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    54
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    55
    if (scala_vars danube.scala)
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    56
    then
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    57
	echo "  --> FAIL (make triple-sure your program conforms to the required format)" >> $out
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    58
	tsts=$(( 1 ))
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    59
    else
352
97bcf8efe4e0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 347
diff changeset
    60
	echo "  --> passed" >> $out
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    61
	tsts=$(( 0 )) 
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 284
diff changeset
    62
    fi
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
fi
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
### danube get_cvs_url tests
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
if [ $tsts -eq 0 ]
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
then
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  echo "danube.scala tests:" >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
  echo "  val movies_url = \"\"\"https://nms.kcl.ac.uk/christian.urban/movies.csv\"\"\"" >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  echo "  get_csv_url(movies_url).length == 9742" >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  if (scala_assert "danube.scala" "danube_test1.scala")
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  then
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
    76
    echo -e "  --> success" >> $out
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
  else
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
    78
    echo -e "  --> ONE OF THE TESTS FAILED\n" >> $out
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  fi
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
fi
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
### danube processing tests
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
if [ $tsts -eq 0 ]
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
then
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
  echo "  val good_ratings = process_ratings(ratings)" >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
  echo "  val movie_names = process_movies(movies)" >> $out  
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
  echo "  " >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
  echo "  good_ratings.length == 48580 " >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
  echo "  movie_names.length == 9742 " >> $out
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
  if (scala_assert "danube.scala" "danube_test2.scala") 
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
  then
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
    94
    echo -e "  --> success" >> $out
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
  else
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
    96
    echo -e "  --> ONE OF THE TESTS FAILED\n" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
    97
  fi
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
    98
fi
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
    99
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   100
### danube groupById test
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   101
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   102
if [ $tsts -eq 0 ]
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   103
then
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   104
  echo -e  "  val ls1 = List((\"1\", \"a\"), (\"2\", \"a\"), (\"1\", \"c\"), (\"2\", \"a\"), (\"1\", \"c\"))" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   105
  echo -e  "  val ls2 = List((\"1\", \"a\"), (\"1\", \"b\"), (\"2\", \"x\"), (\"3\", \"a\"), (\"2\", \"y\"), (\"3\", \"c\"))" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   106
  echo -e  "  groupById(ls1, Map()) == Map(1 -> List(c, c, a), 2 -> List(a, a))" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   107
  echo -e  "  groupById(ls2, Map()) == Map(1 -> List(b, a), 2 -> List(x, y), 3 -> List(c, a))" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   108
  echo -e  "      where the order in the lists is unimportant" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   109
  echo -e  "  val ls3 = (1 to 1000).map(_.toString).toList" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   110
  echo -e  "  val ls4 = ls3 zip ls3.tail" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   111
  echo -e  "  val ls5 = ls4 ::: ls4.reverse" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   112
  echo -e  "  groupById(ls5, Map()) == Map(1 -> List(2,2), 2 -> List(3,3), ....)" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   113
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   114
  if (scala_assert "danube.scala" "danube_test3.scala")
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   115
  then
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   116
      echo -e  -e "  --> success" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   117
  else
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   118
      echo -e  -e "  --> ONE OF THE TESTS FAILED\n" >> $out
211
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
  fi
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
fi
092e0879a5ae updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   122
### danube favourites tests
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   123
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   124
if [ $tsts -eq 0 ]
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   125
then
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   126
  echo -e  "  val good_ratings = process_ratings(ratings)" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   127
  echo -e  "  val ratings_map = groupById(good_ratings, Map())" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   128
  echo -e  "  favourites(ratings_map, \"912\").length  == 80 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   129
  echo -e  "  favourites(ratings_map, \"858\").length  == 158 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   130
  echo -e  "  favourites(ratings_map, \"260\").length  == 201 " >> $out  
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   131
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   132
  if (scala_assert "danube.scala" "danube_test4.scala") 
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   133
  then
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   134
    echo -e  "  --> success" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   135
  else
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   136
    echo -e  "  --> ONE OF THE TESTS FAILED\n" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   137
  fi
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   138
fi
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   139
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   140
### danube suggestions tests
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   141
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   142
if [ $tsts -eq 0 ]
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   143
then
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   144
  echo -e  "  val good_ratings = process_ratings(ratings)" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   145
  echo -e  "  val ratings_map = groupById(good_ratings, Map())" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   146
  echo -e  "  suggestions(ratings_map, \"912\").length  == 4110 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   147
  echo -e  "  suggestions(ratings_map, \"858\").length  == 4883 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   148
  echo -e  "  suggestions(ratings_map, \"260\").length  == 4970 " >> $out  
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   149
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   150
  if (scala_assert "danube.scala" "danube_test5.scala") 
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   151
  then
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   152
    echo -e  "  --> success" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   153
  else
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   154
    echo -e  "  --> ONE OF THE TESTS FAILED\n" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   155
  fi
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   156
fi
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   157
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   158
### danube recommendation tests
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   159
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   160
if [ $tsts -eq 0 ]
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   161
then
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   162
  echo -e  "  recommendations(ratings_map, movies_map, \"1\").length  == 2 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   163
  echo -e  "  recommendations(ratings_map, movies_map, \"2\").length  == 2 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   164
  echo -e  "  recommendations(ratings_map, movies_map, \"3\").length  == 2 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   165
  echo -e  "  recommendations(ratings_map, movies_map, \"4\").length  == 0 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   166
  echo -e  "  recommendations(ratings_map, movies_map, \"5\").length  == 2 " >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   167
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   168
  if (scala_assert "danube.scala" "danube_test6.scala") 
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   169
  then
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   170
    echo -e  "  --> success" >> $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   171
  else
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   172
    echo -e  "  --> ONE OF THE TESTS FAILED\n" >>  $out
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   173
  fi
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   174
fi
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 283
diff changeset
   175
379
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   176
### danube most_recommended
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   177
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   178
if [ $tsts -eq 0 ]
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   179
then
384
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   180
    echo -e  "  val rmap =  Map(\"1\" -> List(\"b\", \"a\"), " >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   181
    echo -e  "                  \"2\" -> List(\"y\", \"x\"), " >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   182
    echo -e  "                  \"3\" -> List(\"c\", \"a\")) " >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   183
    echo -e  "  val nmap = Map(\"a\" -> \"A\", \"b\" -> \"B\", \"c\" -> \"C\",  " >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   184
    echo -e  "                 \"x\" -> \"X\", \"y\" -> \"Y\") " >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   185
    echo -e  "  most_recommended(rmap, nmap).toSet == " >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   186
    echo -e  "      Set((\"A\",2), (\"B\",1), (\"C\",1), (\"X\",1), (\"Y\",1)) " >> $out
379
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   187
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   188
  if (scala_assert "danube.scala" "danube_test7.scala") 
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   189
  then
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   190
    echo -e  "  --> success" >> $out
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   191
  else
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   192
    echo -e  "  --> ONE OF THE TESTS FAILED\n" >>  $out
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   193
  fi
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   194
fi
5616b45d656f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 376
diff changeset
   195