main_marking4/knight_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 02 Nov 2022 21:49:42 +0000
changeset 430 274c865b3878
parent 424 daf561a83ba6
child 463 0315d9983cd0
permissions -rwxr-xr-x
updated
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
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
    11
echo -e "" >> $out
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
echo -e "Below is the feedback and provisional marks for your submission" >> $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
    13
echo -e "of the Main Part 4 (Scala).  Please note all marks are provisional until" >> $out
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
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
    15
echo -e "results transcript." >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
echo -e "" >> $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
    18
echo -e "" >> $out
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
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
    20
echo -e "" >> $out
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
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
# marks for CW8 part 1
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
marks=$(( 0.0 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
    27
# compilation tests
386
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
function scala_compile {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
  (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
    31
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
# functional tests
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
function scala_assert {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
  (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
    37
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
function scala_assert_slow {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
  (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
    41
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
function scala_assert_thirty {
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
    44
  (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
386
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
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
function scala_assert_quick {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
  (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
    49
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
function scala_assert_long {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
  (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
    53
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
function scala_assert_elong {
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
  (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
    57
}
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
# purity test
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
    60
function scala_vars {
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
    61
   (sed 's/immutable/ok/g' c$out > cb$out;
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
    62
    egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
    63
}
386
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
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    66
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
# compilation test
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
echo -e "knight1.scala runs?" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
if (scala_compile knight1.scala)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
    echo -e "  --> success " | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
    tsts=$(( 0 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
    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
    77
    tsts=$(( 1 )) 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
# knights1: purity test
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
if  [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
  then   
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
  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
    85
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
  if (scala_vars knight1.scala)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
     echo -e "  --> FAIL\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
     tsts=$(( 1 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
     echo -e "  --> success" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
     tsts=$(( 0 )) 
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    95
  tsts=$(( 1 ))  
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
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
    98
echo >> $out
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    99
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
### knight1 test
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
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
    echo " is_legal(8, Nil, (3, 4)) == true " | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
    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
   106
    echo " is_legal(2, Nil, (0, 0)) == true" | tee -a $out                          
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
    if (scala_assert "knight1.scala" "knight1_test1.scala")
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
    then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
        echo -e "  --> success" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
	marks=$(( marks + 1.0 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
    else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
        echo -e "  --> \n ONE TEST FAILED\n"| tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
    fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
### knight2 test
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
  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
   122
  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
   123
  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
   124
  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
   125
  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
   126
  echo " legal_moves(1, Nil, (0,0)) == Nil" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
  echo " legal_moves(2, Nil, (0,0)) == Nil" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
  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
   129
  
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
  if (scala_assert "knight1.scala" "knight1_test2.scala")
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
     echo -e "  --> success\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
     marks=$(( marks + 1 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
     echo -e "  --> ONE TEST FAILED\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
### knight3 test
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
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
then
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   144
  echo " count_tours from every position on the board 1 - 4 (0.5% marks)" | tee -a $out
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
  echo " dim = 1: 1" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
  echo "       2: 0,0,0,0" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
  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
   148
  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
   149
  START=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
  
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   151
  if (scala_assert_thirty "knight1.scala" "knight1_test3a.scala") 
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
     DIFF=$(( $END - $START ))
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   155
     #echo " This test ran for $DIFF seconds." | tee -a $out  
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
     echo -e "  --> success\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
     marks=$(( marks + 0.5 ))
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
     DIFF=$(( $END - $START ))
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   161
     echo " This test ran for $DIFF seconds." | tee -a $out 
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
     echo -e "  --> ONE TEST FAILED\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   167
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   168
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   169
then
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   170
  echo " count_tours from every position on the board of dim 5 for the first 3 rows (0.25% marks)" | tee -a $out
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   171
  echo " dim = 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56)" | tee -a $out
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
  START=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   173
  
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   174
  if (scala_assert_thirty "knight1.scala" "knight1_test3b.scala") 
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
  then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
     DIFF=$(( $END - $START ))
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   178
     #echo " This test ran for $DIFF seconds." | tee -a $out  
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
     echo -e "  --> success\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   180
     marks=$(( marks + 0.25 ))
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
  else
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
     END=$(date +%s)
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   183
     DIFF=$(( $END - $START ))
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   184
     echo " This test ran for $DIFF seconds." | tee -a $out 
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
     echo -e "  --> ONE TEST FAILED\n" | tee -a $out
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
  fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
fi
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   190
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
if [ $tsts -eq 0 ]
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
then
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
  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
   194
  echo " enum_tours(5, List((0,0)) ) => 304 tours? and all correct?" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   195
  echo " (0.25% marks) " | tee -a $out
386
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
  
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   198
  if (scala_assert_thirty "knight1.scala" "knight1_test3c.scala") 
386
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 ))
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   202
     #echo " This test ran for $DIFF seconds." | tee -a $out 
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   203
     echo -e "  --> success\n" | tee -a $out
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   204
     marks=$(( marks + 0.25 ))
386
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 ))
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   208
     echo " This test ran for $DIFF seconds." | tee -a $out 
386
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
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   214
### knight4 test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   215
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   216
if [ $tsts -eq 0 ]
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   217
then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   218
  echo -e " Let f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   219
  echo -e "   first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   220
  echo -e "   first(List((1,0),(2,0),(3,0)), f) == None" | tee -a $out  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   221
  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   222
  if (scala_assert "knight1.scala" "knight1_test4.scala") 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   223
  then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   224
      echo -e "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   225
      marks=$(( marks + 1.0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   226
  else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   227
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   228
  fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   229
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   230
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   231
### knight5 test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   232
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   233
if [ $tsts -eq 0 ]
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   234
then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   235
  echo -e " is first_tour(6, List((0,0))) ok? " | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   236
  echo -e " is first_tour(4, List((0,0))) == None " | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   237
  START=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   238
  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   239
  if (scala_assert_thirty "knight1.scala" "knight1_test5.scala") 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   240
  then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   241
      END=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   242
      DIFF=$(( $END - $START ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   243
      echo -e "  This test ran for $DIFF seconds" | tee -a $out  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   244
      echo -e "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   245
      marks=$(( marks + 1.0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   246
  else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   247
      END=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   248
      DIFF=$(( $END - $START ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   249
      echo -e "  This test ran for $DIFF seconds" | tee -a $out 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   250
      echo -e "  --> TEST FAILED\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   251
  fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   252
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   253
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   254
echo -e "" >> $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   255
echo -e  "Below is the feedback for your submission knight2.scala" >> $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   256
echo -e  "" >> $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   257
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   258
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   259
# knights2: compilation test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   260
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   261
echo "knight2.scala runs?" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   262
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   263
if (scala_compile knight2.scala)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   264
then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   265
    echo -e "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   266
    tsts=$(( 0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   267
else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   268
    echo -e "  --> SCALA DID NOT RUN knight2.scala\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   269
    tsts=$(( 1 )) 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   270
fi
386
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   271
e2170c91a9f2 added marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   272
387
6282b88511d8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 386
diff changeset
   273
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   274
# knights2: purity test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   275
#
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   276
if [ $tsts -eq 0 ]
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   277
then 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   278
    echo "knight2.scala does not VARS, RETURNS etc?" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   279
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   280
    if (scala_vars knight2.scala)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   281
    then   
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   282
	echo -e "  --> TEST FAILED\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   283
	tsts=$(( 1 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   284
    else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   285
	echo -e "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   286
	tsts=$(( 0 )) 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   287
    fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   288
else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   289
    tsts=$(( 1 ))  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   290
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   291
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   292
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   293
# ordered move test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   294
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   295
if [ $tsts -eq 0 ]
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   296
then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   297
  echo -e " ordered_moves(8, List((3,4), (3,2)), (1,3)) == List((0,1), (0,5), (2,1), (2,5))" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   298
  echo -e " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   299
  echo -e " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   300
  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   301
  if (scala_assert "knight2.scala" "knight2_test6.scala")
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   302
  then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   303
      echo -e "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   304
      marks=$(( marks + 1.0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   305
  else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   306
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   307
  fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   308
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   309
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   310
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   311
# first-closed-tour test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   312
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   313
if [ $tsts -eq 0 ]
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   314
then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   315
  echo -e " first_closed_tour_heuristics(6, List((3,3))) found and correct?" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   316
  START=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   317
  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   318
  if (scala_assert_thirty "knight2.scala" "knight2_test7.scala")
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   319
  then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   320
      END=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   321
      DIFF=$(( $END - $START ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   322
      echo -e "  This test ran for $DIFF seconds" | tee -a $out 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   323
      echo -e "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   324
      marks=$(( marks + 1.0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   325
  else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   326
      END=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   327
      DIFF=$(( $END - $START ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   328
      echo -e "  This test ran for $DIFF seconds." | tee -a $out 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   329
      echo -e "  --> TEST FAILED\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   330
  fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   331
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   332
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   333
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   334
# first-tour test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   335
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   336
if [ $tsts -eq 0 ]
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   337
then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   338
  echo -e " first_tour_heuristics(8, List((0,0))) found and correct?" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   339
  echo -e " first_tour_heuristics(30, List((0,0))) found and correct?" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   340
  START=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   341
  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   342
  if (scala_assert_thirty "knight2.scala" "knight2_test8.scala")
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   343
  then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   344
      END=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   345
      DIFF=$(( $END - $START ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   346
      echo "  This test ran for $DIFF seconds" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   347
      echo -e "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   348
      marks=$(( marks + 1.0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   349
  else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   350
      END=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   351
      DIFF=$(( $END - $START ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   352
      echo "  This test ran for $DIFF seconds." | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   353
      echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   354
  fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   355
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   356
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   357
echo -e "" >> $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   358
echo -e  "Below is the feedback for your submission knight3.scala" >> $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   359
echo -e  "" >> $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   360
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   361
# compilation test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   362
echo "knight3.scala runs?" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   363
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   364
if (scala_compile knight3.scala)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   365
then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   366
    echo "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   367
    tsts=$(( 0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   368
else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   369
    echo -e "  --> SCALA DID NOT RUN knight3.scala\n" | tee -a $out  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   370
    tsts=$(( 1 )) 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   371
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   372
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   373
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   374
# knights3: purity test
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   375
#
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   376
if [ $tsts -eq 0 ]
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   377
then 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   378
    echo -e "knight3.scala does not contain VARS, RETURNS etc?" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   379
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   380
    if (scala_vars knight3.scala)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   381
    then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   382
	echo "  --> TEST FAILED\n" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   383
	tsts=$(( 1 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   384
    else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   385
	echo "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   386
	tsts=$(( 0 )) 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   387
    fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   388
else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   389
    tsts=$(( 1 ))  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   390
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   391
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   392
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   393
if [ $tsts -eq 0 ]
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   394
then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   395
  echo -e " tour_on_mega_board(70, List((0,0))) found and correct?" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   396
  START=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   397
  
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   398
  if (scala_assert_thirty "knight3.scala" "knight3_test9.scala")
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   399
  then
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   400
      END=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   401
      DIFF=$(( $END - $START ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   402
      echo -e "  This test ran for $DIFF seconds." | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   403
      echo -e "  --> success" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   404
      marks=$(( marks + 1.0 ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   405
  else
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   406
      END=$(date +%s)
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   407
      DIFF=$(( $END - $START ))
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   408
      echo -e "  This test ran for $DIFF seconds." | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   409
      echo -e "  --> TEST FAILED\n" | tee -a $out 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   410
  fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   411
fi
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   412
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   413
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   414
## final marks
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   415
echo -e "" >> $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   416
echo -e "Overall mark for Main Part 4 (Scala)" | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   417
printf " %0.2f\n" $marks | tee -a $out
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   418
Christian Urban <christian.urban@kcl.ac.uk>
parents: 387
diff changeset
   419