main_marking3/re_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Sun, 15 Sep 2024 12:57:59 +0100
changeset 493 244df77507c2
parent 463 0315d9983cd0
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
     1
#!/bin/zsh
390
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
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
    19
marks=$(( 0.0 ))
390
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 {
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
    30
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
390
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 {
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
    34
  (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
390
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
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
    38
function scala_vars {
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
    39
   (sed 's/immutable/ok/g' c$out > cb$out;
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
    40
    egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
    41
}
390
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
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
echo -e "" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
echo -e  "Below is the feedback for your submission re.scala" >> $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
echo -e  "" >> $out
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
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
### compilation test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
echo -e "re.scala runs?" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
if (scala_compile re.scala)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
    echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
    tsts=$(( 0 ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
    echo -e "  --> SCALA DID NOT RUN re.scala" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
    tsts=$(( 1 )) 
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    61
fi
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
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
# var, return, ListBuffer test
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
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
then 
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
    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
    70
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
    if (scala_vars re.scala)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
    then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
	echo -e  "  --> TEST FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
	tsts=$(( 1 ))  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
    else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
	echo -e "  --> success" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
	tsts=$(( 0 )) 
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
    fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
    tsts=$(( 1 ))  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
426
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    83
### make sure datatypes are not tampered with
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    84
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    85
if [ $tsts -eq 0 ]
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    86
then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
    87
    echo -e "re.scala has case classes for ALTs and SEQs?" | tee -a $out
426
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    88
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    89
    if (scala_assert "re.scala" "re_test0.scala")
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    90
    then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
    91
	echo -e "  --> passed" | tee -a $out
426
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    92
	tsts=$(( 0 ))
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    93
    else	
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
    94
	echo -e "  --> FAIL" | tee -a $out
426
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    95
	tsts=$(( 1 ))
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    96
    fi
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    97
else
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    98
    tsts=$(( 1 ))   
b51467741af2 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    99
fi
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   102
### re1 nullable test
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
  echo -e " nullable(ZERO) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
  echo -e " nullable(ONE) == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
  echo -e " nullable(CHAR('a')) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
  echo -e " nullable(ZERO | ONE) == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
  echo -e " nullable(ZERO | CHAR('a')) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
  echo -e " nullable(ONE ~  ONE) == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
  echo -e " nullable(ONE ~ CHAR('a')) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
  echo -e " nullable(STAR(ZERO)) == true" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   114
  echo -e " nullable(ALTs(List(ONE, CHAR('a'), ZERO))) == true" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   115
  echo -e " nullable(SEQs(List(ONE, ALTs(List(ONE, CHAR('a'), ZERO)), STAR(ZERO)))) == true" | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
  if (scala_assert "re.scala" "re_test1.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   119
      echo -e "  --> success (+ 0.5 Marks)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   120
      marks=$(( marks + 0.5 ))
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   126
### re2 der test
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
  echo -e " der('a', ZERO | ONE) == (ZERO | ZERO)" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   131
  echo -e " der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), SEQs(List(ONE)))" | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
  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
   133
  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
   134
  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
   135
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
  echo -e " val r0 = \"a\" ~ \"b\" ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
  echo -e " der('a', r0) == (ONE ~ \"b\") ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
  echo -e " der('b', r0) == (ZERO ~ \"b\") ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
  echo -e " der('c', r0) == (ZERO ~ \"b\") ~ \"c\"" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
  echo -e " val r1 = (ONE ~ \"b\") ~ \"c\"" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   142
  echo -e " der('a', r1) == ((ZERO ~ \"b\") | SEQs(List(ZERO))) ~ \"c\"" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   143
  echo -e " der('b', r1) == ((ZERO ~ \"b\") | SEQs(List(ONE))) ~ \"c\"" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   144
  echo -e " der('c', r1) == ((ZERO ~ \"b\") | SEQs(List(ZERO))) ~ \"c\"" | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
  echo -e " val r2 = ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   147
  echo -e " der('a', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | SEQs(List(ZERO)))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   148
  echo -e " der('b', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | SEQs(List(ZERO)))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   149
  echo -e " der('c', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | SEQs(List(ONE)))" | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
  if (scala_assert "re.scala" "re_test2.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   153
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   154
      marks=$(( marks + 1.0 ))
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   160
### re3 denest test
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   161
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   162
if [ $tsts -eq 0 ]
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   163
then
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   164
    echo -e " denest(List(ONE, ZERO, ALTs(List(ONE, CHAR('a'))))) == List(ONE, ONE, CHAR('a'))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   165
    echo -e " denest(List(ONE ~ ONE, ZERO, ZERO | ONE)) == List(ONE ~ ONE, ZERO, ONE)" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   166
  
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   167
  if (scala_assert "re.scala" "re_test4.scala")
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   168
  then
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   169
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   170
      marks=$(( marks + 1.0 ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   171
  else
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   172
    echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out  
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   173
  fi
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   174
fi
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   175
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   176
### re3a flts test
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   177
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   178
if [ $tsts -eq 0 ]
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   179
then
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   180
  echo -e " flts(Nil) == Nil" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   181
  echo -e " flts(ZERO::ZERO::Nil) == List(ZERO)" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   182
  echo -e " flts(ZERO::ONE::ZERO::ONE::Nil) == List(ZERO)" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   183
  echo -e " flts(ONE::ALTs(List(ONE))::ONE::Nil) == List(ALTs(List(ONE)))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   184
  echo -e " flts(ONE::ALTs(List(ONE))::ONE::ALTs(List(ONE))::Nil) == List(ALTs(List(ONE)), ALTs(List(ONE)))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   185
  echo -e " flts(List(CHAR('a'), ONE, ONE, CHAR('b')), Nil) == List(CHAR('a'), CHAR('b'))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   186
  echo -e " flts(List(ONE ~ CHAR('a'), CHAR('b') ~ ONE), Nil) == List(ONE, CHAR('a'), CHAR('b'), ONE)" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   187
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   188
  if (scala_assert "re.scala" "re_test3a.scala")
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   189
  then
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   190
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   191
      marks=$(( marks + 1.0 ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   192
  else
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   193
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   194
  fi
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   195
fi
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   196
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   197
### re-smart test
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   198
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   199
if [ $tsts -eq 0 ]
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   200
then
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   201
    echo -e " SEQs_smart(Nil) == ONE" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   202
    echo -e " SEQs_smart(List(ZERO)) == ZERO" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   203
    echo -e " SEQs_smart(List(CHAR('a'))) == CHAR('a')" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   204
    echo -e " SEQs_smart(List(ONE ~ ONE)) == ONE ~ ONE" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   205
    echo -e " SEQs_smart(List(ONE, ONE)) == SEQs(List(ONE, ONE))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   206
    echo -e " ALTs_smart(Nil) == ZERO" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   207
    echo -e " ALTs_smart(List(ONE ~ ONE)) == ONE ~ ONE" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   208
    echo -e " ALTs_smart(List(ZERO, ZERO)) == ALTs(List(ZERO, ZERO))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   209
  
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   210
  if (scala_assert "re.scala" "re_test6.scala")
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   211
  then
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   212
    echo -e "  --> success (+ 0.5 Marks)\n" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   213
    marks=$(( marks + 0.5 ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   214
  else
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   215
    echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out   
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   216
  fi
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   217
fi
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   218
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   219
### re3 test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   220
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   221
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   222
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   223
  echo -e " simp(ZERO | ONE) == ONE" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   224
  echo -e " simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   225
  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
   226
  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
   227
  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
   228
  echo -e " simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   229
  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
   230
  echo -e " simp(CHAR('a') | CHAR('a')) == CHAR('a')" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   231
  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
   232
  echo -e " simp(ONE | CHAR('a')) == (ONE | CHAR('a'))" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   233
  echo -e " simp(ALT((CHAR('a') | ZERO) ~ ONE," | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   234
  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
   235
  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
   236
  echo -e " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   237
  echo -e " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   238
  echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE, CHAR('a'))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   239
  echo -e " simp(ALTs(Nil)) == ZERO" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   240
  echo -e " simp(SEQs(List(CHAR('a')))) == CHAR('a')" | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   241
  if (scala_assert "re.scala" "re_test3.scala")
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   242
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   243
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   244
      marks=$(( marks + 1.0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   245
  else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   246
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   247
  fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   248
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   249
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   250
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   251
### re4 test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   252
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   253
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   254
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   255
  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   256
  echo -e " ders((\"a\" * 5).toList,EVIL) == SEQs(List(STAR(CHAR('a')), STAR(STAR(CHAR('a'))), CHAR('b')))" | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   257
  echo -e " ders(List('b'),EVIL) == ONE" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   258
  echo -e " ders(List('b','b'),EVIL) == ZERO" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   259
  echo -e " matcher(EVIL, \"a\" * 5 ++ \"b\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   260
  echo -e " matcher(EVIL, \"a\" * 50 ++ \"b\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   261
  echo -e " matcher(EVIL, \"a\" * 50) == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   262
  echo -e " matcher(EVIL, \"b\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   263
  echo -e " matcher(EVIL, \"bb\") == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   264
  echo -e " matcher(\"abc\", \"abc\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   265
  echo -e " matcher(\"abc\", \"ab\") == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   266
  echo -e " matcher((\"ab\" | \"a\") ~ (ONE | \"bc\"), \"abc\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   267
  echo -e " matcher(ONE, \"\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   268
  echo -e " matcher(ZERO, \"\") == false" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   269
  echo -e " matcher(ONE | CHAR('a'), \"\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   270
  echo -e " matcher(ONE | CHAR('a'), \"a\") == true" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   271
  
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   272
  if (scala_assert "re.scala" "re_test7.scala")
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   273
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   274
      echo -e "  --> success (+ 0.5 Marks)\n" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   275
      marks=$(( marks + 0.5 ))
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   276
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   277
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   278
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   279
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   280
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   281
### re5 test
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   282
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   283
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   284
then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   285
  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   286
  echo -e " size(der('a', der('a', EVIL))) == 36" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   287
  echo -e " size(der('a', der('a', der('a', EVIL)))) == 83" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   288
  echo -e " size(ders(\"aaaaaa\".toList, EVIL)) == 7" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   289
  echo -e " size(ders((\"a\" * 50).toList, EVIL)) == 7" | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   290
  
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   291
  if (scala_assert "re.scala" "re_test8.scala")
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   292
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   293
      echo -e "  --> success (+ 0.5 Marks)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   294
      marks=$(( marks + 0.5 ))
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   295
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   296
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   297
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   298
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   299
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   300
### re6 'power' test 1
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   301
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   302
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   303
if [ $tsts -eq 0 ]
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   304
then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   305
  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
   306
  echo -e "    ...the Iterator produces the rexp" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   307
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   308
  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
   309
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   310
  echo -e "    where SEQ is nested 50 times." | tee -a $out  
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   311
  echo -e "" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   312
  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
   313
  echo -e "    ... the Iterator produces a rexp of size 2097151" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   314
  echo -e "" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   315
  echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   316
  echo -e " matcher(EVIL, \"a\" * 1000000) == false" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   317
  echo -e " matcher(EVIL, \"a\" * 1000000 ++ "b") == true" | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   318
  START=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   319
  
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   320
  if (scala_assert_thirty "re.scala" "re_test9.scala")
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   321
  then
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   322
      END=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   323
      DIFF=$(( $END - $START ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   324
      echo "  This test ran for $DIFF seconds" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   325
      echo -e "  --> success (+ 1.0 Mark)\n" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   326
      marks=$(( marks + 1.0 ))
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   327
  else
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   328
      END=$(date +%s)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   329
      DIFF=$(( $END - $START ))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   330
      echo "  This test ran for $DIFF seconds" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   331
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   332
  fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   333
fi
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   334
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   335
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   336
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   337
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 426
diff changeset
   338
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   339
## final marks
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   340
echo -e "Overall mark for Main Part 3 (Scala)" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   341
printf " %0.1f\n" $marks | tee -a $out
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   342
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   343
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
   344