marking5/bf_test.sh
changeset 333 24bc76d97db2
parent 286 5c57c407e27b
equal deleted inserted replaced
332:703c7e42bf46 333:24bc76d97db2
     8 
     8 
     9 echo -e "" > $out
     9 echo -e "" > $out
    10 
    10 
    11 
    11 
    12 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
    13 echo -e "for assignment 10 Part 1.  Please note all marks are provisional until" >> $out
    13 echo -e "for assignment 10.  Please note all marks are provisional until" >> $out
    14 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
    15 echo -e "results transcript." >> $out
    15 echo -e "results transcript." >> $out
    16 echo -e "" >> $out
    16 echo -e "" >> $out
    17 
    17 
    18 # marks for CW10 part 1
    18 # marks for CW10 part 1
    43 #
    43 #
    44 echo -e "bf.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
    44 echo -e "bf.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
    45 
    45 
    46 if (scala_vars bf.scala)
    46 if (scala_vars bf.scala)
    47 then
    47 then
    48   echo -e "  --> FAIL (make triple-sure your program conforms to the required format)" | tee -a $out
    48   echo -e "  --> TEST FAILED\n" | tee -a $out
    49   tsts0=$(( 1 ))
    49   tsts0=$(( 1 ))
    50 else
    50 else
    51   echo -e "  --> success" | tee -a $out
    51   echo -e "  --> success" | tee -a $out
    52   tsts0=$(( 0 )) 
    52   tsts0=$(( 0 )) 
    53 fi
    53 fi
    61   if (scala_compile bf.scala)
    61   if (scala_compile bf.scala)
    62   then
    62   then
    63     echo -e "  --> success" | tee -a $out
    63     echo -e "  --> success" | tee -a $out
    64     tsts1=$(( 0 ))
    64     tsts1=$(( 0 ))
    65   else
    65   else
    66     echo -e "  --> SCALA DID NOT RUN BF.SCALA\n" | tee -a $out
    66     echo -e "  --> SCALA DID NOT RUN bf.scala\n" | tee -a $out
    67     tsts1=$(( 1 )) 
    67     tsts1=$(( 1 )) 
    68   fi
    68   fi
    69 else
    69 else
    70   tsts1=$(( 1 ))     
    70   tsts1=$(( 1 ))     
    71 fi
    71 fi
    81   if (scala_assert "bf.scala" "bf_test1.scala")
    81   if (scala_assert "bf.scala" "bf_test1.scala")
    82   then
    82   then
    83       echo -e "  --> success" | tee -a $out
    83       echo -e "  --> success" | tee -a $out
    84       marks=$(( marks + 1 ))
    84       marks=$(( marks + 1 ))
    85   else
    85   else
    86       echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
    86       echo -e "  --> TEST FAILED\n" | tee -a $out
    87   fi
    87   fi
    88 fi
    88 fi
    89 
    89 
    90 
    90 
    91 ### bf2 test
    91 ### bf2 test
   100   if (scala_assert "bf.scala" "bf_test2.scala")
   100   if (scala_assert "bf.scala" "bf_test2.scala")
   101   then
   101   then
   102       echo -e "  --> success" | tee -a $out
   102       echo -e "  --> success" | tee -a $out
   103       marks=$(( marks + 1 ))
   103       marks=$(( marks + 1 ))
   104   else
   104   else
   105       echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   105       echo -e "  --> TEST FAILED\n" | tee -a $out
   106   fi
   106   fi
   107 fi
   107 fi
   108 
   108 
   109 ### bf3 test
   109 ### bf3 test
   110 
   110 
   122   if (scala_assert "bf.scala" "bf_test3.scala")
   122   if (scala_assert "bf.scala" "bf_test3.scala")
   123   then
   123   then
   124       echo -e "  --> success" | tee -a $out
   124       echo -e "  --> success" | tee -a $out
   125       marks=$(( marks + 2 ))
   125       marks=$(( marks + 2 ))
   126   else
   126   else
   127       echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   127       echo -e "  --> TEST FAILED\n" | tee -a $out
   128   fi
   128   fi
   129 fi
   129 fi
   130 
   130 
   131 
   131 
   132 
   132 
   145   if (scala_assert "bf.scala" "bf_test4.scala")
   145   if (scala_assert "bf.scala" "bf_test4.scala")
   146   then
   146   then
   147       echo -e "  --> success" | tee -a $out
   147       echo -e "  --> success" | tee -a $out
   148       marks=$(( marks + 2 ))
   148       marks=$(( marks + 2 ))
   149   else
   149   else
   150       echo -e "  --> \n ONE TEST FAILED\n" | tee -a $out
   150       echo -e "  --> TEST FAILED\n" | tee -a $out
       
   151   fi
       
   152 fi
       
   153 
       
   154 
       
   155 # var, return, ListBuffer test
       
   156 #
       
   157 echo "bfc.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
       
   158 
       
   159 if (scala_vars bfc.scala)
       
   160 then
       
   161   echo -e "  --> TEST FAILED\n" | tee -a $out
       
   162   tsts0=$(( 1 ))
       
   163 else
       
   164   echo -e "  --> success" | tee -a $out
       
   165   tsts0=$(( 0 )) 
       
   166 fi
       
   167 
       
   168 
       
   169 # compilation test
       
   170 if  [ $tsts0 -eq 0 ]
       
   171 then    
       
   172   echo "bfc.scala runs?" | tee -a $out
       
   173 
       
   174   if (scala_compile bfc.scala)
       
   175   then
       
   176     echo -e "  --> success" | tee -a $out
       
   177     tsts1=$(( 0 ))
       
   178   else
       
   179     echo -e "  --> SCALA DID NOT RUN bfc.scala\n" | tee -a $out
       
   180     tsts1=$(( 1 )) 
       
   181   fi
       
   182 else
       
   183   tsts1=$(( 1 ))     
       
   184 fi
       
   185 
       
   186 
       
   187 ### bfc5 test
       
   188 
       
   189 if [ $tsts1 -eq 0 ]
       
   190 then
       
   191   echo -e " val p1 = \"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\"\"\"" | tee -a $out
       
   192   echo -e " jtable(p1) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6)" | tee -a $out  
       
   193   echo -e " val p2 = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
       
   194   echo -e " jtable(p2) == Map(14 -> 34, 33 -> 15, 45 -> 44, 48 -> 9, 43 -> 46, 8 -> 49)" | tee -a $out
       
   195   echo -e " run2(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
       
   196   echo -e " run2(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
       
   197   echo -e " run2(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
       
   198   echo -e " run2(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
       
   199   echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
       
   200   echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
       
   201   echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
       
   202   echo -e " run2(hello, Map()) == " | tee -a $out
       
   203   echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
       
   204   
       
   205   if (scala_assert "bfc.scala" "bf_test5.scala")
       
   206   then
       
   207       echo -e "  --> success" | tee -a $out
       
   208       marks=$(( marks + 1 ))
       
   209   else
       
   210       echo -e "  --> TEST FAILED\n" | tee -a $out
       
   211   fi
       
   212 fi
       
   213 
       
   214 
       
   215 ### bfc6 test
       
   216 
       
   217 if [ $tsts1 -eq 0 ]
       
   218 then
       
   219   echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out
       
   220   echo -e " optimise(load_bff(\"mandelbrot.bf\")).length == 11203" | tee -a $out  
       
   221   echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
       
   222   echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
       
   223   echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
       
   224   echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
       
   225   echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
       
   226   echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
       
   227   echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
       
   228   echo -e " run3(hello, Map()) == " | tee -a $out
       
   229   echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
       
   230   
       
   231   if (scala_assert "bfc.scala" "bf_test6.scala")
       
   232   then
       
   233       echo -e "  --> success" | tee -a $out
       
   234       marks=$(( marks + 1 ))
       
   235   else
       
   236       echo -e "  --> TEST FAILED\n" | tee -a $out
       
   237   fi
       
   238 fi
       
   239 
       
   240 ### bfc7 test
       
   241 
       
   242 if [ $tsts1 -eq 0 ]
       
   243 then
       
   244   echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out
       
   245   echo -e " combine(optimise(load_bff(\"mandelbrot.bf\"))).length == 6509" | tee -a $out
       
   246   echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
       
   247   echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
       
   248   echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
       
   249   echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
       
   250   echo -e "        <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
       
   251   echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
       
   252   echo -e "               +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
       
   253   echo -e " run4(hello, Map()) == " | tee -a $out
       
   254   echo -e "       Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
       
   255   
       
   256   if (scala_assert "bfc.scala" "bf_test7.scala")
       
   257   then
       
   258       echo -e "  --> success" | tee -a $out
       
   259       marks=$(( marks + 2 ))
       
   260   else
       
   261       echo -e "  --> TEST FAILED\n" | tee -a $out
   151   fi
   262   fi
   152 fi
   263 fi
   153 
   264 
   154 
   265 
   155 ## final marks
   266 ## final marks
   156 echo -e "Overall mark for CW 10, Part 1" | tee -a $out
   267 echo -e "Overall mark for CW 10" | tee -a $out
   157 echo -e "$marks" | tee -a $out
   268 echo -e "$marks" | tee -a $out
   158 
   269