marking3/knight2_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 08 Nov 2021 01:39:00 +0000
changeset 403 ffce7b61b446
parent 332 703c7e42bf46
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
# to make the script fail safely
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
set -euo pipefail
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
out=${1:-output}
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
echo "" > $out
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
echo "Below is the feedback and provisional marks for your submission" >> $out
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    12
echo "for core assignment 8.  Please note all marks are provisional until" >> $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
echo "ratified by the assessment board -- this is not an official" >> $out
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
echo "results transcript." >> $out
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
echo "" >> $out
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    17
# marks for core CW8
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
marks=$(( 0 ))
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
# compilation tests
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
function scala_compile {
332
703c7e42bf46 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    23
    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out)
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
}
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
# functional tests
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
function scala_assert {
332
703c7e42bf46 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    29
    (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
}
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
    32
function scala_assert_long {
332
703c7e42bf46 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    33
  (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
    34
}
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
    35
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    36
#function scala_assert_elong {
332
703c7e42bf46 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    37
#  (ulimit -t 90; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    38
#}
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
# purity test
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
function scala_vars {
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
}
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    46
# knights1: purity test
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    47
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    48
echo -e "knight1.scala does not contain vars, returns,  Arrays, ListBuffers etc?" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    49
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    50
if (scala_vars knight1.scala)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    51
then
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    52
  echo -e "  --> TEST FAILED\n" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    53
  tsts0=$(( 1 ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    54
else
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    55
  echo -e "  --> success" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    56
  tsts0=$(( 0 )) 
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    57
fi
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    58
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    59
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    60
# compilation test
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    61
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    62
if [ $tsts0 -eq 0 ]
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    63
then    
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    64
  echo -e "knight1.scala runs?" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    65
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    66
  if (scala_compile knight1.scala)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    67
  then
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    68
    echo -e "  --> success " | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    69
    tsts1=$(( 0 ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    70
  else
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    71
    echo -e "  --> SCALA DID NOT RUN knight1.scala\n" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    72
    tsts1=$(( 1 )) 
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    73
  fi
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    74
else
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    75
  tsts1=$(( 1 ))   
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    76
fi
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    77
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    78
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    79
### knight4 test
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    80
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    81
if [ $tsts1 -eq 0 ]
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    82
then
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    83
  echo -e " Let f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    84
  echo -e "   first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    85
  echo -e "   first(List((1,0),(2,0),(3,0)), f) == None" | tee -a $out  
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    86
  
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    87
  if (scala_assert "knight1.scala" "knight1_test4.scala") 
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    88
  then
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    89
      echo -e "  --> success" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    90
      marks=$(( marks + 1 ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    91
  else
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    92
      echo -e "  --> TEST FAILED\n" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    93
  fi
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    94
fi
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    95
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    96
### knight5 test
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    97
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    98
if [ $tsts1 -eq 0 ]
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
    99
then
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   100
  echo -e " is first_tour(6, List((0, 0))) ok? " | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   101
  echo -e " is first_tour(4, List((0, 0))) == None " | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   102
  START=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   103
  
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   104
  if (scala_assert_long "knight1.scala" "knight1_test5.scala") 
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   105
  then
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   106
      END=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   107
      DIFF=$(( $END - $START ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   108
      echo "  It took $DIFF seconds" | tee -a $out  
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   109
      echo -e "  --> success" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   110
      marks=$(( marks + 1 ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   111
  else
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   112
      END=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   113
      DIFF=$(( $END - $START ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   114
      echo "  It took $DIFF seconds" | tee -a $out 
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   115
      echo -e "  --> TEST FAILED\n" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   116
  fi
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   117
fi
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   118
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   119
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   121
# knights2: purity test
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
#
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   123
echo "knight2.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   126
if (scala_vars knight2.scala)
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   128
  echo -e "  --> TEST FAILED\n" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
  tsts0=$(( 1 ))
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
else
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   131
  echo -e "  --> success" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
  tsts0=$(( 0 )) 
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
# compilation test
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
if  [ $tsts0 -eq 0 ]
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
then    
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   139
  echo "knight2.scala runs?" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   141
  if (scala_compile knight2.scala)
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
  then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   143
    echo -e "  --> success" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
    tsts1=$(( 0 ))
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
  else
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   146
    echo -e "  --> SCALA DID NOT RUN knight2.scala\n" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
    tsts1=$(( 1 )) 
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
  fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
else
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
  tsts1=$(( 1 ))     
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
# ordered move test
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
if [ $tsts1 -eq 0 ]
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   157
  echo -e " ordered_moves(8, List((3,4), (3,2)), (1,3)) == List((0,1), (0,5), (2,1), (2,5))" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   158
  echo -e " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   159
  echo -e " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
  
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   161
  if (scala_assert "knight2.scala" "knight2_test6.scala")
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
  then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   163
      echo -e "  --> success" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
      marks=$(( marks + 1 ))
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
  else
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   166
      echo -e "  --> TEST FAILED\n" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
  fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
# first-closed-tour test
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
if [ $tsts1 -eq 0 ]
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   175
  echo -e " first_closed_tour_heuristics(6, List((3,3))) found and correct?" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   176
  START=$(date +%s)
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
  
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   178
  if (scala_assert "knight2.scala" "knight2_test7.scala")
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
  then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   180
      END=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   181
      DIFF=$(( $END - $START ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   182
      echo "  It took $DIFF seconds" | tee -a $out 
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   183
      echo -e "  --> success" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
      marks=$(( marks + 1 ))
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
  else
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   186
      END=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   187
      DIFF=$(( $END - $START ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   188
      echo "  It took $DIFF seconds" | tee -a $out 
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   189
      echo -e "  --> TEST FAILED\n" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
  fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   194
# first-tour test
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
if [ $tsts1 -eq 0 ]
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   198
  echo -e " first_tour_heuristics(8, List((0,0))) found and correct?" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   199
  echo -e " first_tour_heuristics(30, List((0,0))) found and correct?" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   200
  START=$(date +%s)
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
  
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   202
  if (scala_assert_long "knight2.scala" "knight2_test8.scala")
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
  then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   204
      END=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   205
      DIFF=$(( $END - $START ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   206
      echo "  It took $DIFF seconds" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   207
      echo -e "  --> success" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
      marks=$(( marks + 1 ))
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
  else
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   210
      END=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   211
      DIFF=$(( $END - $START ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   212
      echo "  It took $DIFF seconds" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   213
      echo -e "  --> TEST FAILED\n" | tee -a $out
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
  fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
fi
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   218
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   219
# knights3: purity test
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   220
#
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   221
echo -e "knight3.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   222
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   223
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   224
if (scala_vars knight3.scala)
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   225
then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   226
  echo "  --> TEST FAILED\n" | tee -a $out
259
43995ea34fe7 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   227
  tsts0=$(( 1 ))
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   228
else
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   229
  echo "  --> success" | tee -a $out
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   230
  tsts0=$(( 0 )) 
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   231
fi
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   232
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   233
# compilation test
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   234
if  [ $tsts0 -eq 0 ]
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   235
then    
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   236
  echo "knight3.scala runs?" | tee -a $out
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   237
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   238
  if (scala_compile knight3.scala)
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   239
  then
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   240
    echo "  --> success" | tee -a $out
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   241
    tsts1=$(( 0 ))
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   242
  else
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   243
    echo -e "  --> SCALA DID NOT RUN knight3.scala\n" | tee -a $out  
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   244
    tsts1=$(( 1 )) 
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   245
  fi
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   246
else
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   247
  tsts1=$(( 1 ))     
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   248
fi
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   249
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   250
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   251
if [ $tsts1 -eq 0 ]
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   252
then
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   253
  echo -e " tour_on_mega_board(70, List((0,0))) found and correct?" | tee -a $out
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   254
  START=$(date +%s)
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   255
  
332
703c7e42bf46 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
   256
  if (scala_assert_long "knight3.scala" "knight3_test9.scala")
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   257
  then
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   258
      END=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   259
      DIFF=$(( $END - $START ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   260
      echo "  It took $DIFF seconds" | tee -a $out
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   261
      echo -e "  --> success" | tee -a $out
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   262
      marks=$(( marks + 1 ))
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   263
  else
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   264
      END=$(date +%s)
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   265
      DIFF=$(( $END - $START ))
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   266
      echo "  It took $DIFF seconds" | tee -a $out
332
703c7e42bf46 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
   267
      echo -e "  --> TEST FAILED\n" | tee -a $out 
258
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   268
  fi
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   269
fi
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   270
ebe71908b13e updated
Christian Urban <urbanc@in.tum.de>
parents: 243
diff changeset
   271
243
9bb36426c781 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   272
## final marks
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   273
echo -e "" >> $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   274
echo -e "Overall mark for CW 8 Core Part" | tee -a $out
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   275
echo -e "$marks" | tee -a $out