|     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 |