main_marking5/bf_test.sh
changeset 463 0315d9983cd0
parent 424 daf561a83ba6
--- a/main_marking5/bf_test.sh	Sun Jan 15 10:58:13 2023 +0000
+++ b/main_marking5/bf_test.sh	Sat Mar 11 22:01:53 2023 +0000
@@ -14,7 +14,10 @@
 echo -e "for Part 5 (Scala).  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
+
+#echo -e "" >> $out
+#echo -e "XXX needs to have own version of load_bff in the testing code" >> $out
+#echo -e "" >> $out
 
 # marks for CW10 part 1
 marks=$(( 0.0 ))
@@ -22,17 +25,17 @@
 # compilation tests
 
 function scala_compile {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
+  (JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
 }
 
 # functional tests
 
 function scala_assert {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
+  (JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
 }
 
 function scala_assert_thirty {
-  (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
+  (JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
 }
 
 # purity test
@@ -71,7 +74,7 @@
 	echo -e "  --> TEST FAILED\n" | tee -a $out
 	tsts=$(( 1 ))
     else
-	echo -e "  --> success" | tee -a $out
+	echo -e "  --> success\n" | tee -a $out
 	tsts=$(( 0 )) 
     fi
 else
@@ -89,7 +92,7 @@
    
   if (scala_assert "bf.scala" "bf_test1.scala")
   then
-      echo -e "  --> success" | tee -a $out
+      echo -e "  --> success (+ 0.5 Marks)\n" | tee -a $out
       marks=$(( marks + 0.5 ))
   else
       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
@@ -108,7 +111,7 @@
   
   if (scala_assert "bf.scala" "bf_test2.scala")
   then
-      echo -e "  --> success" | tee -a $out
+      echo -e "  --> success (+ 0.5 Marks)\n" | tee -a $out
       marks=$(( marks + 0.5 ))
   else
       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
@@ -127,12 +130,18 @@
     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
-  
+    START=$(date +%s)
+    
   if (scala_assert "bf.scala" "bf_test3.scala")
   then
-      echo -e "  --> success" | tee -a $out
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  --> success (+ 2 Marks)\n" | tee -a $out
       marks=$(( marks + 2.0 ))
   else
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out 
       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
@@ -151,12 +160,19 @@
   echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
   echo -e " run(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
+  START=$(date +%s)
   
   if (scala_assert "bf.scala" "bf_test4.scala")
   then
-      echo -e "  --> success (mark 1%)" | tee -a $out
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out 
+      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
       marks=$(( marks + 1.0 ))
   else
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out 
       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
@@ -164,6 +180,7 @@
 
 if [ $tsts -eq 0 ]
 then
+  echo -e " Is run fast enough?" | tee -a $out 
   echo -e " val bench_small = \"\"\">+[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++" | tee -a $out
   echo -e "  [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++" | tee -a $out
   echo -e "  ++++++++[>++++++++++[>++++++++++[>++++++++++[>+" | tee -a $out
@@ -177,7 +194,7 @@
       END=$(date +%s)
       DIFF=$(( $END - $START ))
       echo -e "  This test ran for $DIFF seconds" | tee -a $out  
-      echo -e "  --> success (mark 1%)" | tee -a $out
+      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
       marks=$(( marks + 1.0 ))
   else
       END=$(date +%s)
@@ -187,6 +204,22 @@
   fi
 fi
 
+if [ $tsts -eq 0 ]
+then
+  echo -e " val str = \"\"\"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]\"\"\"" | tee -a $out
+  echo -e " " | tee -a $out
+  echo -e " run(generate(\"ABC\".toList)) == str" | tee -a $out
+  
+  if (scala_assert_thirty "bf.scala" "bf_test4c.scala")
+  then
+      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
+      marks=$(( marks + 1.0 ))
+  else
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
+      echo -e "  --> TEST FAILED\n" | tee -a $out
+  fi
+fi
+
 
 echo -e "" >> $out
 echo -e "Below is the feedback for your submission of bfc.scala" >> $out
@@ -242,12 +275,19 @@
   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
+  START=$(date +%s)
   
   if (scala_assert "bfc.scala" "bf_test5.scala")
   then
-      echo -e "  --> success" | tee -a $out
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
+      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
       marks=$(( marks + 1.0 ))
   else
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
@@ -258,7 +298,7 @@
 if [ $tsts -eq 0 ]
 then
   echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out
-  echo -e " optimise(load_bff(\"mandelbrot.bf\")).length == 11205" | tee -a $out  
+  echo -e " optimise(load_bff(\"sierpinski.bf\")).length == 110" | 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
@@ -268,12 +308,19 @@
   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
+  START=$(date +%s)
   
   if (scala_assert "bfc.scala" "bf_test6.scala")
   then
-      echo -e "  --> success" | tee -a $out
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
+      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
       marks=$(( marks + 1.0 ))
   else
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi
@@ -283,7 +330,7 @@
 if [ $tsts -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 == 6511" | tee -a $out
+  echo -e " combine(optimise(load_bff(\"sierpinski.bf\"))).length == 122" | 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
@@ -293,12 +340,19 @@
   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
+  START=$(date +%s)
   
   if (scala_assert "bfc.scala" "bf_test7.scala")
   then
-      echo -e "  --> success (+ 2%)" | tee -a $out
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out  END=$(date +%s)
+      echo -e "  --> success (+ 2 Marks)" | tee -a $out
       marks=$(( marks + 2.0 ))
   else
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo -e "  This test ran for $DIFF seconds" | tee -a $out     
       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi