#!/bin/bash
set -e
out=${1:-output}
echo "" > $out
echo "Below is the feedback and provisional mark for your submission" >> $out
echo "for CW 7, 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
function scala_vars {
(egrep 'var|return|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
}
# compilation tests
function scala_compile {
(scala "$1" 2> /dev/null 1> /dev/null)
}
# functional tests
function scala_assert {
(scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
}
# marks for CW2b
marks=$(( 0 ))
# knights3: var, comments test
#
echo "knight3.scala does not contain vars, returns etc?" | tee -a $out
if (scala_vars knight3.scala)
then
echo " --> fail" | tee -a $out
tsts0=$(( 1 ))
else
echo " --> yes" | tee -a $out
tsts0=$(( 0 ))
fi
# compilation test
if [ $tsts0 -eq 0 ]
then
echo "knight3.scala runs?" | tee -a $out
if (scala_compile knight3.scala.bak)
then
echo " --> yes" | tee -a $out
tsts1=$(( 0 ))
else
echo " --> scala knight3.scala did not run successfully" | tee -a $out
tsts1=$(( 1 ))
fi
else
tsts1=$(( 1 ))
fi
## final marks
echo "Overall mark for CW 7, Part 2" | tee -a $out
echo "$marks" | tee -a $out