Attic/marking2/knight1_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 08 Nov 2021 00:17:50 +0000
changeset 400 e48ea8300b2d
parent 331 e3878cdd38bc
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
162
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
# to make the script fail safely
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
set -euo pipefail
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
out=${1:-output}
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
echo "" > $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
echo "Below is the feedback and provisional marks for your submission" >> $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
echo "for assignment 7 Part 1.  Please note all marks are provisional until" >> $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
echo "ratified by the assessment board -- this is not an official" >> $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
echo "results transcript." >> $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
echo "" >> $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
echo "Below is the feedback for your submission of CW 7, Part 1." >> $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
echo "" >> $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
# marks for CW7 part 1
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
marks=$(( 0 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 162
diff changeset
    24
# compilation tests (used to be 30 secs)
162
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
function scala_compile {
166
780c40aaad27 updated
Christian Urban <urbanc@in.tum.de>
parents: 162
diff changeset
    27
  (ulimit -t 360; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null) 
162
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
}
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
# functional tests
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
function scala_assert {
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
  (ulimit -t 360; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
}
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
# purity test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
function scala_vars {
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
}
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
# knights1: purity test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
echo "knight1.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
if (scala_vars knight1.scala)
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  echo "  --> fail" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
  tsts0=$(( 1 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
  echo "  --> success" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
  tsts0=$(( 0 )) 
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
# compilation test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
if [ $tsts0 -eq 0 ]
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
then    
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
  echo "knight1.scala runs?" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  if (scala_compile knight1.scala)
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
  then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
    echo "  --> success " | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
    tsts1=$(( 0 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
  else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
    echo "  --> scala did not run knight1.scala" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
    tsts1=$(( 1 )) 
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  tsts1=$(( 1 ))   
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
### knight1a test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
if [ $tsts1 -eq 0 ]
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
    echo " is_legal(8, Nil)(3, 4) == true " | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
    echo " is_legal(8, List((4, 1), (1, 0)))(4, 1) == false " | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
    echo " is_legal(2, Nil)(0, 0) == true" | tee -a $out                          
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
    if (scala_assert "knight1.scala" "knight1a_test.scala")
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
    then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
        echo "  --> success" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
	marks=$(( marks + 1 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
    else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
        echo "  --> test failed" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
    fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
### knight1b test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
if [ $tsts1 -eq 0 ]
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
  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
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
  echo " legal_moves(8, Nil, (7,7)) == List((6,5), (5,6))" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
  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
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
  echo " legal_moves(8, List((6,6)), (7,7)) == List((6,5), (5,6))" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
  echo " legal_moves(1, Nil, (0,0)) == Nil" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
  echo " legal_moves(2, Nil, (0,0)) == Nil" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
  echo " legal_moves(3, Nil, (0,0)) == List((1,2), (2,1))" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
  
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
  if (scala_assert "knight1.scala" "knight1b_test.scala")
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
  then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
     echo "  --> success" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
     marks=$(( marks + 1 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
  else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
    echo "  --> test failed" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
  fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
### knight1c test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
if [ $tsts1 -eq 0 ]
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
  echo " all_tours from every position on the board" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
  echo " dim = 1: 1" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
  echo "       2: 0,0,0,0" >>  $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
  echo "       3: 0,0,0,0,0,0,0,0,0" >>  $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
  echo "       4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  echo "       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
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
  echo " enum_tours(5, List((0,2)) ) => 56 tours? and all correct?" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
  
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  if (scala_assert "knight1.scala" "knight1c_test.scala") 
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
  then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
     echo "  --> success" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
     marks=$(( marks + 2 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
  else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
    echo "  --> test failed" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
  fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
# knights2: var test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
echo "knight2.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
if (scala_vars knight2.scala)
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
  echo "  --> fail" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
  tsts0=$(( 1 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
  echo "  --> success" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
  tsts0=$(( 0 )) 
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
# compilation test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
if  [ $tsts0 -eq 0 ]
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
then    
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
  echo "knight2.scala runs?" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
  if (scala_compile knight2.scala)
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
  then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
    echo "  --> success" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
    tsts1=$(( 0 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
  else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
    echo "  --> scala did not run knight2.scala" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
    tsts1=$(( 1 )) 
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
  fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
  tsts1=$(( 1 ))     
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
### knight2a test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
if [ $tsts1 -eq 0 ]
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
  echo " val f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
  echo "   first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
  echo "   first(List((1,0),(2,0),(3,0)), f) == None" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
  if (scala_assert "knight2.scala" "knight2a_test.scala") 
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
  then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
    echo "  --> success" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
    marks=$(( marks + 1 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
  else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
    echo "  --> test failed" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   181
  fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
### knight2b test
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
if [ $tsts1 -eq 0 ]
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
  echo " is first_tour(8, List((0, 0))) ok? " | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
  echo " is first_tour(4, List((0, 0))) == None " | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
  if (scala_assert "knight2.scala" "knight2b_test.scala") 
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
  then
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
     echo "  --> success" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
     marks=$(( marks + 2 ))
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
  else
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
    echo "  --> test failed" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
  fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
fi
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
## final marks
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
echo "Overall mark for Part 1" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
echo "$marks" | tee -a $out
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
6d25ccbb3cf2 marking 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206