marking/mark03a
changeset 90 d77af4aca939
parent 89 fac25de665d2
child 91 b43c81c65341
equal deleted inserted replaced
89:fac25de665d2 90:d77af4aca939
     4 out=${1:-output}
     4 out=${1:-output}
     5 
     5 
     6 echo "" > $out
     6 echo "" > $out
     7 
     7 
     8 echo "Below is the feedback and provisional mark for your submission" >> $out
     8 echo "Below is the feedback and provisional mark for your submission" >> $out
     9 echo "for CW 7, Part 2.  Please note all marks are provisional until" >> $out
     9 echo "for CW 8, Part 1.  Please note all marks are provisional until" >> $out
    10 echo "ratified by the assessment board -- this is not an official" >> $out
    10 echo "ratified by the assessment board -- this is not an official" >> $out
    11 echo "results transcript." >> $out
    11 echo "results transcript." >> $out
    12 echo "" >> $out
    12 echo "" >> $out
    13 
    13 
    14 function scala_vars {
    14 function scala_vars {
    28 function scala_assert {
    28 function scala_assert {
    29   (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
    29   (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
    30 }
    30 }
    31 
    31 
    32 
    32 
    33 # marks for CW2b
    33 # marks for CW
    34 marks=$(( 0 ))
    34 marks=$(( 0 ))
    35 
    35 
    36 
    36 
    37 # knights3: var, comments test
    37 # var, return, ListBuffer test
    38 #
    38 #
    39 echo "knight3.scala does not contain vars, returns etc?" | tee -a $out
    39 echo "re.scala does not contain vars, returns etc?" | tee -a $out
    40 
    40 
    41 if (scala_vars knight3.scala)
    41 if (scala_vars re.scala)
    42 then
    42 then
    43   echo "  --> fail" | tee -a $out
    43   echo "  --> fail" | tee -a $out
    44   tsts0=$(( 1 ))
    44   tsts0=$(( 1 ))
    45 else
    45 else
    46   echo "  --> yes" | tee -a $out
    46   echo "  --> yes" | tee -a $out
    49 
    49 
    50 
    50 
    51 # compilation test
    51 # compilation test
    52 if  [ $tsts0 -eq 0 ]
    52 if  [ $tsts0 -eq 0 ]
    53 then    
    53 then    
    54   echo "knight3.scala runs?" | tee -a $out
    54   echo "re.scala runs?" | tee -a $out
    55 
    55 
    56   if (scala_compile knight3.scala.bak)
    56   if (scala_compile re.scala.bak)
    57   then
    57   then
    58     echo "  --> yes" | tee -a $out
    58     echo "  --> yes" | tee -a $out
    59     tsts1=$(( 0 ))
    59     tsts1=$(( 0 ))
    60   else
    60   else
    61     echo "  --> scala knight3.scala did not run successfully" | tee -a $out
    61     echo "  --> scala re.scala did not run successfully" | tee -a $out
    62     tsts1=$(( 1 )) 
    62     tsts1=$(( 1 )) 
    63   fi
    63   fi
    64 else
    64 else
    65   tsts1=$(( 1 ))     
    65   tsts1=$(( 1 ))     
    66 fi
    66 fi
    67 
    67 
    68 if [ $tsts1 -eq 0 ]
    68 if [ $tsts1 -eq 0 ]
    69 then
    69 then
    70   echo " ordered_moves(8, List((3,4), (3,2)), (1, 3)) == List((0,1), (0,5), (2,1), (2,5))" | tee -a $out
    70   echo " nullable(ZERO) == false" | tee -a $out
    71   echo " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" | tee -a $out
    71   echo " nullable(ONE) == true" | tee -a $out
    72   echo " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" | tee -a $out
    72   echo " nullable(CHAR('a')) == false" | tee -a $out
       
    73   echo " nullable(ZERO | ONE) == true" | tee -a $out
       
    74   echo " nullable(ZERO | CHAR('a')) == false" | tee -a $out
       
    75   echo " nullable(ONE ~  ONE) == true" | tee -a $out
       
    76   echo " nullable(ONE ~ CHAR('a')) == false" | tee -a $out
       
    77   echo " nullable(STAR(ZERO)) == true" | tee -a $out
    73   
    78   
    74   if (scala_assert "knight3.scala.bak" "../../../marking/knight3a_test.scala")
    79   if (scala_assert "re.scala.bak" "../../../marking/re1a_test.scala")
    75   then
    80   then
    76     echo "  --> success" | tee -a $out
    81     echo "  --> success" | tee -a $out
    77     marks=$(( marks + 1 ))
    82     marks=$(( marks + 1 ))
    78   else
    83   else
    79     echo "  --> test failed" | tee -a $out
    84     echo "  --> test failed" | tee -a $out
    80   fi
    85   fi
    81 fi
    86 fi
    82 
    87 
    83 if [ $tsts1 -eq 0 ]
    88 if [ $tsts1 -eq 0 ]
    84 then
    89 then
    85   echo " first_closed_tour_heuristic(6, List((3, 3))) found and ok?" | tee -a $out
    90   echo " der('a', ZERO | ONE) == (ZERO | ZERO)" | tee -a $out
       
    91   echo " der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE)" | tee -a $out
       
    92   echo " der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))" | tee -a $out
       
    93   echo " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" | tee -a $out
    86   
    94   
    87   if (scala_assert "knight3.scala.bak" "../../../marking/knight3b_test.scala")
    95   if (scala_assert "re.scala.bak" "../../../marking/re1b_test.scala")
    88   then
    96   then
    89     echo "  --> success" | tee -a $out
    97     echo "  --> success" | tee -a $out
    90     marks=$(( marks + 1 ))
    98     marks=$(( marks + 1 ))
    91   else
    99   else
    92     echo "  --> test failed" | tee -a $out
   100     echo "  --> test failed" | tee -a $out
    93   fi
   101   fi
    94 fi
   102 fi
    95 
   103 
    96 if [ $tsts1 -eq 0 ]
   104 if [ $tsts1 -eq 0 ]
    97 then
   105 then
    98   echo " first_tour_heuristic(8, List((0,0))) found and ok?" | tee -a $out
   106   echo " simp(ZERO | ONE) == ONE" | tee -a $out
    99   echo " first_tour_heuristic(50, List((0,0))) found and ok?" | tee -a $out
   107   echo " simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)" | tee -a $out
       
   108   echo " simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')" | tee -a $out
       
   109   echo " simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO" | tee -a $out
       
   110   echo " simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')" | tee -a $out
   100   
   111   
   101   if (scala_assert "knight3.scala.bak" "../../../marking/knight3c_test.scala")
   112   if (scala_assert "re.scala.bak" "../../../marking/re1c_test.scala")
   102   then
   113   then
   103     echo "  --> success" | tee -a $out
   114     echo "  --> success" | tee -a $out
   104     marks=$(( marks + 1 ))
   115     marks=$(( marks + 1 ))
   105   else
   116   else
   106     echo "  --> test failed" | tee -a $out
   117     echo "  --> test failed" | tee -a $out
   107   fi
   118   fi
   108 fi
   119 fi
   109 
   120 
       
   121 if [ $tsts1 -eq 0 ]
       
   122 then
       
   123   echo " EVIL = (a*)* b" | tee -a $out
       
   124   echo " ders(List.fill(5)('a'),EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))" | tee -a $out
       
   125   echo " ders(List('b'),EVIL) == ONE" | tee -a $out
       
   126   echo " ders(List('b','b'),EVIL) == ZERO" | tee -a $out
       
   127   echo " matcher(EVIL, \"a\" * 5 ++ \"b\") == true" | tee -a $out
       
   128   echo " matcher(EVIL, \"b\") == true" | tee -a $out
       
   129   echo " matcher(EVIL, \"bb\") == false" | tee -a $out
       
   130   echo " matcher(\"abc\", \"abc\") == true" | tee -a $out
       
   131   echo " matcher((\"ab\" | \"a\") ~ (ONE | \"bc\"), \"abc\") == true" | tee -a $out
       
   132   echo " matcher(ONE, \"\") == true" | tee -a $out
       
   133   echo " matcher(ZERO, \"\") == false" | tee -a $out
       
   134   
       
   135   if (scala_assert "re.scala.bak" "../../../marking/re1d_test.scala")
       
   136   then
       
   137     echo "  --> success" | tee -a $out
       
   138     marks=$(( marks + 1 ))
       
   139   else
       
   140     echo "  --> test failed" | tee -a $out
       
   141   fi
       
   142 fi
       
   143 
       
   144 if [ $tsts1 -eq 0 ]
       
   145 then
       
   146   echo " replace(\"aa\".% | \"bb\", \"aabbbaaaaaaabaaaaabbaaaabb\" , \"c\") == \"ccbcabcaccc\"" | tee -a $out
       
   147   echo " replace(\"aa\".% | \"bb\", \"abba\" , \"\") == \"aa\"" | tee -a $out
       
   148   
       
   149   if (scala_assert "re.scala.bak" "../../../marking/re1e_test.scala")
       
   150   then
       
   151     echo "  --> success" | tee -a $out
       
   152     marks=$(( marks + 2 ))
       
   153   else
       
   154     echo "  --> test failed" | tee -a $out
       
   155   fi
       
   156 fi
       
   157 
   110 
   158 
   111 ## final marks
   159 ## final marks
   112 echo "Overall mark for CW 7, Part 2" | tee -a $out
   160 echo "Overall mark for CW 8, Part 1" | tee -a $out
   113 echo "$marks" | tee -a $out
   161 echo "$marks" | tee -a $out