pre_marking4/knight1_test.sh
changeset 387 6282b88511d8
parent 386 e2170c91a9f2
equal deleted inserted replaced
386:e2170c91a9f2 387:6282b88511d8
     6 out=${1:-output}
     6 out=${1:-output}
     7 
     7 
     8 echo "" > $out
     8 echo "" > $out
     9 
     9 
    10 echo `date` >> $out
    10 echo `date` >> $out
       
    11 echo -e "" >> $out
    11 echo -e "Below is the feedback and provisional marks for your submission" >> $out
    12 echo -e "Below is the feedback and provisional marks for your submission" >> $out
    12 echo -e "of the Preliminary Part of Part 4 (Scala).  Please note all marks are provisional until" >> $out
    13 echo -e "of the Preliminary Part of Part 4 (Scala).  Please note all marks are provisional until" >> $out
    13 echo -e "ratified by the assessment board -- this is not an official" >> $out
    14 echo -e "ratified by the assessment board -- this is not an official" >> $out
    14 echo -e "results transcript." >> $out
    15 echo -e "results transcript." >> $out
    15 echo -e "" >> $out
    16 echo -e "" >> $out
    16 
    17 
       
    18 echo -e "" >> $out
    17 echo -e "Below is the feedback for your submission knight1.scala" >> $out
    19 echo -e "Below is the feedback for your submission knight1.scala" >> $out
    18 echo -e "" >> $out
    20 echo -e "" >> $out
    19 
    21 
    20 
    22 
    21 
    23 
    22 # marks for CW8 part 1
    24 # marks for CW8 part 1
    23 marks=$(( 0.0 ))
    25 marks=$(( 0.0 ))
    24 
    26 
    25 
    27 # compilation tests
    26 function scala_compile {
       
    27   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1") # 2>> $out 1>> $out) 
       
    28 }
       
    29 
       
    30 # functional tests
       
    31 
    28 
    32 function scala_compile {
    29 function scala_compile {
    33   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
    30   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
    34 }
    31 }
    35 
    32 
    42 function scala_assert_slow {
    39 function scala_assert_slow {
    43   (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
    40   (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
    44 }
    41 }
    45 
    42 
    46 function scala_assert_thirty {
    43 function scala_assert_thirty {
    47   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
    44   (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)  
    48 }
    45 }
    49 
    46 
    50 function scala_assert_quick {
    47 function scala_assert_quick {
    51   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)    
    48   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)    
    52 }
    49 }
    96   fi
    93   fi
    97 else
    94 else
    98   tsts=$(( 1 ))  
    95   tsts=$(( 1 ))  
    99 fi
    96 fi
   100 
    97 
   101 
    98 echo >> $out
   102 
    99 
   103 ### knight1 test
   100 ### knight1 test
   104 
   101 
   105 if [ $tsts -eq 0 ]
   102 if [ $tsts -eq 0 ]
   106 then
   103 then
   142 
   139 
   143 ### knight3 test
   140 ### knight3 test
   144 
   141 
   145 if [ $tsts -eq 0 ]
   142 if [ $tsts -eq 0 ]
   146 then
   143 then
   147   echo " count_tours from every position on the board 1 - 4" | tee -a $out
   144   echo " count_tours from every position on the board 1 - 4 (0.5% marks)" | tee -a $out
   148   echo " dim = 1: 1" | tee -a $out
   145   echo " dim = 1: 1" | tee -a $out
   149   echo "       2: 0,0,0,0" | tee -a $out
   146   echo "       2: 0,0,0,0" | tee -a $out
   150   echo "       3: 0,0,0,0,0,0,0,0,0" | tee -a $out
   147   echo "       3: 0,0,0,0,0,0,0,0,0" | tee -a $out
   151   echo "       4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | tee -a $out
   148   echo "       4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | tee -a $out
   152   START=$(date +%s)
   149   START=$(date +%s)
   153   
   150   
   154   if (scala_assert "knight1.scala" "knight1_test3a.scala") 
   151   if (scala_assert_thirty "knight1.scala" "knight1_test3a.scala") 
   155   then
   152   then
   156      END=$(date +%s)
   153      END=$(date +%s)
   157      DIFF=$(( $END - $START ))
   154      DIFF=$(( $END - $START ))
   158      echo " It took $DIFF seconds" | tee -a $out  
   155      #echo " This test ran for $DIFF seconds." | tee -a $out  
   159      echo -e "  --> success\n" | tee -a $out
   156      echo -e "  --> success\n" | tee -a $out
   160      marks=$(( marks + 0.5 ))
   157      marks=$(( marks + 0.5 ))
   161   else
   158   else
   162      END=$(date +%s)
   159      END=$(date +%s)
   163      DIFF=$(( $END - $START ))
   160      DIFF=$(( $END - $START ))
   164      echo " It took $DIFF seconds" | tee -a $out 
   161      echo " This test ran for $DIFF seconds." | tee -a $out 
   165      echo -e "  --> ONE TEST FAILED\n" | tee -a $out
   162      echo -e "  --> ONE TEST FAILED\n" | tee -a $out
   166   fi
   163   fi
   167 fi
   164 fi
   168 
   165 
   169 
   166 
   170 if [ $tsts -eq 0 ]
   167 
   171 then
   168 if [ $tsts -eq 0 ]
   172   echo " count_tours from every position on the board of dim 5" | tee -a $out
   169 then
   173   echo " dim = 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56,0,56,0,56,0,304,0,56,0,304" | tee -a $out
   170   echo " count_tours from every position on the board of dim 5 for the first 3 rows (0.5% marks)" | tee -a $out
       
   171   echo " dim = 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56)" | tee -a $out
   174   START=$(date +%s)
   172   START=$(date +%s)
   175   
   173   
   176   if (scala_assert "knight1.scala" "knight1_test3b.scala") 
   174   if (scala_assert_thirty "knight1.scala" "knight1_test3b.scala") 
   177   then
   175   then
   178      END=$(date +%s)
   176      END=$(date +%s)
   179      DIFF=$(( $END - $START ))
   177      DIFF=$(( $END - $START ))
   180      echo " It took $DIFF seconds" | tee -a $out  
   178      #echo " This test ran for $DIFF seconds." | tee -a $out  
   181      echo -e "  --> success\n" | tee -a $out
   179      echo -e "  --> success\n" | tee -a $out
   182      marks=$(( marks + 0.5 ))
   180      marks=$(( marks + 0.5 ))
   183   else
   181   else
   184      END=$(date +%s)
   182      END=$(date +%s)
   185      DIFF=$(( $END - $START ))
   183      DIFF=$(( $END - $START ))
   186      echo " It took $DIFF seconds" | tee -a $out 
   184      echo " This test ran for $DIFF seconds." | tee -a $out 
   187      echo -e "  --> ONE TEST FAILED\n" | tee -a $out
   185      echo -e "  --> ONE TEST FAILED\n" | tee -a $out
   188   fi
   186   fi
   189 fi
   187 fi
       
   188 
   190 
   189 
   191 
   190 
   192 if [ $tsts -eq 0 ]
   191 if [ $tsts -eq 0 ]
   193 then
   192 then
   194   echo " enum_tours(5, List((0,2)) ) => 56 tours? and all correct?" | tee -a $out
   193   echo " enum_tours(5, List((0,2)) ) => 56 tours? and all correct?" | tee -a $out
   195   echo " enum_tours(5, List((0,0)) ) => 304 tours? and all correct?" | tee -a $out
   194   echo " enum_tours(5, List((0,0)) ) => 304 tours? and all correct?" | tee -a $out
   196   START=$(date +%s)
   195   START=$(date +%s)
   197   
   196   
   198   if (scala_assert "knight1.scala" "knight1_test3c.scala") 
   197   if (scala_assert_thirty "knight1.scala" "knight1_test3c.scala") 
   199   then
   198   then
   200      END=$(date +%s)
   199      END=$(date +%s)
   201      DIFF=$(( $END - $START ))
   200      DIFF=$(( $END - $START ))
   202      echo "  It took $DIFF seconds" | tee -a $out 
   201      #echo " This test ran for $DIFF seconds." | tee -a $out 
   203      echo -e "  --> success\n" | tee -a $out
   202      echo -e "  --> success\n" | tee -a $out
   204      marks=$(( marks + 1.0 ))
   203      marks=$(( marks + 1.0 ))
   205   else
   204   else
   206      END=$(date +%s)
   205      END=$(date +%s)
   207      DIFF=$(( $END - $START ))
   206      DIFF=$(( $END - $START ))
   208      echo " It took $DIFF seconds" | tee -a $out 
   207      echo " This test ran for $DIFF seconds." | tee -a $out 
   209      echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   208      echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   210   fi
   209   fi
   211 fi
   210 fi
   212 
   211 
   213 
   212 
   214 ## final marks
   213 ## final marks
   215 echo -e "Overall mark for the Preliminary Part 4 (Scala)" | tee -a $out
   214 echo -e "Overall mark for the Preliminary Part 4 (Scala)" | tee -a $out
   216 printf " %0.1f\n" $marks | tee -a $out
   215 printf " %0.1f\n" $marks | tee -a $out
   217 
   216 
   218 
   217 
       
   218