main_marking3/re_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 16 Jul 2021 23:34:19 +0100
changeset 394 839ad118e467
parent 390 175a950470a9
child 424 daf561a83ba6
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
#!/bin/bash
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
# to make the script fail safely
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
set -euo pipefail
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
out=${1:-output}
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
echo -e "" > $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
echo -e `date` >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
echo -e  "" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
echo -e "Below is the feedback and provisional marks for your submission" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
echo -e "for the Main Part 3 (Scala). Please note all marks are provisional until" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
echo -e "ratified by the assessment board -- this is not an official" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
echo -e "results transcript." >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
echo -e "" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
# marks for CW8
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
marks=$(( 0 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
# compilation tests
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
function scala_compile {
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
}
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    27
# functional tests
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
function scala_assert {
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
}
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
function scala_assert_thirty {
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
  (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
}
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
# purity test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
function scala_vars {
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
   (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
}
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
echo -e "" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
echo -e  "Below is the feedback for your submission re.scala" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
echo -e  "" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
### compilation test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
echo -e "re.scala runs?" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
if (scala_compile re.scala)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
    echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
    tsts=$(( 0 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
    echo -e "  --> SCALA DID NOT RUN re.scala" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
    tsts=$(( 1 )) 
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    61
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    62
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    63
# var, return, ListBuffer test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
#
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    65
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    66
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
then 
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
    echo -e "re.scala does not contain VARS, RETURNS etc?" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
    if (scala_vars re.scala)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
    then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
	echo -e  "  --> TEST FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
	tsts=$(( 1 ))  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
    else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
	echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
	tsts=$(( 0 )) 
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
    fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
    tsts=$(( 1 ))  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
### re1 test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    85
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
  echo -e " nullable(ZERO) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
  echo -e " nullable(ONE) == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
  echo -e " nullable(CHAR('a')) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
  echo -e " nullable(ZERO | ONE) == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
  echo -e " nullable(ZERO | CHAR('a')) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
  echo -e " nullable(ONE ~  ONE) == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
  echo -e " nullable(ONE ~ CHAR('a')) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    95
  echo -e " nullable(STAR(ZERO)) == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    96
  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    97
  if (scala_assert "re.scala" "re_test1.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    98
  then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    99
      echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
      marks=$(( marks + 1 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   102
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
### re2 test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
  echo -e " der('a', ZERO | ONE) == (ZERO | ZERO)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
  echo -e " der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
  echo -e " der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
  echo -e " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
  echo -e " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
  echo -e " val r0 = \"a\" ~ \"b\" ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
  echo -e " der('a', r0) == (ONE ~ \"b\") ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
  echo -e " der('b', r0) == (ZERO ~ \"b\") ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
  echo -e " der('c', r0) == (ZERO ~ \"b\") ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
  echo -e " val r1 = (ONE ~ \"b\") ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
  echo -e " der('a', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
  echo -e " der('b', r1) == ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
  echo -e " der('c', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   126
  echo -e " val r2 = ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
  echo -e " der('a', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
  echo -e " der('b', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
  echo -e " der('c', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ONE)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
  if (scala_assert "re.scala" "re_test2.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
  then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
      echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
      marks=$(( marks + 1 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
### re3 test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   142
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   144
  echo -e " simp(ZERO | ONE) == ONE" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
  echo -e " simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
  echo -e " simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
  echo -e " simp(((ONE ~ ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
  echo -e " simp(((ONE | ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
  echo -e " simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
  echo -e " simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
  echo -e " simp(CHAR('a') | CHAR('a')) == CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
  echo -e " simp(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
  echo -e " simp(ONE | CHAR('a')) == (ONE | CHAR('a'))" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
  echo -e " simp(ALT((CHAR('a') | ZERO) ~ ONE," | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
  echo -e "          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
  echo -e " simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
  echo -e " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
  echo -e " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
  echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE | CHAR('a'), CHAR('a') | ONE)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
  if (scala_assert "re.scala" "re_test3.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
  then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
      echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
      marks=$(( marks + 1 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   167
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   168
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   169
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   170
### re4 test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   171
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   173
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   174
  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
  echo -e " ders((\"a\" * 5).toList,EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
  echo -e " ders(List('b'),EVIL) == ONE" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
  echo -e " ders(List('b','b'),EVIL) == ZERO" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   178
  echo -e " matcher(EVIL, \"a\" * 5 ++ \"b\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
  echo -e " matcher(EVIL, \"a\" * 50 ++ \"b\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
  echo -e " matcher(EVIL, \"a\" * 50) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
  echo -e " matcher(EVIL, \"b\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
  echo -e " matcher(EVIL, \"bb\") == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   183
  echo -e " matcher(\"abc\", \"abc\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
  echo -e " matcher(\"abc\", \"ab\") == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
  echo -e " matcher((\"ab\" | \"a\") ~ (ONE | \"bc\"), \"abc\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
  echo -e " matcher(ONE, \"\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
  echo -e " matcher(ZERO, \"\") == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
  echo -e " matcher(ONE | CHAR('a'), \"\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
  echo -e " matcher(ONE | CHAR('a'), \"a\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
  if (scala_assert "re.scala" "re_test4.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
  then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
      echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   194
      marks=$(( marks + 1 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   195
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   196
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   197
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   198
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   199
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   200
### re5 test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   201
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   202
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   203
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   204
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   205
  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   206
  echo -e " size(der('a', der('a', EVIL))) == 28" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   207
  echo -e " size(der('a', der('a', der('a', EVIL)))) == 58" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   208
  echo -e " size(ders(\"aaaaaa\".toList, EVIL)) == 8" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   209
  echo -e " size(ders((\"a\" * 50).toList, EVIL)) == 8" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   210
  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   211
  if (scala_assert "re.scala" "re_test5.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   212
  then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   213
      echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   214
      marks=$(( marks + 1 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   215
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   216
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   217
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   218
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   219
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   220
### re6 'power' test 1
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   221
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   222
sleep 5
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   223
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   224
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   225
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   226
  echo -e " simp(Iterator.iterate(ONE:Rexp)(r => SEQ(r, ONE | ONE)).drop(50).next) == ONE" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   227
  echo -e "    ...the Iterator produces the rexp" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   228
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   229
  echo -e "      SEQ(SEQ(SEQ(..., ONE | ONE) , ONE | ONE), ONE | ONE)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   230
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   231
  echo -e "    where SEQ is nested 50 times." | tee -a $out  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   232
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   233
  echo -e " simp(Iterator.iterate(ONE:Rexp)(r => ALT(r, r)).drop(20).next) == ONE" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   234
  echo -e "    ... the Iterator produces a rexp of size 2097151" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   235
  START=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   236
  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   237
  if (scala_assert_thirty "re.scala" "re_test6.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   238
  then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   239
      END=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   240
      DIFF=$(( $END - $START ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   241
      echo "   This test ran for $DIFF seconds" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   242
      echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   243
      marks=$(( marks + 1 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   244
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   245
      END=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   246
      DIFF=$(( $END - $START ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   247
      echo "  This test ran for $DIFF seconds" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   248
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   249
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   250
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   251
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   252
sleep 10
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   253
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   254
### re7 'power' test 2
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   255
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   256
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   257
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   258
  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   259
  echo -e " matcher(EVIL, \"a\" * 1000000 ++ \"b\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   260
  echo -e " matcher(EVIL, \"a\" * 1000000) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   261
  START=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   262
  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   263
  if (scala_assert_thirty "re.scala" "re_test7.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   264
  then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   265
      END=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   266
      DIFF=$(( $END - $START ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   267
      echo "   This test ran for $DIFF seconds" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   268
      echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   269
      marks=$(( marks + 1 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   270
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   271
      END=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   272
      DIFF=$(( $END - $START ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   273
      echo "  This test ran for $DIFF seconds" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   274
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   275
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   276
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   277
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   278
sleep 10
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   279
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   280
## final marks
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   281
echo -e "Overall mark for Main Part 3 (Scala)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   282
echo -e "$marks" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   283
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   284