--- a/main_marking3/re_test.sh Thu Jan 13 12:55:03 2022 +0000
+++ b/main_marking3/re_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
@@ -16,7 +16,7 @@
echo -e "" >> $out
# marks for CW8
-marks=$(( 0 ))
+marks=$(( 0.0 ))
# compilation tests
@@ -35,10 +35,11 @@
}
# purity test
+function scala_vars {
+ (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)
+}
-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)
-}
echo -e "" >> $out
echo -e "Below is the feedback for your submission re.scala" >> $out
@@ -97,7 +98,7 @@
if (scala_assert "re.scala" "re_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
@@ -131,7 +132,7 @@
if (scala_assert "re.scala" "re_test2.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
@@ -161,12 +162,33 @@
if (scala_assert "re.scala" "re_test3.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
fi
+### re3a flts test
+
+if [ $tsts -eq 0 ]
+then
+ echo -e " flts(Nil) == Nil" | tee -a $out
+ echo -e " flts(ZERO::ZERO::Nil) == Nil" | tee -a $out
+ echo -e " flts(ZERO::ONE::ZERO::ONE::Nil) == List(ONE, ONE)" | tee -a $out
+ echo -e " flts(ONE::ALTs(List(ONE))::ONE::Nil) == List(ONE, ONE, ONE)" | tee -a $out
+ echo -e " flts(ONE::ALTs(List(ONE))::ONE::ALTs(List(ONE))::Nil) == List(ONE, ONE, ONE, ONE)" | tee -a $out
+
+ if (scala_assert "re.scala" "re_test3a.scala")
+ then
+ echo -e " --> success" | tee -a $out
+ marks=$(( marks + 1.0 ))
+ else
+ echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
+ fi
+fi
+
+
+
### re4 test
if [ $tsts -eq 0 ]
@@ -191,7 +213,7 @@
if (scala_assert "re.scala" "re_test4.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
@@ -211,7 +233,7 @@
if (scala_assert "re.scala" "re_test5.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
@@ -219,7 +241,6 @@
### re6 'power' test 1
-sleep 5
if [ $tsts -eq 0 ]
then
@@ -240,7 +261,7 @@
DIFF=$(( $END - $START ))
echo " This test ran for $DIFF seconds" | tee -a $out
echo -e " --> success" | tee -a $out
- marks=$(( marks + 1 ))
+ marks=$(( marks + 0.5 ))
else
END=$(date +%s)
DIFF=$(( $END - $START ))
@@ -249,7 +270,6 @@
fi
fi
-sleep 10
### re7 'power' test 2
@@ -266,7 +286,7 @@
DIFF=$(( $END - $START ))
echo " This test ran for $DIFF seconds" | tee -a $out
echo -e " --> success" | tee -a $out
- marks=$(( marks + 1 ))
+ marks=$(( marks + 0.5 ))
else
END=$(date +%s)
DIFF=$(( $END - $START ))
@@ -275,10 +295,11 @@
fi
fi
-sleep 10
+
## final marks
echo -e "Overall mark for Main Part 3 (Scala)" | tee -a $out
-echo -e "$marks" | tee -a $out
+printf " %0.1f\n" $marks | tee -a $out
+