updated
authorChristian Urban <urbanc@in.tum.de>
Sat, 02 Feb 2019 13:38:47 +0000
changeset 263 5a16bcb4105e
parent 262 21c69dc3dbf7
child 264 ecd989eee8bd
updated
testing2/danube_test2.sh
testing2/danube_test3.scala
testing2/mark2
testing3/mark2
testing5/bf_test2.sh
testing5/bf_test6.scala
testing5/bf_test7.scala
testing5/mark2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing2/danube_test2.sh	Sat Feb 02 13:38:47 2019 +0000
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+# to make the script fail safely
+set -euo pipefail
+
+
+out=${1:-output}
+
+echo "" > $out
+
+echo -e "Below is the feedback for your submission for the advanced part of danube.scala" >> $out
+echo -e "" >> $out
+
+
+# compilation tests
+
+function scala_compile {
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2>> $out 1>> $out) 
+}
+
+# functional tests
+
+function scala_assert {
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "") #2> /dev/null 1> /dev/null)
+}
+
+# purity test
+
+function scala_vars {
+   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
+}
+
+
+# var, .par return, ListBuffer test
+#
+echo "danube.scala does not contain vars, returns etc?" >> $out
+
+if (scala_vars danube.scala)
+then
+  echo -e "  --> fail (make triple-sure your program conforms to the required format)" >> $out
+  tsts0=$(( 0 ))
+else
+  echo -e "  --> success" >> $out
+  tsts0=$(( 0 )) 
+fi
+
+### compilation test
+
+
+if  [ $tsts0 -eq 0 ]
+then 
+  echo "danube.scala runs?" >> $out
+
+  if (scala_compile danube.scala)
+  then
+    echo -e "  --> success" >> $out
+    tsts=$(( 0 ))
+  else
+    echo -e "  --> SCALA DID NOT RUN DANUBE.SCALA\n" >> $out  
+    tsts=$(( 1 )) 
+  fi
+else
+  tsts=$(( 1 ))     
+fi
+
+### danube groupById test
+
+if [ $tsts -eq 0 ]
+then
+  echo "  val ls = List((\"1\", \"a\"), (\"2\", \"a\"), (\"1\", \"c\"), (\"2\", \"a\"), (\"1\", \"c\"))" >> $out
+  echo "  groupById(ls, Map()) == Map(1 -> List(c, c, a), 2 -> List(a, a))" >> $out
+  echo "      where the order in the lists is unimportant" >> $out
+
+  if (scala_assert "danube.scala" "danube_test3.scala")
+  then
+      echo -e "  --> success" >> $out
+  else
+      echo -e "  --> \n ONE TEST FAILED\n" >> $out  
+  fi
+fi
+
+### danube processing tests
+
+#if [ $tsts -eq 0 ]
+#then
+#  echo "  val good_ratings = process_ratings(ratings)" >> $out
+#  echo "  val movie_names = process_movies(movies)" >> $out  
+#  echo "  " >> $out
+#  echo "  good_ratings.length == 48580 " >> $out
+#  echo "  movie_names.length == 9742 " >> $out
+#
+#  if (scala_assert "danube.scala" "danube_test2.scala") 
+#  then
+#    echo "  --> success" >> $out
+#  else
+#    echo "  --> one of the tests failed" >> $out
+#  fi
+#fi
+
+echo -e "\nFor other testcases please look at the template file." >> $out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing2/danube_test3.scala	Sat Feb 02 13:38:47 2019 +0000
@@ -0,0 +1,8 @@
+
+val ls_urban = List(("1", "a"), ("2", "a"), ("1", "c"), ("2", "a"), ("1", "c"))
+
+val m_urban = groupById(ls_urban, Map())
+
+assert(m_urban.getOrElse("1", Nil).count(_ == "c") == 2)
+assert(m_urban.getOrElse("1", Nil).count(_ == "a") == 1)
+assert(m_urban.getOrElse("2", Nil) == List("a", "a"))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing2/mark2	Sat Feb 02 13:38:47 2019 +0000
@@ -0,0 +1,15 @@
+#!/bin/bash
+###set -e
+
+trap "exit" INT
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+cp $DIR/* .
+
+./danube_test2.sh output1
+
+echo -e "Here is an automated test report for your work on the advanced part of assignment 7.  Please note that this is not the mark for your work; it is provided only in the hope that it is useful in developing your solution.  Passing these tests does not guarantee your code is free from bugs: after the deadline, your code will be marked against a different, more thorough set of test cases.\n\n" > $1
+
+cat output1 >> $1 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing3/mark2	Sat Feb 02 13:38:47 2019 +0000
@@ -0,0 +1,18 @@
+#!/bin/bash
+###set -e
+
+trap "exit" INT
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+cp $DIR/* .
+
+./knight2_test.sh output1
+
+
+echo -e "Here is an automated test report for your work so far on assignment 8.  Please note that this is not the mark for your work; it is provided only in the hope that it is useful in developing your solution.  Passing these tests does not guarantee your code is free from bugs: after the deadline, your code will be marked against a different, more thorough set of test cases.\n\n" > $1
+
+
+cat output1 >> $1
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing5/bf_test2.sh	Sat Feb 02 13:38:47 2019 +0000
@@ -0,0 +1,109 @@
+#!/bin/bash
+set -e
+
+out=${1:-output}
+
+echo -e "" > $out
+
+echo -e "Below is the feedback for your submission of CW 10, Part 2." >> $out
+echo -e "" >> $out
+
+
+# compilation tests
+
+function scala_compile {
+   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2>> $out 1>> $out)
+}
+
+# functional tests
+
+function scala_assert {
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "")  #2> /dev/null 1> /dev/null)   
+}
+
+# purity test
+
+function scala_vars {
+   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
+}
+
+
+# var, return, ListBuffer test
+#
+echo -e "bfc.scala does not contain vars, returns etc?" >> $out
+
+if (scala_vars bfc.scala)
+then
+  echo -e "   --> fail (make triple-sure your program conforms to the required format)" >> $out  
+  tsts0=$(( 0 ))
+else
+  echo -e "  --> success" >> $out
+  tsts0=$(( 0 )) 
+fi
+
+
+# compilation test
+if  [ $tsts0 -eq 0 ]
+then    
+  echo -e "bfc.scala runs?" >> $out
+
+  if (scala_compile bfc.scala)
+  then
+    echo -e "  --> success" >> $out
+    tsts1=$(( 0 ))
+  else
+    echo -e "  -->   --> SCALA DID NOT RUN BFC.SCALA\nx" >> $out
+    tsts1=$(( 1 )) 
+  fi
+else
+  tsts1=$(( 1 ))     
+fi
+
+
+### bfc tests
+
+if [ $tsts1 -eq 0 ]
+then
+  echo -e " jtable(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\"\"\") ==" >> $out
+  echo -e "     Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6)" >> $out  
+  
+  if (scala_assert "bfc.scala" "bf_test5.scala")
+  then
+    echo -e "  --> success" >> $out
+  else
+    echo -e "  --> \n ONE TEST FAILED\n" >> $out
+  fi
+fi
+
+
+
+if [ $tsts1 -eq 0 ]
+then
+  echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" >> $out
+  echo -e " optimise(load_bff(\"mandelbrot.bf\")).length == 11203" >> $out  
+  
+  if (scala_assert "bfc.scala" "bf_test6.scala")
+  then
+    echo -e "  --> success" >> $out
+  else
+    echo -e "  --> \n ONE TEST FAILED\n" >> $out
+  fi
+fi
+
+
+
+if [ $tsts1 -eq 0 ]
+then
+    echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" >> $out
+    echo -e " combine(optimise(load_bff(\"mandelbrot.bf\"))).length == 6509" >> $out
+  
+  if (scala_assert "bfc.scala" "bf_test7.scala")
+  then
+    echo -e "  --> success" >> $out
+  else
+    echo -e "  --> \n ONE TEST FAILED\n" >> $out   
+  fi
+fi
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing5/bf_test6.scala	Sat Feb 02 13:38:47 2019 +0000
@@ -0,0 +1,3 @@
+
+assert(optimise(load_bff("benchmark.bf")).length == 181)
+assert(optimise(load_bff("mandelbrot.bf")).length == 11203)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing5/bf_test7.scala	Sat Feb 02 13:38:47 2019 +0000
@@ -0,0 +1,3 @@
+
+assert(combine(optimise(load_bff("benchmark.bf"))).length == 134)
+assert(combine(optimise(load_bff("mandelbrot.bf"))).length == 6509)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing5/mark2	Sat Feb 02 13:38:47 2019 +0000
@@ -0,0 +1,16 @@
+#!/bin/bash
+###set -e
+
+trap "exit" INT
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+cp $DIR/* .
+
+./bf_test2.sh output1
+
+echo -e "Here is an automated test report for your work so far on the advanced part of assignment 10.  Please note that this is not the mark for your work; it is provided only in the hope that it is useful in developing your solution.  Passing these tests does not guarantee your code is free from bugs: after the deadline, your code will be marked against a different, more thorough set of test cases.\n\n" > $1
+
+
+cat output1 >> $1
+