pre_marking4/knight1_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 18 Jan 2021 22:12:39 +0000
changeset 386 e2170c91a9f2
child 387 6282b88511d8
permissions -rwxr-xr-x
added marking
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
#!/bin/zsh
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
# to make the script fail safely
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
set -euo pipefail
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
out=${1:-output}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
echo "" > $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
echo `date` >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
echo -e "Below is the feedback and provisional marks for your submission" >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
echo -e "of the Preliminary Part of Part 4 (Scala).  Please note all marks are provisional until" >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
echo -e "ratified by the assessment board -- this is not an official" >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
echo -e "results transcript." >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
echo -e "" >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
echo -e "Below is the feedback for your submission knight1.scala" >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
echo -e "" >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
# marks for CW8 part 1
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
marks=$(( 0.0 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
function scala_compile {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    27
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1") # 2>> $out 1>> $out) 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
# functional tests
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
function scala_compile {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
# functional tests
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
function scala_assert {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
function scala_assert_slow {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
  (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
function scala_assert_thirty {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
function scala_assert_quick {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)    
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
function scala_assert_long {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
  (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)    
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
function scala_assert_elong {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
  (ulimit -t 90; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    61
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    62
# purity test
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    63
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    65
function scala_vars {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    66
   (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
# compilation test
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
echo -e "knight1.scala runs?" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
if (scala_compile knight1.scala)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
    echo -e "  --> success " | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
    tsts=$(( 0 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
    echo -e "  --> SCALA DID NOT RUN KNIGHT1.SCALA\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
    tsts=$(( 1 )) 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
# knights1: purity test
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    85
if  [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
  then   
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
  echo -e "knight1.scala does not contain VARS, RETURNS etc?" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
  if (scala_vars knight1.scala)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
     echo -e "  --> FAIL\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
     tsts=$(( 1 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
     echo -e "  --> success" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    95
     tsts=$(( 0 )) 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    96
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    97
else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    98
  tsts=$(( 1 ))  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    99
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   102
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
### knight1 test
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
    echo " is_legal(8, Nil, (3, 4)) == true " | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
    echo " is_legal(8, List((4, 1), (1, 0)), (4, 1)) == false " | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
    echo " is_legal(2, Nil, (0, 0)) == true" | tee -a $out                          
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
    if (scala_assert "knight1.scala" "knight1_test1.scala")
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
    then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
        echo -e "  --> success" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
	marks=$(( marks + 1.0 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
    else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
        echo -e "  --> \n ONE TEST FAILED\n"| tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
    fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
### knight2 test
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
  echo " legal_moves(8, Nil, (2,2)) == List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4))" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
  echo " legal_moves(8, Nil, (7,7)) == List((6,5), (5,6))" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   126
  echo " legal_moves(8, List((4,1), (1,0)), (2,2)) == List((3,4), (4,3), (3,0), (0,1), (0,3), (1,4))" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
  echo " legal_moves(8, Nil, (0,1)) == List((1,3), (2,2), (2,0))" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
  echo " legal_moves(8, List((6,6)), (7,7)) == List((6,5), (5,6))" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
  echo " legal_moves(1, Nil, (0,0)) == Nil" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
  echo " legal_moves(2, Nil, (0,0)) == Nil" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
  echo " legal_moves(3, Nil, (0,0)) == List((1,2), (2,1))" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
  if (scala_assert "knight1.scala" "knight1_test2.scala")
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
     echo -e "  --> success\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
     marks=$(( marks + 1 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
     echo -e "  --> ONE TEST FAILED\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   142
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
### knight3 test
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   144
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
  echo " count_tours from every position on the board 1 - 4" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
  echo " dim = 1: 1" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
  echo "       2: 0,0,0,0" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
  echo "       3: 0,0,0,0,0,0,0,0,0" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
  echo "       4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
  START=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
  if (scala_assert "knight1.scala" "knight1_test3a.scala") 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
     DIFF=$(( $END - $START ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
     echo " It took $DIFF seconds" | tee -a $out  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
     echo -e "  --> success\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
     marks=$(( marks + 0.5 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
     DIFF=$(( $END - $START ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
     echo " It took $DIFF seconds" | tee -a $out 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
     echo -e "  --> ONE TEST FAILED\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   167
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   168
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   169
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   170
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   171
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
  echo " count_tours from every position on the board of dim 5" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   173
  echo " dim = 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56,0,56,0,56,0,304,0,56,0,304" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   174
  START=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
  if (scala_assert "knight1.scala" "knight1_test3b.scala") 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   178
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
     DIFF=$(( $END - $START ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
     echo " It took $DIFF seconds" | tee -a $out  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
     echo -e "  --> success\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
     marks=$(( marks + 0.5 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   183
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
     DIFF=$(( $END - $START ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
     echo " It took $DIFF seconds" | tee -a $out 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
     echo -e "  --> ONE TEST FAILED\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   194
  echo " enum_tours(5, List((0,2)) ) => 56 tours? and all correct?" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   195
  echo " enum_tours(5, List((0,0)) ) => 304 tours? and all correct?" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   196
  START=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   197
  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   198
  if (scala_assert "knight1.scala" "knight1_test3c.scala") 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   199
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   200
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   201
     DIFF=$(( $END - $START ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   202
     echo "  It took $DIFF seconds" | tee -a $out 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   203
     echo -e "  --> success\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   204
     marks=$(( marks + 1.0 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   205
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   206
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   207
     DIFF=$(( $END - $START ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   208
     echo " It took $DIFF seconds" | tee -a $out 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   209
     echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   210
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   211
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   212
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   213
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   214
## final marks
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   215
echo -e "Overall mark for the Preliminary Part 4 (Scala)" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   216
printf " %0.1f\n" $marks | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   217
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   218