marking5/bf_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 02 Dec 2020 01:15:14 +0000
changeset 382 1bd800376e0c
parent 333 24bc76d97db2
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
# to make the script fail safely
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
set -euo pipefail
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
out=${1:-output}
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
     9
echo -e "" > $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    12
echo -e "Below is the feedback and provisional marks for your submission" >> $out
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
    13
echo -e "for assignment 10.  Please note all marks are provisional until" >> $out
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    14
echo -e "ratified by the assessment board -- this is not an official" >> $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    15
echo -e "results transcript." >> $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    16
echo -e "" >> $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
# marks for CW10 part 1
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
marks=$(( 0 ))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
# compilation tests
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
function scala_compile {
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    24
    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null)
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
}
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
# functional tests
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
function scala_assert {
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    30
    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
}
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
# purity test
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
function scala_vars {
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
}
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
# var, return, ListBuffer test
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
#
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    44
echo -e "bf.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
if (scala_vars bf.scala)
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
then
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
    48
  echo -e "  --> TEST FAILED\n" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  tsts0=$(( 1 ))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
else
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    51
  echo -e "  --> success" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
  tsts0=$(( 0 )) 
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
# compilation test
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
if  [ $tsts0 -eq 0 ]
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
then    
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    59
  echo -e "bf.scala runs?" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
  if (scala_compile bf.scala)
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
  then
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    63
    echo -e "  --> success" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
    tsts1=$(( 0 ))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
  else
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
    66
    echo -e "  --> SCALA DID NOT RUN bf.scala\n" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
    tsts1=$(( 1 )) 
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
  fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
else
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  tsts1=$(( 1 ))     
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
### bf1 test
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
if [ $tsts1 -eq 0 ]
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
then
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    78
  echo -e " load_bff(\"benchmark.bf\").length == 188" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    79
  echo -e " load_bff(\"foobar.bf\") == \"\"" | tee -a $out  
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
   
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
  if (scala_assert "bf.scala" "bf_test1.scala")
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
  then
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    83
      echo -e "  --> success" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
      marks=$(( marks + 1 ))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
  else
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
    86
      echo -e "  --> TEST FAILED\n" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
  fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
### bf2 test
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
if [ $tsts1 -eq 0 ]
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
then
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    95
  echo -e " sread(Map(), 2) == 0" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    96
  echo -e " sread(Map(2 -> 1), 2) == 1" | tee -a $out  
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    97
  echo -e " write(Map(), 1, 2) == Map(1 -> 2)" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
    98
  echo -e " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
  
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
  if (scala_assert "bf.scala" "bf_test2.scala")
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
  then
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   102
      echo -e "  --> success" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
      marks=$(( marks + 1 ))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
  else
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   105
      echo -e "  --> TEST FAILED\n" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
  fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
### bf3 test
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
if [ $tsts1 -eq 0 ]
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
then
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   113
    echo -e " jumpRight(\"[xxxxxx]xxx\", 1, 0) == 8" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   114
    echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   115
    echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   116
    echo -e " jumpRight(\"[xx[xxx]xxx\", 1, 0) == 11" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   117
    echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   118
    echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   119
    echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" | tee -a $out
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   120
    echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
  
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
  if (scala_assert "bf.scala" "bf_test3.scala")
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  then
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   124
      echo -e "  --> success" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
      marks=$(( marks + 2 ))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  else
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   127
      echo -e "  --> TEST FAILED\n" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
  fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
if [ $tsts1 -eq 0 ]
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
then
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
  echo -e " run(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
  echo -e " run(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
  echo -e " run(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  echo -e " run(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
  echo -e " run(hello, Map()) == " | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
  
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
  if (scala_assert "bf.scala" "bf_test4.scala")
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
  then
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   147
      echo -e "  --> success" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
      marks=$(( marks + 2 ))
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
  else
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   150
      echo -e "  --> TEST FAILED\n" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   151
  fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   152
fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   153
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   154
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   155
# var, return, ListBuffer test
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   156
#
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   157
echo "bfc.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   158
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   159
if (scala_vars bfc.scala)
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   160
then
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   161
  echo -e "  --> TEST FAILED\n" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   162
  tsts0=$(( 1 ))
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   163
else
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   164
  echo -e "  --> success" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   165
  tsts0=$(( 0 )) 
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   166
fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   167
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   168
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   169
# compilation test
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   170
if  [ $tsts0 -eq 0 ]
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   171
then    
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   172
  echo "bfc.scala runs?" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   173
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   174
  if (scala_compile bfc.scala)
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   175
  then
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   176
    echo -e "  --> success" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   177
    tsts1=$(( 0 ))
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   178
  else
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   179
    echo -e "  --> SCALA DID NOT RUN bfc.scala\n" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   180
    tsts1=$(( 1 )) 
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   181
  fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   182
else
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   183
  tsts1=$(( 1 ))     
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   184
fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   185
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   186
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   187
### bfc5 test
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   188
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   189
if [ $tsts1 -eq 0 ]
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   190
then
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   191
  echo -e " val p1 = \"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\"\"\"" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   192
  echo -e " jtable(p1) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6)" | tee -a $out  
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   193
  echo -e " val p2 = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   194
  echo -e " jtable(p2) == Map(14 -> 34, 33 -> 15, 45 -> 44, 48 -> 9, 43 -> 46, 8 -> 49)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   195
  echo -e " run2(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   196
  echo -e " run2(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   197
  echo -e " run2(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   198
  echo -e " run2(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   199
  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   200
  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   201
  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   202
  echo -e " run2(hello, Map()) == " | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   203
  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   204
  
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   205
  if (scala_assert "bfc.scala" "bf_test5.scala")
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   206
  then
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   207
      echo -e "  --> success" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   208
      marks=$(( marks + 1 ))
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   209
  else
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   210
      echo -e "  --> TEST FAILED\n" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   211
  fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   212
fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   213
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   214
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   215
### bfc6 test
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   216
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   217
if [ $tsts1 -eq 0 ]
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   218
then
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   219
  echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   220
  echo -e " optimise(load_bff(\"mandelbrot.bf\")).length == 11203" | tee -a $out  
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   221
  echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   222
  echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   223
  echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   224
  echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   225
  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   226
  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   227
  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   228
  echo -e " run3(hello, Map()) == " | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   229
  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   230
  
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   231
  if (scala_assert "bfc.scala" "bf_test6.scala")
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   232
  then
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   233
      echo -e "  --> success" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   234
      marks=$(( marks + 1 ))
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   235
  else
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   236
      echo -e "  --> TEST FAILED\n" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   237
  fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   238
fi
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   239
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   240
### bfc7 test
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   241
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   242
if [ $tsts1 -eq 0 ]
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   243
then
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   244
  echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   245
  echo -e " combine(optimise(load_bff(\"mandelbrot.bf\"))).length == 6509" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   246
  echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   247
  echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   248
  echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   249
  echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   250
  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   251
  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   252
  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   253
  echo -e " run4(hello, Map()) == " | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   254
  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   255
  
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   256
  if (scala_assert "bfc.scala" "bf_test7.scala")
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   257
  then
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   258
      echo -e "  --> success" | tee -a $out
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   259
      marks=$(( marks + 2 ))
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   260
  else
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   261
      echo -e "  --> TEST FAILED\n" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   262
  fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   263
fi
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   264
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   265
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   266
## final marks
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   267
echo -e "Overall mark for CW 10" | tee -a $out
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 253
diff changeset
   268
echo -e "$marks" | tee -a $out
253
ec7a12806c3f updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   269