pre_marking3/postfix_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 15 Jan 2021 02:40:57 +0000
changeset 384 6e1237691307
child 386 e2170c91a9f2
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
384
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
#!/bin/zsh
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
set -euo pipefail
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
out=${1:-output}
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
echo -e "" > $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
echo `date` >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
echo -e "Below is the feedback and provisional marks for your submission" >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
echo -e "of the Preliminary Part of Part 3 (Scala).  Please note all marks are provisional until" >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
echo -e "ratified by the assessment board -- this is not an official" >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
echo -e "results transcript." >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
echo -e "" >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
echo -e "Below is the feedback for your submission docdiff.scala" >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
echo -e "" >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
# marks for CW9 preliminary
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
marks=$(( 0.0 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
# compilation tests
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
function scala_compile {
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    27
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
}
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
# functional tests
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
function scala_assert {
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
}
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
# purity test
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
function scala_vars {
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
   (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null)
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
}
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
# compilation test
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
echo -e "postfix.scala runs?" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
if (scala_compile postfix.scala)
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
   echo -e "  --> success" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
   tsts=$(( 0 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
   echo -e "  --> SCALA DID NOT RUN postfix.scala\n" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
   tsts=$(( 1 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
# var, return, ListBuffer test
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
#
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
if  [ $tsts -eq 0 ]
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
  then   
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    61
  echo -e "postfix.scala does not contain VARS, RETURNS etc??" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    62
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    63
  if (scala_vars postfix.scala)
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
  then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    65
    echo -e "  --> FAIL\n" | tee -a $out  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    66
    tsts=$(( 1 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
  else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
    echo -e "  --> success" | tee -a $out  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
    tsts=$(( 0 )) 
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
  fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
   tsts=$(( 1 ))  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
fi  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
### postfix tests
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
if [ $tsts -eq 0 ]
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
  echo -e " syard(split(\"3 + 4 * ( 2 - 1 )\")) == List(\"3\", \"4\", \"2\", \"1\", \"-\", \"*\", \"+\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
  echo -e " syard(split(\"( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )\")) == List(\"3\", \"4\", \"5\", \"+\", \"+\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
  echo -e " syard(split(\"5 + 7 / 2\")) == List(\"5\", \"7\", \"2\", \"/\", \"+\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
  echo -e " syard(split(\"5 * 7 / 2\")) == List(\"5\", \"7\", \"*\", \"2\", \"/\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    85
  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
  if (scala_assert "postfix.scala" "postfix_test1.scala")
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
  then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
    echo -e "  --> success" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
    marks=$(( marks + 1.0 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
  else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
    echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
  fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    95
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    96
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    97
if [ $tsts -eq 0 ]
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    98
then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    99
  echo -e " compute(syard(split(\"3 + 4 * ( 2 - 1 )\"))) == 7" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
  echo -e " compute(syard(split(\"10 + 12 * 33\"))) == 406" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
  echo -e " compute(syard(split(\"( 5 + 7 ) * 2\"))) == 24" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   102
  echo -e " compute(syard(split(\"5 + 7 / 2\"))) == 8" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
  echo -e " compute(syard(split(\"5 * 7 / 2\"))) == 17" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
  echo -e " compute(syard(split(\"9 + 24 / ( 7 - 3 )\"))) == 15" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
  if (scala_assert "postfix.scala" "postfix_test2.scala")
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
  then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
     echo -e "  --> success" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
     marks=$(( marks + 1.0 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
  else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
     echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
  fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
### postfix2 tests
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
echo -e "Below is the feedback for your submission postfix2.scala" >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
echo -e "" >> $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
# compilation test
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
echo -e "postfix2.scala runs?" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   126
if (scala_compile postfix2.scala)
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
   echo -e "  --> success" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
   tsts=$(( 0 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
   echo -e "  --> SCALA DID NOT RUN postfix2.scala\n" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
   tsts=$(( 1 )) 
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
# var, return, ListBuffer test
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
#
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
if  [ $tsts -eq 0 ]
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
then     
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
  echo -e "postfix2.scala does not contain VARS, RETURNS etc?" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   142
  if (scala_vars postfix2.scala)
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
  then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   144
    echo -e "  --> FAIL\n" | tee -a $out  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
    tsts=$(( 1 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
  else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
    echo -e "  --> success" | tee -a $out  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
    tsts=$(( 0 )) 
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
  fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
  tsts=$(( 1 ))  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
if [ $tsts -eq 0 ]
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
  echo -e " syard(split(\"3 + 4 * ( 2 - 1 )\")) == List(\"3\", \"4\", \"2\", \"1\", \"-\", \"*\", \"+\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
  echo -e " syard(split(\"( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )\")) == List(\"3\", \"4\", \"5\", \"+\", \"+\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
  echo -e " syard(split(\"5 + 7 / 2\")) == List(\"5\", \"7\", \"2\", \"/\", \"+\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
  echo -e " syard(split(\"5 * 7 / 2\")) == List(\"5\", \"7\", \"*\", \"2\", \"/\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
  echo -e " syard(split(\"3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3\")) == " | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
  echo -e "         List(\"3\", \"4\", \"8\", \"*\", \"5\", \"1\", \"-\", \"2\", \"3\", \"^\", \"^\", \"/\", \"+\")" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
  if (scala_assert "postfix2.scala" "postfix_test3.scala")
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   167
  then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   168
      echo -e "  --> success" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   169
      marks=$(( marks + 0.5 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   170
  else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   171
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
  fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   173
fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   174
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
if [ $tsts -eq 0 ]
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
  echo -e " compute(syard(split(\"3 + 4 * ( 2 - 1 )\"))) == 7" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   178
  echo -e " compute(syard(split(\"10 + 12 * 33\"))) == 406" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
  echo -e " compute(syard(split(\"( 5 + 7 ) * 2\"))) == 24" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
  echo -e " compute(syard(split(\"5 + 7 / 2\"))) == 8" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
  echo -e " compute(syard(split(\"5 * 7 / 2\"))) == 17" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
  echo -e " compute(syard(split(\"9 + 24 / ( 7 - 3 )\"))) == 15" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   183
  echo -e " compute(syard(split(\"4 ^ 3 ^ 2\"))) == 262144" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
  echo -e " compute(syard(split(\"4 ^ ( 3 ^ 2 )\"))) == 262144" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
  echo -e " compute(syard(split(\"( 4 ^ 3 ) ^ 2\"))) == 4096" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
  echo -e " compute(syard(split(\"( 3 + 1 ) ^ 2 ^ 3\"))) == 65536" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
  
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
  if (scala_assert "postfix2.scala" "postfix_test10.scala")
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
  then
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
      echo -e "  --> success" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
      marks=$(( marks + 0.5 ))
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
  else
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   194
  fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   195
fi
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   196
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   197
## final marks
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   198
echo -e "Overall mark for the Preliminary Part 3 (Scala)" | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   199
printf " %0.1f\n" $marks | tee -a $out
6e1237691307 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   200