marking/mark03b
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 21 Dec 2016 01:19:25 +0000
changeset 93 21f41e08457d
child 94 ae4708c851ee
permissions -rwxr-xr-x
updated

#!/bin/bash
set -e

out=${1:-output}

echo "" > $out

echo "Below is the feedback and provisional mark for your submission" >> $out
echo "for CW 8, 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 '\bvar\b|\breturn\b|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 CW
marks=$(( 0 ))


# var, return, ListBuffer test
#
echo "re2.scala does not contain vars, returns etc?" | tee -a $out

if (scala_vars re.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 "re2.scala runs?" | tee -a $out

  if (scala_compile re2.scala)
  then
    echo "  --> yes" | tee -a $out
    tsts1=$(( 0 ))
  else
    echo "  --> scala re2.scala did not run successfully" | tee -a $out
    tsts1=$(( 1 )) 
  fi
else
  tsts1=$(( 1 ))     
fi

#if [ $tsts1 -eq 0 ]
#then
#  echo " nullable(ZERO) == false" | tee -a $out
#  echo " nullable(ONE) == true" | tee -a $out
#  
#  if (scala_assert "re.scala.bak" "../../../marking/re1a_test.scala")
#  then
#    echo "  --> success" | tee -a $out
#    marks=$(( marks + 1 ))
#  else
#    echo "  --> test failed" | tee -a $out
#  fi
#fi


## final marks
echo "Overall mark for CW 8, Part 2" | tee -a $out
echo "$marks" | tee -a $out