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