marking/mark03b
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 21 Dec 2016 03:06:18 +0000
changeset 94 ae4708c851ee
parent 93 21f41e08457d
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
#!/bin/bash
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
set -e
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
out=${1:-output}
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
echo "" > $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
echo "Below is the feedback and provisional mark for your submission" >> $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
echo "for CW 8, Part 2.  Please note all marks are provisional until" >> $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
echo "ratified by the assessment board -- this is not an official" >> $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
echo "results transcript." >> $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
echo "" >> $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
function scala_vars {
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
   (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
}
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
# compilation tests
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
function scala_compile {
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
  (scala "$1" 2> /dev/null 1> /dev/null) 
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
}
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
# functional tests
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
function scala_assert {
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
}
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
# marks for CW
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
marks=$(( 0 ))
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
# var, return, ListBuffer test
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
#
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
echo "re2.scala does not contain vars, returns etc?" | tee -a $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
94
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    41
if (scala_vars re2.scala)
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
then
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
  echo "  --> fail" | tee -a $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
  tsts0=$(( 1 ))
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
else
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
  echo "  --> yes" | tee -a $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
  tsts0=$(( 0 )) 
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
fi
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
# compilation test
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
if  [ $tsts0 -eq 0 ]
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
then    
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
  echo "re2.scala runs?" | tee -a $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
  if (scala_compile re2.scala)
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
  then
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
    echo "  --> yes" | tee -a $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
    tsts1=$(( 0 ))
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
  else
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
    echo "  --> scala re2.scala did not run successfully" | tee -a $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
    tsts1=$(( 1 )) 
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
  fi
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
else
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
  tsts1=$(( 1 ))     
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
fi
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
94
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    68
if [ $tsts1 -eq 0 ]
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    69
then
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    70
  echo " iterT(200000, (x: Int) => x + 1, 0) == 200000" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    71
  echo " iterT(100, (x: BigInt) => x * 2, BigInt(2)) == BigInt(\"2535301200456458802993406410752\")" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    72
  echo " iterT(10, (x: String) => x ++ \"a\", \"a\") == \"aaaaaaaaaaa\"" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    73
  
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    74
  if (scala_assert "re2.scala" "../../../marking/re2a_test.scala")
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    75
  then
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    76
    echo "  --> success" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    77
    marks=$(( marks + 2 ))
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    78
  else
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    79
    echo "  --> test failed" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    80
  fi
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    81
fi
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
94
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    83
if [ $tsts1 -eq 0 ]
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    84
then
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    85
  echo " size(iterT(20, (r: Rexp) => der('a', r), EVIL)) == 7340068" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    86
  echo " size(iterT(20, (r: Rexp) => simp(der('a', r)), EVIL)) == 8" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    87
  
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    88
  if (scala_assert "re2.scala" "../../../marking/re2b_test.scala")
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    89
  then
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    90
    echo "  --> success" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    91
    marks=$(( marks + 1 ))
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    92
  else
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    93
    echo "  --> test failed" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    94
  fi
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    95
fi
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    96
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    97
if [ $tsts1 -eq 0 ]
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    98
then
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    99
  echo " fixpT((x:Int) => if (200000 < x) x else x + 1, 0) == 200001" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   100
  echo " fixpT((x:Long) => if (20 < x) x else x + 1, 0L) == 21L" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   101
  
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   102
  if (scala_assert "re2.scala" "../../../marking/re2c_test.scala")
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   103
  then
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   104
    echo "  --> success" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   105
    marks=$(( marks + 1 ))
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   106
  else
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   107
    echo "  --> test failed" | tee -a $out
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   108
  fi
ae4708c851ee updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   109
fi
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
## final marks
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
echo "Overall mark for CW 8, Part 2" | tee -a $out
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
echo "$marks" | tee -a $out