updated
authorChristian Urban <urbanc@in.tum.de>
Wed, 30 Oct 2019 12:37:18 +0000
changeset 286 5c57c407e27b
parent 285 bd9d142d2cd8
child 287 c493eaba6018
updated
marking5/bf.scala
marking5/bf_test.sh
marking5/bf_test1.scala
marking5/bf_test2.scala
marking5/bf_test3.scala
marking5/bf_test4.scala
marking5/bf_test5.scala
marking5/bf_test6.scala
marking5/bf_test7.scala
marking5/bfc.scala
marking5/bfc_test.sh
marking5/compare
marking5/tails
testing5/bf_test.sh
testing5/bf_test1.scala
testing5/bf_test2.scala
testing5/bf_test2.sh
testing5/bf_test3.scala
testing5/bf_test4.scala
testing5/bf_test6.scala
testing5/bf_test7.scala
testing5/bfc.scala
testing5/bfc_test.sh
--- a/marking5/bf.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,7 +1,7 @@
 // Part 1 about an Interpreter for the Brainf*** language
 //========================================================
 
-//object CW10a {  // only for generating the Jar file
+object CW10a { 
 
 
 type Mem = Map[Int, Int]
@@ -222,4 +222,4 @@
 time_needed(1, run(b1))
 */
 
-//}
+}
--- a/marking5/bf_test.sh	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf_test.sh	Wed Oct 30 12:37:18 2019 +0000
@@ -6,14 +6,14 @@
 
 out=${1:-output}
 
-echo "" > $out
+echo -e "" > $out
 
 
-echo "Below is the feedback and provisional marks for your submission" >> $out
-echo "for assignment 10 Part 1.  Please note all marks are provisional until" >> $out
-echo "ratified by the assessment board -- this is not an official" >> $out
-echo "results transcript." >> $out
-echo "" >> $out
+echo -e "Below is the feedback and provisional marks for your submission" >> $out
+echo -e "for assignment 10 Part 1.  Please note all marks are provisional until" >> $out
+echo -e "ratified by the assessment board -- this is not an official" >> $out
+echo -e "results transcript." >> $out
+echo -e "" >> $out
 
 # marks for CW10 part 1
 marks=$(( 0 ))
@@ -21,13 +21,13 @@
 # compilation tests
 
 function scala_compile {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2> /dev/null 1> /dev/null)
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null)
 }
 
 # functional tests
 
 function scala_assert {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 }
 
 
@@ -41,14 +41,14 @@
 
 # var, return, ListBuffer test
 #
-echo "bf.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
+echo -e "bf.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
 
 if (scala_vars bf.scala)
 then
-  echo "  --> test failed" | tee -a $out
+  echo -e "  --> FAIL (make triple-sure your program conforms to the required format)" | tee -a $out
   tsts0=$(( 1 ))
 else
-  echo "  --> success" | tee -a $out
+  echo -e "  --> success" | tee -a $out
   tsts0=$(( 0 )) 
 fi
 
@@ -56,14 +56,14 @@
 # compilation test
 if  [ $tsts0 -eq 0 ]
 then    
-  echo "bf.scala runs?" | tee -a $out
+  echo -e "bf.scala runs?" | tee -a $out
 
   if (scala_compile bf.scala)
   then
-    echo "  --> success" | tee -a $out
+    echo -e "  --> success" | tee -a $out
     tsts1=$(( 0 ))
   else
-    echo "  --> scala bf.scala did not run successfully" | tee -a $out
+    echo -e "  --> SCALA DID NOT RUN BF.SCALA\n" | tee -a $out
     tsts1=$(( 1 )) 
   fi
 else
@@ -75,15 +75,15 @@
 
 if [ $tsts1 -eq 0 ]
 then
-  echo " load_bff(\"benchmark.bf\").length == 188" | tee -a $out
-  echo " load_bff(\"foobar.bf\") == \"\"" | tee -a $out  
+  echo -e " load_bff(\"benchmark.bf\").length == 188" | tee -a $out
+  echo -e " load_bff(\"foobar.bf\") == \"\"" | tee -a $out  
    
   if (scala_assert "bf.scala" "bf_test1.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-    echo "  --> test failed" | tee -a $out
+      echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   fi
 fi
 
@@ -92,17 +92,17 @@
 
 if [ $tsts1 -eq 0 ]
 then
-  echo " sread(Map(), 2) == 0" | tee -a $out
-  echo " sread(Map(2 -> 1), 2) == 1" | tee -a $out  
-  echo " write(Map(), 1, 2) == Map(1 -> 2)" | tee -a $out
-  echo " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" | tee -a $out
+  echo -e " sread(Map(), 2) == 0" | tee -a $out
+  echo -e " sread(Map(2 -> 1), 2) == 1" | tee -a $out  
+  echo -e " write(Map(), 1, 2) == Map(1 -> 2)" | tee -a $out
+  echo -e " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" | tee -a $out
   
   if (scala_assert "bf.scala" "bf_test2.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-    echo "  --> test failed" | tee -a $out
+      echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   fi
 fi
 
@@ -110,21 +110,21 @@
 
 if [ $tsts1 -eq 0 ]
 then
-    echo " jumpRight(\"[xxxxxx]xxx\", 1, 0) == 8" | tee -a $out
-    echo " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
-    echo " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
-    echo " jumpRight(\"[xx[xxx]xxx\", 1, 0) == 11" | tee -a $out
-    echo " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" | tee -a $out
-    echo " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" | tee -a $out
-    echo " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" | tee -a $out
-    echo " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" | tee -a $out
+    echo -e " jumpRight(\"[xxxxxx]xxx\", 1, 0) == 8" | tee -a $out
+    echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
+    echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
+    echo -e " jumpRight(\"[xx[xxx]xxx\", 1, 0) == 11" | tee -a $out
+    echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" | tee -a $out
+    echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" | tee -a $out
+    echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" | tee -a $out
+    echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" | tee -a $out
   
   if (scala_assert "bf.scala" "bf_test3.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 2 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   fi
 fi
 
@@ -144,15 +144,15 @@
   
   if (scala_assert "bf.scala" "bf_test4.scala")
   then
-      echo "  --> success" | tee -a $out
+      echo -e "  --> success" | tee -a $out
       marks=$(( marks + 2 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   fi
 fi
 
 
 ## final marks
-echo "Overall mark for CW 10, Part 1" | tee -a $out
-echo "$marks" | tee -a $out
+echo -e "Overall mark for CW 10, Part 1" | tee -a $out
+echo -e "$marks" | tee -a $out
 
--- a/marking5/bf_test1.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf_test1.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10a._ 
 
 assert(load_bff("benchmark.bf").length == 188)
 assert(load_bff("foobar.bf") == "")
--- a/marking5/bf_test2.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf_test2.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10a._
 
 assert(sread(Map(), 2) == 0)
 assert(sread(Map(2 -> 1), 2) == 1)
--- a/marking5/bf_test3.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf_test3.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10a._
 
 assert(jumpRight("[xxxxxx]xxx", 1, 0) == 8)
 assert(jumpRight("[xx[x]x]xxx", 1, 0) == 8)
--- a/marking5/bf_test4.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf_test4.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10a._
 
 assert(run("[-]", Map(0 -> 100)) == Map(0 -> 0))
 assert(run("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
--- a/marking5/bf_test5.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf_test5.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10b._
 
 val hw_urban = """+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]"""
 assert(jtable(hw_urban) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6))
--- a/marking5/bf_test6.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf_test6.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10b._
 
 assert(optimise(load_bff("benchmark.bf")).length == 181)
 assert(optimise(load_bff("mandelbrot.bf")).length == 11203)
--- a/marking5/bf_test7.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bf_test7.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10b._
 
 assert(combine(optimise(load_bff("benchmark.bf"))).length == 134)
 assert(combine(optimise(load_bff("mandelbrot.bf"))).length == 6509)
--- a/marking5/bfc.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bfc.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,7 +1,7 @@
 // Part 2 about a "Compiler" for the Brainf*** language
 //======================================================
 
-//object CW10b {
+object CW10b {
 
 // !!! Copy any function you need from file bf.scala !!!
 //
@@ -309,4 +309,4 @@
 //time_needed(1, run4(load_bff("mandelbrot.bf")))
 
 
-//}
+}
--- a/marking5/bfc_test.sh	Wed Oct 30 11:51:02 2019 +0000
+++ b/marking5/bfc_test.sh	Wed Oct 30 12:37:18 2019 +0000
@@ -10,7 +10,7 @@
 
 
 echo "Below is the feedback and provisional marks for your submission" >> $out
-echo "for assignment 10 Advanced Part 2.  Please note all marks are provisional until" >> $out
+echo "for assignment 10 Part 2.  Please note all marks are provisional until" >> $out
 echo "ratified by the assessment board -- this is not an official" >> $out
 echo "results transcript." >> $out
 echo "" >> $out
@@ -21,13 +21,13 @@
 # compilation tests
 
 function scala_compile {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2> /dev/null 1> /dev/null)
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null)
 }
 
 # functional tests
 
 function scala_assert {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 }
 
 
@@ -45,7 +45,7 @@
 
 if (scala_vars bfc.scala)
 then
-  echo "  --> test failed" | tee -a $out
+  echo "  --> FAIL (make triple-sure your program conforms to the required format)" | tee -a $out
   tsts0=$(( 1 ))
 else
   echo "  --> success" | tee -a $out
@@ -63,7 +63,7 @@
     echo "  --> success" | tee -a $out
     tsts1=$(( 0 ))
   else
-    echo "  --> scala bfc.scala did not run successfully" | tee -a $out
+    echo "  --> SCALA DID NOT RUN BFC.SCALA\n" | tee -a $out
     tsts1=$(( 1 )) 
   fi
 else
@@ -94,7 +94,7 @@
       echo "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-    echo "  --> test failed" | tee -a $out
+    echo "  --> \n ONE TEST FAILED\n" | tee -a $out
   fi
 fi
 
@@ -120,7 +120,7 @@
       echo "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
-    echo "  --> test failed" | tee -a $out
+      echo "  --> \n ONE TEST FAILED\n" | tee -a $out
   fi
 fi
 
@@ -145,12 +145,12 @@
       echo "  --> success" | tee -a $out
       marks=$(( marks + 2 ))
   else
-      echo "  --> test failed" | tee -a $out
+      echo "  --> \n ONE TEST FAILED\n" | tee -a $out
   fi
 fi
 
 
 ## final marks
-echo "Overall mark for CW 10, Advanced Part 2" | tee -a $out
+echo "Overall mark for CW 10, Part 2" | tee -a $out
 echo "$marks" | tee -a $out
 
--- a/marking5/compare	Wed Oct 30 11:51:02 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-#!/bin/sh
-###set -e
-
-trap "exit" INT
-
-files=${1:-assignment201810-*}
-
-for sd in $files; do
-  cd $sd
-  cp output output1
-  #cmp -s output output1 > /dev/null
-  #if [ $? -eq 1 ]; then
-  #    echo $sd + "is different"
-  #fi
-  cd ..
-done
-
-
--- a/marking5/tails	Wed Oct 30 11:51:02 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#!/bin/sh
-###set -e
-
-trap "exit" INT
-
-files=${1:-assignment201810-*}
-
-for sd in $files; do
-  cd $sd
-  #echo $sd
-  marksone=$(( `tail -1 output` ))
-  markstwo=$(( `tail -1 output1` ))
-  if [ "$marksone" != "$markstwo" ]; then
-      echo $sd + "is different"
-  fi
-  cd ..
-done
-
-
--- a/testing5/bf_test.sh	Wed Oct 30 11:51:02 2019 +0000
+++ b/testing5/bf_test.sh	Wed Oct 30 12:37:18 2019 +0000
@@ -1,11 +1,11 @@
 #!/bin/bash
-set -e
+set -euo pipefail
 
 out=${1:-output}
 
 echo -e "" > $out
 
-echo -e "Below is the feedback for your submission of CW 10, Part 1." >> $out
+echo -e "Below is the feedback for your submission of CW 10." >> $out
 echo -e "" >> $out
 
 
@@ -18,7 +18,7 @@
 # functional tests
 
 function scala_assert {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)   
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)   
 }
 
 # purity test
@@ -34,7 +34,7 @@
 
 if (scala_vars bf.scala)
 then
-  echo -e "   --> fail (make triple-sure your program conforms to the required format)" >> $out  
+  echo -e "   --> FAIL (make triple-sure your program conforms to the required format)" >> $out  
   tsts0=$(( 0 ))
 else
   echo -e "  --> success" >> $out
@@ -52,7 +52,7 @@
     echo -e "  --> success" >> $out
     tsts1=$(( 0 ))
   else
-    echo -e "  -->   --> SCALA DID NOT RUN BF.SCALA\nx" >> $out
+    echo -e "  --> SCALA DID NOT RUN BF.SCALA\n" >> $out
     tsts1=$(( 1 )) 
   fi
 else
--- a/testing5/bf_test1.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/testing5/bf_test1.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10a._
 
 assert(load_bff("benchmark.bf").length == 188)
 assert(load_bff("foobar.bf") == "")
--- a/testing5/bf_test2.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/testing5/bf_test2.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10a._
 
 assert(sread(Map(), 2) == 0)
 assert(sread(Map(2 -> 1), 2) == 1)
--- a/testing5/bf_test2.sh	Wed Oct 30 11:51:02 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-#!/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 "$1" 2>> $out 1>> $out)
-}
-
-# functional tests
-
-function scala_assert {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -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
-
-
-
--- a/testing5/bf_test3.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/testing5/bf_test3.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10a._
 
 assert(jumpRight("[xxxxxx]xxx", 1, 0) == 8)
 assert(jumpRight("[xx[x]x]xxx", 1, 0) == 8)
--- a/testing5/bf_test4.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/testing5/bf_test4.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10a._
 
 assert(run("[-]", Map(0 -> 100)) == Map(0 -> 0))
 assert(run("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
--- a/testing5/bf_test6.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/testing5/bf_test6.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10b._
 
 assert(optimise(load_bff("benchmark.bf")).length == 181)
 assert(optimise(load_bff("mandelbrot.bf")).length == 11203)
--- a/testing5/bf_test7.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/testing5/bf_test7.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,3 +1,4 @@
+import CW10b._
 
 assert(combine(optimise(load_bff("benchmark.bf"))).length == 134)
 assert(combine(optimise(load_bff("mandelbrot.bf"))).length == 6509)
--- a/testing5/bfc.scala	Wed Oct 30 11:51:02 2019 +0000
+++ b/testing5/bfc.scala	Wed Oct 30 12:37:18 2019 +0000
@@ -1,7 +1,7 @@
 // Part 2 about a "Compiler" for the Brainf*** language
 //======================================================
 
-//object CW10b {
+object CW10b {
 
 // !!! Copy any function you need from file bf.scala !!!
 //
@@ -309,4 +309,4 @@
 //time_needed(1, run4(load_bff("mandelbrot.bf")))
 
 
-//}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing5/bfc_test.sh	Wed Oct 30 12:37:18 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 "$1" 2>> $out 1>> $out)
+}
+
+# functional tests
+
+function scala_assert {
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 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\n" >> $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
+
+
+