marking/mark03b
changeset 93 21f41e08457d
child 94 ae4708c851ee
equal deleted inserted replaced
92:cfff88de2ff5 93:21f41e08457d
       
     1 #!/bin/bash
       
     2 set -e
       
     3 
       
     4 out=${1:-output}
       
     5 
       
     6 echo "" > $out
       
     7 
       
     8 echo "Below is the feedback and provisional mark for your submission" >> $out
       
     9 echo "for CW 8, Part 2.  Please note all marks are provisional until" >> $out
       
    10 echo "ratified by the assessment board -- this is not an official" >> $out
       
    11 echo "results transcript." >> $out
       
    12 echo "" >> $out
       
    13 
       
    14 function scala_vars {
       
    15    (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
       
    16 }
       
    17 
       
    18 
       
    19 # compilation tests
       
    20 
       
    21 function scala_compile {
       
    22   (scala "$1" 2> /dev/null 1> /dev/null) 
       
    23 }
       
    24 
       
    25 
       
    26 # functional tests
       
    27 
       
    28 function scala_assert {
       
    29   (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
       
    30 }
       
    31 
       
    32 
       
    33 # marks for CW
       
    34 marks=$(( 0 ))
       
    35 
       
    36 
       
    37 # var, return, ListBuffer test
       
    38 #
       
    39 echo "re2.scala does not contain vars, returns etc?" | tee -a $out
       
    40 
       
    41 if (scala_vars re.scala)
       
    42 then
       
    43   echo "  --> fail" | tee -a $out
       
    44   tsts0=$(( 1 ))
       
    45 else
       
    46   echo "  --> yes" | tee -a $out
       
    47   tsts0=$(( 0 )) 
       
    48 fi
       
    49 
       
    50 
       
    51 # compilation test
       
    52 if  [ $tsts0 -eq 0 ]
       
    53 then    
       
    54   echo "re2.scala runs?" | tee -a $out
       
    55 
       
    56   if (scala_compile re2.scala)
       
    57   then
       
    58     echo "  --> yes" | tee -a $out
       
    59     tsts1=$(( 0 ))
       
    60   else
       
    61     echo "  --> scala re2.scala did not run successfully" | tee -a $out
       
    62     tsts1=$(( 1 )) 
       
    63   fi
       
    64 else
       
    65   tsts1=$(( 1 ))     
       
    66 fi
       
    67 
       
    68 #if [ $tsts1 -eq 0 ]
       
    69 #then
       
    70 #  echo " nullable(ZERO) == false" | tee -a $out
       
    71 #  echo " nullable(ONE) == true" | tee -a $out
       
    72 #  
       
    73 #  if (scala_assert "re.scala.bak" "../../../marking/re1a_test.scala")
       
    74 #  then
       
    75 #    echo "  --> success" | tee -a $out
       
    76 #    marks=$(( marks + 1 ))
       
    77 #  else
       
    78 #    echo "  --> test failed" | tee -a $out
       
    79 #  fi
       
    80 #fi
       
    81 
       
    82 
       
    83 ## final marks
       
    84 echo "Overall mark for CW 8, Part 2" | tee -a $out
       
    85 echo "$marks" | tee -a $out