testing3/knight2_test.sh
changeset 248 1616d06a0893
parent 247 50a3b874008a
child 249 1997cfcd6334
equal deleted inserted replaced
247:50a3b874008a 248:1616d06a0893
     6 
     6 
     7 out=${1:-output}
     7 out=${1:-output}
     8 
     8 
     9 echo "" > $out
     9 echo "" > $out
    10 
    10 
    11 echo "Below is the feedback and provisional marks for your submission" >> $out
    11 echo -e "Below is the feedback for your submission of CW 8, Advanced Part 2." >> $out
    12 echo "for assignment 8 Part 2.  Please note all marks are provisional until" >> $out
    12 echo -e "" >> $out
    13 echo "ratified by the assessment board -- this is not an official" >> $out
       
    14 echo "results transcript." >> $out
       
    15 echo "" >> $out
       
    16 
    13 
    17 # marks for CW8 part 2
    14 
    18 marks=$(( 0 ))
       
    19 
    15 
    20 # compilation tests
    16 # compilation tests
    21 
    17 
    22 function scala_compile {
    18 function scala_compile {
    23   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2>> $out 1>> $out) 
    19   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2>> $out 1>> $out) 
    28 
    24 
    29 function scala_assert {
    25 function scala_assert {
    30   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "") #2> /dev/null 1> /dev/null)
    26   (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "") #2> /dev/null 1> /dev/null)
    31 }
    27 }
    32 
    28 
    33 function scala_assert_slow {
       
    34   (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
       
    35 }
       
    36 
       
    37 
    29 
    38 
    30 
    39 # purity test
    31 # purity test
    40 
    32 
    41 function scala_vars {
    33 function scala_vars {
    43 }
    35 }
    44 
    36 
    45 
    37 
    46 # knights2: purity test
    38 # knights2: purity test
    47 #
    39 #
    48 echo -e "knight2.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
    40 echo -e "knight2.scala does not contain vars, returns, Arrays, ListBuffers etc?" >> $out
    49 
    41 
    50 
    42 
    51 if (scala_vars knight2.scala)
    43 if (scala_vars knight2.scala)
    52 then
    44 then
    53   echo -e "  --> test failed" | tee -a $out
    45   echo -e "  --> fail (make triple-sure your program conforms to the required format)" >> $out    
    54   tsts0=$(( 0 ))
    46   tsts0=$(( 0 ))
    55 else
    47 else
    56   echo -e "  --> success" | tee -a $out
    48   echo -e "  --> success" >> $out
    57   tsts0=$(( 0 )) 
    49   tsts0=$(( 0 )) 
    58 fi
    50 fi
    59 
    51 
    60 
    52 
    61 # compilation test
    53 # compilation test
    62 if  [ $tsts0 -eq 0 ]
    54 if  [ $tsts0 -eq 0 ]
    63 then    
    55 then    
    64   echo -e "knight2.scala runs?" | tee -a $out
    56   echo -e "knight2.scala runs?" >> $out
    65 
    57 
    66   if (scala_compile knight2.scala)
    58   if (scala_compile knight2.scala)
    67   then
    59   then
    68     echo -e "  --> success" | tee -a $out
    60     echo -e "  --> success" >> $out
    69     tsts1=$(( 0 ))
    61     tsts1=$(( 0 ))
    70   else
    62   else
    71     echo -e "  --> SCALA DID NOT RUN KNIGHT2.SCALA\n" >> $out  
    63     echo -e "  --> SCALA DID NOT RUN KNIGHT2.SCALA\n" >> $out  
    72     tsts1=$(( 1 )) 
    64     tsts1=$(( 1 )) 
    73   fi
    65   fi
    77 
    69 
    78 # ordered move test
    70 # ordered move test
    79 
    71 
    80 if [ $tsts1 -eq 0 ]
    72 if [ $tsts1 -eq 0 ]
    81 then
    73 then
    82   echo -e " ordered_moves(8, List((3,4), (3,2)), (1,3)) == List((0,1), (0,5), (2,1), (2,5))" | tee -a $out
    74   echo -e " ordered_moves(8, List((3,4), (3,2)), (1,3)) == List((0,1), (0,5), (2,1), (2,5))" >> $out
    83   echo -e " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" | tee -a $out
    75   echo -e " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" >> $out
    84   echo -e " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" | tee -a $out
    76   echo -e " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" >> $out
    85   
    77   
    86   if (scala_assert "knight2.scala" "knight_test6.scala")
    78   if (scala_assert "knight2.scala" "knight_test6.scala")
    87   then
    79   then
    88       echo -e "  --> success" | tee -a $out
    80       echo -e "  --> success" >> $out
    89       marks=$(( marks + 1 ))
       
    90   else
    81   else
    91       echo -e "  --> \n ONE TEST FAILED\n" >> $out  
    82       echo -e "  --> \n ONE TEST FAILED\n" >> $out  
    92   fi
    83   fi
    93 fi
    84 fi
    94 
    85 
    95 
    86 
    96 # first-closed-tour test
    87 # first-closed-tour test
    97 
    88 
    98 if [ $tsts1 -eq 0 ]
    89 if [ $tsts1 -eq 0 ]
    99 then
    90 then
   100   echo -e " first_closed_tour_heuristic(6, List((3,3))) found and correct?" | tee -a $out
    91   echo -e " first_closed_tour_heuristic(6, List((3,3))) found and correct?" >> $out
   101   
    92   
   102   if (scala_assert "knight2.scala" "knight_test7.scala")
    93   if (scala_assert "knight2.scala" "knight_test7.scala")
   103   then
    94   then
   104       echo -e "  --> success" | tee -a $out
    95       echo -e "  --> success" >> $out
   105       marks=$(( marks + 1 ))
       
   106   else
    96   else
   107       echo -e "  --> \n ONE TEST FAILED\n" >> $out  
    97       echo -e "  --> \n ONE TEST FAILED\n" >> $out  
   108   fi
    98   fi
   109 fi
    99 fi
   110 
   100 
   111 
   101 
   112 
   102 
   113 if [ $tsts1 -eq 0 ]
   103 if [ $tsts1 -eq 0 ]
   114 then
   104 then
   115   echo -e " first_tour_heuristic(8, List((0,0))) found and correct?" | tee -a $out
   105   echo -e " first_tour_heuristic(8, List((0,0))) found and correct?" >> $out
   116   echo -e " first_tour_heuristic(30, List((0,0))) found and correct?" | tee -a $out
   106   echo -e " first_tour_heuristic(30, List((0,0))) found and correct?" >> $out
   117   
   107   
   118   if (scala_assert "knight2.scala" "knight_test8.scala")
   108   if (scala_assert "knight2.scala" "knight_test8.scala")
   119   then
   109   then
   120       echo -e "  --> success" | tee -a $out
   110       echo -e "  --> success" >> $out
   121       marks=$(( marks + 1 ))
       
   122   else
   111   else
   123       echo -e "  --> \n ONE TEST FAILED\n" >> $out 
   112       echo -e "  --> \n ONE TEST FAILED\n" >> $out 
   124   fi
   113   fi
   125 fi
   114 fi
   126 
   115 
   127 
   116 
   128 # knights3: purity test
   117 # knights3: purity test
   129 #
   118 #
   130 echo -e "knight3.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
   119 echo -e "knight3.scala does not contain vars, returns, Arrays, ListBuffers etc?" >> $out
   131 
   120 
   132 
   121 
   133 if (scala_vars knight3.scala)
   122 if (scala_vars knight3.scala)
   134 then
   123 then
   135   echo "  --> test failed" | tee -a $out
   124   echo "  --> test failed" >> $out
   136   tsts0=$(( 0 ))
   125   tsts0=$(( 0 ))
   137 else
   126 else
   138   echo "  --> success" | tee -a $out
   127   echo "  --> success" >> $out
   139   tsts0=$(( 0 )) 
   128   tsts0=$(( 0 )) 
   140 fi
   129 fi
   141 
   130 
   142 
   131 
   143 # compilation test
   132 # compilation test
   144 if  [ $tsts0 -eq 0 ]
   133 if  [ $tsts0 -eq 0 ]
   145 then    
   134 then    
   146   echo "knight3.scala runs?" | tee -a $out
   135   echo "knight3.scala runs?" >> $out
   147 
   136 
   148   if (scala_compile knight3.scala)
   137   if (scala_compile knight3.scala)
   149   then
   138   then
   150     echo "  --> success" | tee -a $out
   139     echo "  --> success" >> $out
   151     tsts1=$(( 0 ))
   140     tsts1=$(( 0 ))
   152   else
   141   else
   153     echo -e "  --> SCALA DID NOT RUN KNIGHT3.SCALA\n" >> $out  
   142     echo -e "  --> SCALA DID NOT RUN KNIGHT3.SCALA\n" >> $out  
   154     tsts1=$(( 1 )) 
   143     tsts1=$(( 1 )) 
   155   fi
   144   fi
   158 fi
   147 fi
   159 
   148 
   160 
   149 
   161 if [ $tsts1 -eq 0 ]
   150 if [ $tsts1 -eq 0 ]
   162 then
   151 then
   163   echo -e " tour_on_mega_board(70, List((0,0))) found and correct?" | tee -a $out
   152   echo -e " tour_on_mega_board(70, List((0,0))) found and correct?" >> $out
   164   
   153   
   165   if (scala_assert "knight3.scala" "knight_test9.scala")
   154   if (scala_assert "knight3.scala" "knight_test9.scala")
   166   then
   155   then
   167       echo -e "  --> success" | tee -a $out
   156       echo -e "  --> success" >> $out
   168       marks=$(( marks + 1 ))
       
   169   else
   157   else
   170       echo -e "  --> \n ONE TEST FAILED\n" >> $out 
   158       echo -e "  --> \n ONE TEST FAILED\n" >> $out 
   171   fi
   159   fi
   172 fi
   160 fi
   173 
   161 
   174 
       
   175 ## final marks
       
   176 echo "Overall mark for CW 8, Part 2" | tee -a $out
       
   177 echo "$marks" | tee -a $out