testing3/knight_test.sh
author Christian Urban <urbanc@in.tum.de>
Mon, 27 Jan 2020 10:18:13 +0000
changeset 329 8a34b2ebc8cc
parent 296 12dc251fc47e
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
set -euo pipefail
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
out=${1:-output}
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
echo -e "" > $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
295
3f34da7a3094 updated
Christian Urban <urbanc@in.tum.de>
parents: 292
diff changeset
     8
echo -e "Below is the feedback for your submission of CW 8" >> $out
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
echo -e "" >> $out
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
    10
echo -e "!! Important: !!" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
    11
echo -e "Because of limitations with our testing infrastructure, we can only" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
    12
echo -e "let code run for 10 seconds and then have to kill it. This might" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
    13
echo -e "mean your code is correct, but still marked as Fail. Remember" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
    14
echo -e "you can test your code on your own machine and benchmark it" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
    15
echo -e "against the reference implementation." >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
    16
echo -e "" >> $out
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
# compilation tests
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
function scala_compile {
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    21
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out) 
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
}
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
# functional tests
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
function scala_assert_slow {
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    27
  (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -i "$1" "-- $2" 2> /dev/null 1> /dev/null)
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
}
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
function scala_assert_thirty {
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    31
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
}
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
function scala_assert_quick {
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
    35
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
}
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
# purity test
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
function scala_vars {
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
}
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
# knights1: purity test
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
echo -e "knight1.scala does not contain vars, returns etc?" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
if (scala_vars knight1.scala)
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
then
292
a52987bf44e1 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    51
  echo -e "  --> FAIL (make triple-sure your program conforms to the required format)" >> $out  
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
  tsts0=$(( 0 ))
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
else
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  echo -e "  --> success" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  tsts0=$(( 0 )) 
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
# compilation test
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
if [ $tsts0 -eq 0 ]
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
then    
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  echo -e "knight1.scala runs?" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
  if (scala_compile knight1.scala)
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
  then
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
    echo -e "  --> success " >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
    tsts1=$(( 0 ))
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
  else
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
    echo -e "  --> SCALA DID NOT RUN KNIGHT1.SCALA\n" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
    tsts1=$(( 1 )) 
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
else
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  tsts1=$(( 1 ))   
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
### knight1 test
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
if [ $tsts1 -eq 0 ]
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
then
295
3f34da7a3094 updated
Christian Urban <urbanc@in.tum.de>
parents: 292
diff changeset
    81
    echo -e "For testing needs to take 10 seconds or less to execute: " >> $out
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
    echo -e " is_legal(8, Nil, (3, 4)) == true " >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
    echo -e " is_legal(8, List((4, 1), (1, 0)), (4, 1)) == false " >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
    echo -e " is_legal(2, Nil, (0, 0)) == true" >> $out                          
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
    if (scala_assert_quick "knight1.scala" "knight_test1.scala")
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
    then
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
        echo -e "  --> success" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
    else
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
        echo -e "  --> \n ONE TEST FAILED\n" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
    fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
### knight2 test
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
if [ $tsts1 -eq 0 ]
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
then
295
3f34da7a3094 updated
Christian Urban <urbanc@in.tum.de>
parents: 292
diff changeset
    98
  echo -e "For testing needs to take 10 seconds or less to execute: " >> $out
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
  echo -e " legal_moves(8, Nil, (2,2)) == List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4))" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
  echo -e " legal_moves(8, Nil, (7,7)) == List((6,5), (5,6))" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
  echo -e " legal_moves(8, List((4,1), (1,0)), (2,2)) == List((3,4), (4,3), (3,0), (0,1), (0,3), (1,4))" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
  echo -e " legal_moves(8, List((6,6)), (7,7)) == List((6,5), (5,6))" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
  echo -e " legal_moves(1, Nil, (0,0)) == Nil" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
  echo -e " legal_moves(2, Nil, (0,0)) == Nil" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
  echo -e " legal_moves(3, Nil, (0,0)) == List((1,2), (2,1))" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
  
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
  if (scala_assert_quick "knight1.scala" "knight_test2.scala")
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
  then
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
    echo -e "  --> success" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
  else
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
    echo -e "  --> \n ONE TEST FAILED\n" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
  fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
### knight3 test
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
if [ $tsts1 -eq 0 ]
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
then
295
3f34da7a3094 updated
Christian Urban <urbanc@in.tum.de>
parents: 292
diff changeset
   120
  echo -e "For testing needs to take 10 seconds or less to execute: " >> $out
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
  echo -e " count_tours from every position on the board" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
  echo -e " dim = 1: 1" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  echo -e "       2: 0,0,0,0" >>  $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
  echo -e "       3: 0,0,0,0,0,0,0,0,0" >>  $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
  echo -e "       4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  #echo -e "       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" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
  echo -e " enum_tours(5, List((0,0)) ) == 304 and all correct?" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
  echo -e " enum_tours(5, List((0,1)) ) == 0" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
  echo -e " enum_tours(5, List((0,2)) ) == 56 and all correct?" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
  
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
  if (scala_assert_quick "knight1.scala" "knight_test3.scala") 
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
  then
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
    echo -e "  --> success" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
  else
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
    echo -e "  --> \n ONE TEST FAILED\n" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
  fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
### knight4 test
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
if [ $tsts1 -eq 0 ]
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
then
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   143
  echo -e "For testing needs to take 10 seconds or less to execute: " >> $out
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
  echo -e " Let f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
  echo -e "   first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
  echo -e "   first(List((1,0),(2,0),(3,0)), f) == None" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
  if (scala_assert_quick "knight1.scala" "knight_test4.scala") 
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
  then
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
    echo -e "  --> success" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
  else
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
    echo -e "  --> \n ONE TEST FAILED\n" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
  fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
### knight5 test
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
if [ $tsts1 -eq 0 ]
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
then
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   161
  echo -e "For testing needs to take 10 seconds or less to execute: " >> $out
220
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
  echo -e " is first_tour(6, List((0, 0))) ok? " >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
  echo -e " is first_tour(4, List((0, 0))) == None " >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
  if (scala_assert_quick "knight1.scala" "knight_test5.scala") 
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
  then
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
    echo -e "  --> success" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
  else
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
    echo -e "  --> \n ONE TEST FAILED\n" >> $out
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
  fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
fi
3020f8c76baa updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   173
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   174
echo -e "" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   175
echo -e "" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   176
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   177
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   178
# knights2: purity test
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   179
#
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   180
echo -e "knight2.scala does not contain vars, returns, Arrays, ListBuffers etc?" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   181
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   182
if (scala_vars knight2.scala)
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   183
then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   184
  echo -e "  --> Fail (make triple-sure your program conforms to the required format)" >> $out    
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   185
  tsts0=$(( 0 ))
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   186
else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   187
  echo -e "  --> success" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   188
  tsts0=$(( 0 )) 
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   189
fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   190
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   191
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   192
# compilation test
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   193
if  [ $tsts0 -eq 0 ]
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   194
then    
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   195
  echo -e "knight2.scala runs?" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   196
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   197
  if (scala_compile knight2.scala)
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   198
  then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   199
    echo -e "  --> success" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   200
    tsts1=$(( 0 ))
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   201
  else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   202
    echo -e "  --> SCALA DID NOT RUN KNIGHT2.SCALA\n" >> $out  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   203
    tsts1=$(( 1 )) 
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   204
  fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   205
else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   206
  tsts1=$(( 1 ))     
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   207
fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   208
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   209
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   210
# ordered move test
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   211
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   212
if [ $tsts1 -eq 0 ]
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   213
then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   214
  echo -e "For testing needs to take 10 seconds or less to execute: " >> $out  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   215
  echo -e " ordered_moves(8, List((3,4), (3,2)), (1,3)) == List((0,1), (0,5), (2,1), (2,5))" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   216
  echo -e " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   217
  echo -e " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   218
  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   219
  if (scala_assert_quick "knight2.scala" "knight_test6.scala")
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   220
  then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   221
      echo -e "  --> success" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   222
  else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   223
      echo -e "  --> \n ONE TEST FAILED\n" >> $out  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   224
  fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   225
fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   226
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   227
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   228
# first-closed-tour test
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   229
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   230
if [ $tsts1 -eq 0 ]
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   231
then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   232
  echo -e "For testing needs to take 10 seconds or less to execute: " >> $out  
329
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 296
diff changeset
   233
  echo -e " first_closed_tour_heuristics(6, List((3,3))) found and correct?" >> $out
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   234
  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   235
  if (scala_assert_quick "knight2.scala" "knight_test7.scala")
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   236
  then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   237
      echo -e "  --> success" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   238
  else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   239
      echo -e "  --> \n ONE TEST FAILED\n" >> $out  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   240
  fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   241
fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   242
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   243
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   244
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   245
if [ $tsts1 -eq 0 ]
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   246
then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   247
  echo -e "For testing needs to take 10 seconds or less to execute: " >> $out   
329
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 296
diff changeset
   248
  echo -e " first_tour_heuristics(8, List((0,0))) found and correct?" >> $out
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 296
diff changeset
   249
  echo -e " first_tour_heuristics(30, List((0,0))) found and correct?" >> $out
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   250
  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   251
  if (scala_assert_quick "knight2.scala" "knight_test8.scala")
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   252
  then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   253
      echo -e "  --> success" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   254
  else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   255
      echo -e "  --> \n ONE TEST FAILED\n" >> $out 
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   256
  fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   257
fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   258
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   259
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   260
echo -e "" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   261
echo -e "" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   262
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   263
# knights3: purity test
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   264
#
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   265
echo -e "knight3.scala does not contain vars, returns, Arrays, ListBuffers etc?" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   266
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   267
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   268
if (scala_vars knight3.scala)
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   269
then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   270
  echo "  --> Fail (make triple-sure your program conforms to the required format)xsxs" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   271
  tsts0=$(( 0 ))
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   272
else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   273
  echo "  --> success" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   274
  tsts0=$(( 0 )) 
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   275
fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   276
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   277
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   278
# compilation test
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   279
if  [ $tsts0 -eq 0 ]
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   280
then    
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   281
  echo "knight3.scala runs?" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   282
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   283
  if (scala_compile knight3.scala)
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   284
  then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   285
    echo "  --> success" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   286
    tsts1=$(( 0 ))
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   287
  else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   288
    echo -e "  --> SCALA DID NOT RUN KNIGHT3.SCALA\n" >> $out  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   289
    tsts1=$(( 1 )) 
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   290
  fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   291
else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   292
  tsts1=$(( 1 ))     
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   293
fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   294
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   295
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   296
if [ $tsts1 -eq 0 ]
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   297
then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   298
  echo -e "For testing needs to take 10 seconds or less to execute: " >> $out  
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   299
  echo -e " tour_on_mega_board(70, List((0,0))) found and correct?" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   300
  
329
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents: 296
diff changeset
   301
  if (scala_assert_slow "knight3.scala" "knight_test9.scala")
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   302
  then
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   303
      echo -e "  --> success" >> $out
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   304
  else
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   305
      echo -e "  --> \n ONE TEST FAILED\n" >> $out 
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   306
  fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   307
fi
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 295
diff changeset
   308