diff -r e9d14d58be3c -r daf561a83ba6 main_marking5/bf_test.sh --- a/main_marking5/bf_test.sh Thu Jan 13 12:55:03 2022 +0000 +++ b/main_marking5/bf_test.sh Mon Apr 11 23:55:27 2022 +0100 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/zsh # to make the script fail safely set -euo pipefail @@ -17,7 +17,7 @@ echo -e "" >> $out # marks for CW10 part 1 -marks=$(( 0 )) +marks=$(( 0.0 )) # compilation tests @@ -36,9 +36,9 @@ } # purity test - function scala_vars { - (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null) + (sed 's/immutable/ok/g' c$out > cb$out; + egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null) } @@ -90,7 +90,7 @@ if (scala_assert "bf.scala" "bf_test1.scala") then echo -e " --> success" | tee -a $out - marks=$(( marks + 1 )) + marks=$(( marks + 0.5 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out fi @@ -109,7 +109,7 @@ if (scala_assert "bf.scala" "bf_test2.scala") then echo -e " --> success" | tee -a $out - marks=$(( marks + 1 )) + marks=$(( marks + 0.5 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out fi @@ -131,7 +131,7 @@ if (scala_assert "bf.scala" "bf_test3.scala") then echo -e " --> success" | tee -a $out - marks=$(( marks + 2 )) + marks=$(( marks + 2.0 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out fi @@ -144,8 +144,6 @@ echo -e " run(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out echo -e " run(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out echo -e " run(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out - echo -e " run(\"++++++++++#>+***#\") == Map(0 -> 10, 1 -> 1000)" | tee -a $out - echo -e " run(\"+++>+@+@+@+@+@\") == Map(0 -> 3, 1 -> 7, 4 -> 3, 5 -> 3, 6 -> 3, 7 -> 3)" | tee -a $out echo -e " run(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out @@ -156,14 +154,13 @@ if (scala_assert "bf.scala" "bf_test4.scala") then - echo -e " --> success" | tee -a $out - marks=$(( marks + 1 )) + echo -e " --> success (mark 1%)" | tee -a $out + marks=$(( marks + 1.0 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out fi fi -sleep 10 if [ $tsts -eq 0 ] then @@ -180,8 +177,8 @@ END=$(date +%s) DIFF=$(( $END - $START )) echo -e " This test ran for $DIFF seconds" | tee -a $out - echo -e " --> success" | tee -a $out - marks=$(( marks + 1 )) + echo -e " --> success (mark 1%)" | tee -a $out + marks=$(( marks + 1.0 )) else END=$(date +%s) DIFF=$(( $END - $START )) @@ -190,7 +187,6 @@ fi fi -sleep 10 echo -e "" >> $out echo -e "Below is the feedback for your submission of bfc.scala" >> $out @@ -250,7 +246,7 @@ if (scala_assert "bfc.scala" "bf_test5.scala") then echo -e " --> success" | tee -a $out - marks=$(( marks + 1 )) + marks=$(( marks + 1.0 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out fi @@ -276,7 +272,7 @@ if (scala_assert "bfc.scala" "bf_test6.scala") then echo -e " --> success" | tee -a $out - marks=$(( marks + 1 )) + marks=$(( marks + 1.0 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out fi @@ -301,7 +297,7 @@ if (scala_assert "bfc.scala" "bf_test7.scala") then echo -e " --> success (+ 2%)" | tee -a $out - marks=$(( marks + 2 )) + marks=$(( marks + 2.0 )) else echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out fi @@ -310,6 +306,5 @@ ## final marks echo -e "Overall mark for Part 5 (Scala)" | tee -a $out -echo -e "$marks" | tee -a $out +printf " %0.1f\n" $marks | tee -a $out -sleep 12