updated
authorChristian Urban <urbanc@in.tum.de>
Thu, 17 Jan 2019 00:31:32 +0000
changeset 255 44f2b6e34015
parent 254 cc0154804096
child 256 512292bb5e93
updated
TAs
marking5/bf_test5.scala
marking5/bf_test6.scala
marking5/bf_test7.scala
marking5/bfc_test.sh
marking5/mk-advanced
--- a/TAs	Wed Jan 16 12:24:47 2019 +0000
+++ b/TAs	Thu Jan 17 00:31:32 2019 +0000
@@ -68,13 +68,13 @@
 
 CW10, Part 1
                late (231)
-194  => 6       137
-3    => 5        56
+194  => 6       195
+3    => 5         4
 15   => 4        16
-1    => 3         5
-4    => 2         4
-2    => 1         0 
-11   => 0        13
+1    => 3         1
+4    => 2         3
+2    => 1         1 
+11   => 0        10
 --------
 230 submissions
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking5/bf_test5.scala	Thu Jan 17 00:31:32 2019 +0000
@@ -0,0 +1,21 @@
+
+val hw_urban = """+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]"""
+assert(jtable(hw_urban) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6))
+
+val hw_urban1 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
+
+assert(jtable(hw_urban1) == Map(14 -> 34, 33 -> 15, 45 -> 44, 48 -> 9, 43 -> 46, 8 -> 49))
+
+
+
+assert(run2("[-]", Map(0 -> 100)) == Map(0 -> 0))
+assert(run2("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
+assert(run2("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
+val hw_urban2 = """+++++[->++++++++++<]>--<+++[->>++++++++++
+                  <<]>>++<<----------[+>.>.<+<]"""
+assert(run2(hw_urban2) == Map(0 -> 0, 1 -> 58, 2 -> 32))
+
+val hw_urban3 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.
+                   +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
+
+assert(run2(hw_urban3) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking5/bf_test6.scala	Thu Jan 17 00:31:32 2019 +0000
@@ -0,0 +1,17 @@
+
+assert(optimise(load_bff("benchmark.bf")).length == 181)
+assert(optimise(load_bff("mandelbrot.bf")).length == 11203)
+
+
+
+assert(run3("[-]", Map(0 -> 100)) == Map(0 -> 0))
+assert(run3("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
+assert(run3("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
+val hw_urban2 = """+++++[->++++++++++<]>--<+++[->>++++++++++
+                  <<]>>++<<----------[+>.>.<+<]"""
+assert(run3(hw_urban2) == Map(0 -> 0, 1 -> 58, 2 -> 32))
+
+val hw_urban3 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.
+                   +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
+
+assert(run3(hw_urban3) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking5/bf_test7.scala	Thu Jan 17 00:31:32 2019 +0000
@@ -0,0 +1,17 @@
+
+assert(combine(optimise(load_bff("benchmark.bf"))).length == 134)
+assert(combine(optimise(load_bff("mandelbrot.bf"))).length == 6509)
+
+
+
+assert(run4("[-]", Map(0 -> 100)) == Map(0 -> 0))
+assert(run4("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
+assert(run4("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
+val hw_urban2 = """+++++[->++++++++++<]>--<+++[->>++++++++++
+                  <<]>>++<<----------[+>.>.<+<]"""
+assert(run4(hw_urban2) == Map(0 -> 0, 1 -> 58, 2 -> 32))
+
+val hw_urban3 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.
+                   +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
+
+assert(run4(hw_urban3) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking5/bfc_test.sh	Thu Jan 17 00:31:32 2019 +0000
@@ -0,0 +1,156 @@
+#!/bin/bash
+
+# to make the script fail safely
+set -euo pipefail
+
+
+out=${1:-output}
+
+echo "" > $out
+
+
+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 "ratified by the assessment board -- this is not an official" >> $out
+echo "results transcript." >> $out
+echo "" >> $out
+
+# marks for CW10 part 2
+marks=$(( 0 ))
+
+# compilation tests
+
+function scala_compile {
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$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)
+}
+
+
+# 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 "bfc.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
+
+if (scala_vars bfc.scala)
+then
+  echo "  --> test failed" | tee -a $out
+  tsts0=$(( 1 ))
+else
+  echo "  --> success" | tee -a $out
+  tsts0=$(( 0 )) 
+fi
+
+
+# compilation test
+if  [ $tsts0 -eq 0 ]
+then    
+  echo "bfc.scala runs?" | tee -a $out
+
+  if (scala_compile bfc.scala)
+  then
+    echo "  --> success" | tee -a $out
+    tsts1=$(( 0 ))
+  else
+    echo "  --> scala bfc.scala did not run successfully" | tee -a $out
+    tsts1=$(( 1 )) 
+  fi
+else
+  tsts1=$(( 1 ))     
+fi
+
+
+### bfc5 test
+
+if [ $tsts1 -eq 0 ]
+then
+  echo -e " val p1 = \"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\"\"\"" | tee -a $out
+  echo -e " jtable(p1) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6)" | tee -a $out  
+  echo -e " val p2 = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
+  echo -e " jtable(p2) == Map(14 -> 34, 33 -> 15, 45 -> 44, 48 -> 9, 43 -> 46, 8 -> 49)" | tee -a $out
+  echo -e " run2(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
+  echo -e " run2(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
+  echo -e " run2(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
+  echo -e " run2(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
+  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
+  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
+  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
+  echo -e " run2(hello, Map()) == " | tee -a $out
+  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
+  
+  if (scala_assert "bfc.scala" "bf_test5.scala")
+  then
+      echo "  --> success" | tee -a $out
+      marks=$(( marks + 1 ))
+  else
+    echo "  --> test failed" | tee -a $out
+  fi
+fi
+
+
+### bfc6 test
+
+if [ $tsts1 -eq 0 ]
+then
+  echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out
+  echo -e " optimise(load_bff(\"mandelbrot.bf\")).length == 11203" | tee -a $out  
+  echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
+  echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
+  echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
+  echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
+  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
+  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
+  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
+  echo -e " run3(hello, Map()) == " | tee -a $out
+  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
+  
+  if (scala_assert "bfc.scala" "bf_test6.scala")
+  then
+      echo "  --> success" | tee -a $out
+      marks=$(( marks + 1 ))
+  else
+    echo "  --> test failed" | tee -a $out
+  fi
+fi
+
+### bfc7 test
+
+if [ $tsts1 -eq 0 ]
+then
+  echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out
+  echo -e " combine(optimise(load_bff(\"mandelbrot.bf\"))).length == 6509" | tee -a $out
+  echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
+  echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
+  echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
+  echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
+  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
+  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
+  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
+  echo -e " run4(hello, Map()) == " | tee -a $out
+  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
+  
+  if (scala_assert "bfc.scala" "bf_test7.scala")
+  then
+      echo "  --> success" | tee -a $out
+      marks=$(( marks + 2 ))
+  else
+      echo "  --> test failed" | tee -a $out
+  fi
+fi
+
+
+## final marks
+echo "Overall mark for CW 10, Advanced Part 2" | tee -a $out
+echo "$marks" | tee -a $out
+
--- a/marking5/mk-advanced	Wed Jan 16 12:24:47 2019 +0000
+++ b/marking5/mk-advanced	Thu Jan 17 00:31:32 2019 +0000
@@ -3,21 +3,23 @@
 
 trap "exit" INT
 
-files=${1:-assignment20178-*}
+files=${1:-assignment201710-*}
 
 for sd in $files; do
   cd $sd
   echo $sd
   touch .
-  cp ../../../marking3/bf_test.sh .
-  cp ../../../marking3/bf1a_test.scala .
-  cp ../../../marking3/bf1b_test.scala .
-  cp ../../../marking3/bf1c_test.scala .
-  ./bf_test.sh output
-  rm bf_test.sh
-  rm bf1a_test.scala
-  rm bf1b_test.scala
-  rm bf1c_test.scala
+  cp ../../../marking5/bfc_test.sh .
+  cp ../../../marking5/bf_test5.scala .
+  cp ../../../marking5/bf_test6.scala .
+  cp ../../../marking5/bf_test7.scala .
+  cp ../../../marking5/*.bf .
+  ./bfc_test.sh output
+  rm bfc_test.sh
+  rm bf_test5.scala
+  rm bf_test6.scala
+  rm bf_test7.scala
+  rm *.bf
   cd ..
 done