marking/mark02b
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 16 Dec 2016 13:25:08 +0000
changeset 87 9384b8c98014
parent 86 f8a781322499
child 88 990a1531135d
permissions -rwxr-xr-x
updatd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
86
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
set -e
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
out=${1:-output}
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
echo "" > $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
echo "Below is the feedback and provisional mark for your submission" >> $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
echo "for CW 7, Part 2.  Please note all marks are provisional until" >> $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
echo "ratified by the assessment board -- this is not an official" >> $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
echo "results transcript." >> $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
echo "" >> $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
function scala_vars {
87
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    15
   (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
86
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
}
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
# compilation tests
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
function scala_compile {
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  (scala "$1" 2> /dev/null 1> /dev/null) 
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
}
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
# functional tests
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
function scala_assert {
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
}
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
# marks for CW2b
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
marks=$(( 0 ))
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
# knights3: var, comments test
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
#
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
echo "knight3.scala does not contain vars, returns etc?" | tee -a $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
if (scala_vars knight3.scala)
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
then
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  echo "  --> fail" | tee -a $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  tsts0=$(( 1 ))
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
else
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  echo "  --> yes" | tee -a $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
  tsts0=$(( 0 )) 
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
fi
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
# compilation test
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
if  [ $tsts0 -eq 0 ]
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
then    
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  echo "knight3.scala runs?" | tee -a $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  if (scala_compile knight3.scala.bak)
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
  then
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
    echo "  --> yes" | tee -a $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
    tsts1=$(( 0 ))
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
  else
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
    echo "  --> scala knight3.scala did not run successfully" | tee -a $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
    tsts1=$(( 1 )) 
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  fi
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
else
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
  tsts1=$(( 1 ))     
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
fi
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
87
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    68
if [ $tsts1 -eq 0 ]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    69
then
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    70
  echo " ordered_moves(8, List((3,4), (3,2)), (1, 3)) == List((0,1), (0,5), (2,1), (2,5))" | tee -a $out
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    71
  echo " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" | tee -a $out
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    72
  echo " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" | tee -a $out
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    73
  
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    74
  if (scala_assert "knight3.scala.bak" "../../../marking/knight3a_test.scala")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    75
  then
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    76
    echo "  --> success" | tee -a $out
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    77
    marks=$(( marks + 1 ))
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    78
  else
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    79
    echo "  --> test failed" | tee -a $out
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    80
  fi
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 86
diff changeset
    81
fi
86
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
## final marks
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
echo "Overall mark for CW 7, Part 2" | tee -a $out
f8a781322499 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
echo "$marks" | tee -a $out