main_marking5/bf_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 13 Jun 2024 13:13:33 +0100
changeset 491 e2ffe8642f55
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: 394
diff changeset
     1
#!/bin/zsh
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
# to make the script fail safely
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
set -euo pipefail
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
out=${1:-output}
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
echo -e "" > $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
echo -e `date` >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
echo -e  "" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
echo -e "Below is the feedback and provisional marks for your submission" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
echo -e "for Part 5 (Scala).  Please note all marks are provisional until" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
echo -e "ratified by the assessment board -- this is not an official" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
echo -e "results transcript." >> $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    17
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    18
#echo -e "" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    19
#echo -e "XXX needs to have own version of load_bff in the testing code" >> $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    20
#echo -e "" >> $out
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
# marks for CW10 part 1
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
    23
marks=$(( 0.0 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
# compilation tests
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    27
function scala_compile {
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    28
  (JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
}
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
# functional tests
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
function scala_assert {
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    34
  (JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
}
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
function scala_assert_thirty {
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    38
  (JAVA_OPTS="-Xmx1g" scala -nc -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
}
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
# purity test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
function scala_vars {
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
    43
   (sed 's/immutable/ok/g' c$out > cb$out;
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
    44
    egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null)
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
}
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
echo -e "" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
echo -e "Below is the feedback for your submission of bf.scala" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
echo -e "" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
# compilation test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
echo -e "bf.scala runs?" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
if (scala_compile bf.scala)
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
    echo -e "  --> success" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
    tsts=$(( 0 ))
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
else
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    61
    echo -e "  --> SCALA DID NOT RUN bf.scala\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    62
    tsts=$(( 1 )) 
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    63
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    65
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    66
# var, return, ListBuffer test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
#
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
if  [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
then   
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
    echo -e "bf.scala does not contain VARS, RETURNS etc?" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
    if (scala_vars bf.scala)   
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
    then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
	echo -e "  --> TEST FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
	tsts=$(( 1 ))
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
    else
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    77
	echo -e "  --> success\n" | tee -a $out
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
	tsts=$(( 0 )) 
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
    fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
else
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
    tsts=$(( 1 ))  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
fi    
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    85
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
### bf1 test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
  echo -e " load_bff(\"benchmark.bf\").length == 188" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
  echo -e " load_bff(\"foobar.bf\") == \"\"" | tee -a $out  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
   
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
  if (scala_assert "bf.scala" "bf_test1.scala")
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    95
      echo -e "  --> success (+ 0.5 Marks)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
    96
      marks=$(( marks + 0.5 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    97
  else
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    98
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    99
  fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   102
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
### bf2 test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
  echo -e " sread(Map(), 2) == 0" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
  echo -e " sread(Map(2 -> 1), 2) == 1" | tee -a $out  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
  echo -e " write(Map(), 1, 2) == Map(1 -> 2)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
  echo -e " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
  if (scala_assert "bf.scala" "bf_test2.scala")
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   114
      echo -e "  --> success (+ 0.5 Marks)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
   115
      marks=$(( marks + 0.5 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
  else
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
  fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
### bf3 test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
    echo -e " jumpRight(\"[xxxxxx]xxx\", 1, 0) == 8" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   126
    echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
    echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
    echo -e " jumpRight(\"[xx[xxx]xxx\", 1, 0) == 11" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
    echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
    echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
    echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
    echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   133
    START=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   134
    
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
  if (scala_assert "bf.scala" "bf_test3.scala")
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   137
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   138
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   139
      echo -e "  --> success (+ 2 Marks)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
   140
      marks=$(( marks + 2.0 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
  else
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   142
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   143
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   144
      echo -e "  This test ran for $DIFF seconds" | tee -a $out 
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
  fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
  echo -e " run(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
  echo -e " run(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
  echo -e " run(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
  echo -e " run(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
  echo -e " run(hello, Map()) == " | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   163
  START=$(date +%s)
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
  if (scala_assert "bf.scala" "bf_test4.scala")
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   167
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   168
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   169
      echo -e "  This test ran for $DIFF seconds" | tee -a $out 
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   170
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
   171
      marks=$(( marks + 1.0 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
  else
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   173
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   174
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   175
      echo -e "  This test ran for $DIFF seconds" | tee -a $out 
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
  fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   178
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   183
  echo -e " Is run fast enough?" | tee -a $out 
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
  echo -e " val bench_small = \"\"\">+[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
  echo -e "  [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
  echo -e "  ++++++++[>++++++++++[>++++++++++[>++++++++++[>+" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
  echo -e "  +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.\"\"\"" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
  echo -e " run(bench_small, Map()) == " | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
  echo -e "       Map(0 -> 10, 5 -> 0, 1 -> 0, 6 -> 0, 2 -> 0, 7 -> 0, 3 -> 0, 4 -> 0)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
  START=$(date +%s)
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
  if (scala_assert_thirty "bf.scala" "bf_test4b.scala")
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
  then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   194
      END=$(date +%s)
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   195
      DIFF=$(( $END - $START ))
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   196
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   197
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
   198
      marks=$(( marks + 1.0 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   199
  else
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   200
      END=$(date +%s)
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   201
      DIFF=$(( $END - $START ))
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   202
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   203
      echo -e "  --> TEST FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   204
  fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   205
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   206
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   207
if [ $tsts -eq 0 ]
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   208
then
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   209
  echo -e " val str = \"\"\"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]\"\"\"" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   210
  echo -e " " | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   211
  echo -e " run(generate(\"ABC\".toList)) == str" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   212
  
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   213
  if (scala_assert_thirty "bf.scala" "bf_test4c.scala")
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   214
  then
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   215
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   216
      marks=$(( marks + 1.0 ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   217
  else
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   218
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   219
      echo -e "  --> TEST FAILED\n" | tee -a $out
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   220
  fi
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   221
fi
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   222
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   223
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   224
echo -e "" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   225
echo -e "Below is the feedback for your submission of bfc.scala" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   226
echo -e "" >> $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   227
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   228
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   229
# compilation test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   230
echo "bfc.scala runs?" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   231
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   232
if (scala_compile bfc.scala)
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   233
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   234
    echo -e "  --> success" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   235
    tsts=$(( 0 ))
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   236
else
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   237
    echo -e "  --> SCALA DID NOT RUN bfc.scala\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   238
    tsts=$(( 1 )) 
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   239
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   240
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   241
# var, return, ListBuffer test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   242
#
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   243
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   244
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   245
then 
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   246
    echo "bfc.scala does not contain VARS, RETURNS etc?" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   247
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   248
    if (scala_vars bfc.scala)
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   249
    then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   250
	echo -e "  --> TEST FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   251
	tsts=$(( 1 ))
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   252
    else
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   253
	echo -e "  --> success" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   254
	tsts=$(( 0 )) 
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   255
    fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   256
else
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   257
  tsts=$(( 1 ))     
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   258
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   259
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   260
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   261
### bfc5 test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   262
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   263
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   264
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   265
  echo -e " val p1 = \"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\"\"\"" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   266
  echo -e " jtable(p1) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6)" | tee -a $out  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   267
  echo -e " val p2 = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   268
  echo -e " jtable(p2) == Map(14 -> 34, 33 -> 15, 45 -> 44, 48 -> 9, 43 -> 46, 8 -> 49)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   269
  echo -e " run2(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   270
  echo -e " run2(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   271
  echo -e " run2(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   272
  echo -e " run2(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   273
  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   274
  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   275
  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   276
  echo -e " run2(hello, Map()) == " | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   277
  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   278
  START=$(date +%s)
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   279
  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   280
  if (scala_assert "bfc.scala" "bf_test5.scala")
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   281
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   282
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   283
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   284
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   285
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
   286
      marks=$(( marks + 1.0 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   287
  else
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   288
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   289
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   290
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   291
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   292
  fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   293
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   294
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   295
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   296
### bfc6 test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   297
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   298
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   299
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   300
  echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   301
  echo -e " optimise(load_bff(\"sierpinski.bf\")).length == 110" | tee -a $out  
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   302
  echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   303
  echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   304
  echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   305
  echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   306
  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   307
  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   308
  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   309
  echo -e " run3(hello, Map()) == " | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   310
  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   311
  START=$(date +%s)
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   312
  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   313
  if (scala_assert "bfc.scala" "bf_test6.scala")
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   314
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   315
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   316
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   317
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   318
      echo -e "  --> success (+ 1 Mark)\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
   319
      marks=$(( marks + 1.0 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   320
  else
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   321
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   322
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   323
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   324
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   325
  fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   326
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   327
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   328
### bfc7 test
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   329
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   330
if [ $tsts -eq 0 ]
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   331
then
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   332
  echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   333
  echo -e " combine(optimise(load_bff(\"sierpinski.bf\"))).length == 122" | tee -a $out
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   334
  echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   335
  echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   336
  echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   337
  echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   338
  echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   339
  echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   340
  echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   341
  echo -e " run4(hello, Map()) == " | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   342
  echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   343
  START=$(date +%s)
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   344
  
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   345
  if (scala_assert "bfc.scala" "bf_test7.scala")
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   346
  then
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   347
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   348
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   349
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   350
      echo -e "  --> success (+ 2 Marks)" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
   351
      marks=$(( marks + 2.0 ))
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   352
  else
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   353
      END=$(date +%s)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   354
      DIFF=$(( $END - $START ))
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
   355
      echo -e "  This test ran for $DIFF seconds" | tee -a $out     
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   356
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   357
  fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   358
fi
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   359
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   360
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   361
## final marks
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   362
echo -e "Overall mark for Part 5 (Scala)" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 394
diff changeset
   363
printf " %0.1f\n" $marks | tee -a $out
392
97ecdc8cb61b marking 5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   364