marking1/drumb_test.sh
changeset 266 ca48ac1d3c3e
parent 261 8997430d9765
child 267 9e0216756771
equal deleted inserted replaced
265:59779ce322a6 266:ca48ac1d3c3e
     2 set -euo pipefail
     2 set -euo pipefail
     3 
     3 
     4 
     4 
     5 out=${1:-output}
     5 out=${1:-output}
     6 
     6 
     7 # read marks for CW6 part 1
     7 echo "" > $out
     8 marks=$(( `tail -1 $out` ))
     8 
     9 
     9 echo `date` >> $out
    10 echo $marks
    10 echo >> $out
       
    11 echo "Below is the feedback and provisional marks for your submission" >> $out
       
    12 echo "for the Main Part of Assignment 6 .  Please note all marks are provisional until" >> $out
       
    13 echo "ratified by the assessment board -- this is not an official" >> $out
       
    14 echo "results transcript." >> $out
       
    15 echo "" >> $out
       
    16 
       
    17 # marks for CW6 main part 
       
    18 marks=$(( 0 ))
       
    19 
    11 
    20 
    12 echo "" >> $out
    21 echo "" >> $out
    13 echo "Below is the feedback for your submission drumb.scala" >> $out
    22 echo "Below is the feedback for your submission drumb.scala" >> $out
    14 echo "" >> $out
    23 echo "" >> $out
    15 
    24 
    16 
    25 
    17 # compilation tests
    26 # compilation tests
    18 
    27 
    19 function scala_compile {
    28 function scala_compile {
    20     (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -nc  "$1" 2> /dev/null 1> /dev/null)
    29     (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null)
    21 }
    30 }
    22 
    31 
    23 # functional tests
    32 # functional tests
    24 
    33 
    25 function scala_assert {
    34 function scala_assert {
    26     (ulimit -t 60; JAVA_OPTS="-Xmx4g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
    35     (ulimit -t 60; JAVA_OPTS="-Xmx4g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
    27 }
    36 }
    28 
    37 
    29 
    38 
    30 # purity test
    39 # purity test
    31 
    40 
    63     tsts=$(( 1 )) 
    72     tsts=$(( 1 )) 
    64   fi
    73   fi
    65 else
    74 else
    66   tsts=$(( 1 ))     
    75   tsts=$(( 1 ))     
    67 fi
    76 fi
       
    77 
       
    78 echo >> $out
    68 
    79 
    69 ### get january tests
    80 ### get january tests
    70 
    81 
    71 if [ $tsts -eq 0 ]
    82 if [ $tsts -eq 0 ]
    72 then
    83 then
   118   else
   129   else
   119       echo "  --> test failed" | tee -a $out
   130       echo "  --> test failed" | tee -a $out
   120   fi
   131   fi
   121 fi
   132 fi
   122 
   133 
       
   134 ### get_delta test
       
   135 
       
   136 if [ $tsts -eq 0 ]
       
   137 then
       
   138   echo "  get_delta(None, None) == None" | tee -a $out
       
   139   echo "  get_delta(Some(50.0), None) == None" | tee -a $out
       
   140   echo "  get_delta(None, Some(100.0)) == None" | tee -a $out
       
   141   echo "  get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out
       
   142 
       
   143   if (scala_assert "drumb.scala" "drumb_test4.scala")
       
   144   then
       
   145       echo "  --> success" | tee -a $out
       
   146       marks=$(( marks + 1 ))
       
   147   else
       
   148       echo "  --> test failed" | tee -a $out
       
   149   fi
       
   150 fi
       
   151 
       
   152 
   123 ### get_deltas_test
   153 ### get_deltas_test
   124 
   154 
   125 #if [ $tsts -eq 0 ]
   155 if [ $tsts -eq 0 ]
   126 #then
   156 then
   127 #  echo " val prices1 = get_prices(List(\"BIDU\"), 2004 to 2008)" | tee -a $out
   157   echo -e "  get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)) == " | tee -a $out
   128 #  echo " val prices2 = get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)" | tee -a $out
   158   echo -e "    List(List(Some(-0.03573992567129673), Some(0.539975124774038)), " | tee -a $out
   129 #  echo " " | tee -a $out  
   159   echo -e "         List(Some(0.10103412653643493), Some(0.24777709700099845)))" | tee -a $out
   130 #  echo " get_deltas(prices1) == List(List(None), List(None), " | tee -a $out
   160   echo -e "" | tee -a $out
   131 #  echo "                             List(Some(0.9277165354330709)), " | tee -a $out
   161   echo -e "  get_deltas(get_prices(List(\"BIDU\"), 2004 to 2008)) == " | tee -a $out
   132 #  echo "                             List(Some(2.119679764725104)))" | tee -a $out
   162   echo -e "    List(List(None), List(None),                          " | tee -a $out
   133 #  echo " " | tee -a $out  
   163   echo -e "         List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) " | tee -a $out
   134 #  echo " get_deltas(prices2) == List(List(Some(-0.03573992567129673), Some(0.5399749442411563)), " | tee -a $out
   164   
   135 #  echo "                             List(Some(0.10103412653643493), Some(0.2477771728154912)))" | tee -a $out
   165   if (scala_assert "drumb.scala" "drumb_test5.scala") 
   136 #  
   166   then
   137 #  if (scala_assert "drumb.scala" "drumb_test2.scala") 
   167      echo "  --> success" | tee -a $out
   138 #  then
   168      marks=$(( marks + 1 ))
   139 #      echo "  --> success" | tee -a $out
   169   else
   140 #      marks=$(( marks + 1 ))
   170      echo "  --> test failed" | tee -a $out
   141 #  else
   171   fi
   142 #      echo "  --> test failed" | tee -a $out
   172 fi
   143 #  fi
   173 
   144 #fi
   174 
   145 
   175 ### yield_tests
   146 
   176 
   147 ### yield_tests, investment_test
   177 if [ $tsts -eq 0 ]
   148 
   178 then
   149 #if [ $tsts -eq 0 ]
   179   echo -e "  val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out
   150 #then
   180   echo -e "  yearly_yield(get_deltas(ds, 100, 0)) == 125" | tee -a $out
   151 #  echo " val prices1 = get_prices(List(\"BIDU\"), 2004 to 2008)" | tee -a $out
   181   echo -e "  yearly_yield(get_deltas(ds, 100, 1)) == 117" | tee -a $out
   152 #  echo " val prices2 = get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)" | tee -a $out
   182   
   153 #  echo " val prices3 = get_prices(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2010 to 2012)" | tee -a $out 
   183   if (scala_assert "drumb.scala" "drumb_test6.scala") 
   154 #  echo " val deltas1 = get_deltas(prices1)" | tee -a $out
   184   then
   155 #  echo " val deltas2 = get_deltas(prices2)" | tee -a $out
   185       echo "  --> success" | tee -a $out
   156 #  echo " val deltas3 = get_deltas(prices3)" | tee -a $out
   186       marks=$(( marks + 1 ))
   157 #  echo "" | tee -a $out
   187   else
   158 #  echo " yearly_yield(deltas1, 100, 0) == 100" | tee -a $out
   188       echo "  --> test failed" | tee -a $out
   159 #  echo " yearly_yield(deltas1, 100, 2) == 192" | tee -a $out
   189   fi
   160 #  echo " yearly_yield(deltas2, 100, 0) == 125" | tee -a $out
   190 fi
   161 #  echo " yearly_yield(deltas3, 100, 0) == 164" | tee -a $out
   191 
   162 #  echo " yearly_yield(deltas3, 100, 1) == 119" | tee -a $out
   192 
   163 #  echo "" | tee -a $out
   193 ### investment_test
   164 #  echo " val inv1 = investment(List(\"IBM\", \"BIDU\"), 2004 to 2008, 100)" | tee -a $out
   194 
   165 #  echo " val inv2 = investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2010 to 2012, 100)" | tee -a $out
   195 if [ $tsts -eq 0 ]
   166 #  echo "" | tee -a $out
   196 then
   167 #  echo " inv1 >= 295 && inv1 <= 301" | tee -a $out
   197   echo -e "  All results need to be in the range of -/+ 1% of the given values."   | tee -a $out
   168 #  echo " inv2 >= 194 && inv2 <= 198" | tee -a $out
   198   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2000, 100) == 100"   | tee -a $out
   169 #  
   199   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2001, 100) == 27 "   | tee -a $out
   170 #  if (scala_assert "drumb.scala" "drumb_test3.scala") 
   200   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2002, 100) == 42 "   | tee -a $out
   171 #  then
   201   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2003, 100) == 27 "   | tee -a $out
   172 #      echo "  --> success" | tee -a $out
   202   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2004, 100) == 38 "   | tee -a $out
   173 #      marks=$(( marks + 1 ))
   203   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2005, 100) == 113"   | tee -a $out
   174 #  else
   204   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2006, 100) == 254"   | tee -a $out
   175 #      echo "  --> test failed" | tee -a $out
   205   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2007, 100) == 349"   | tee -a $out
   176 #  fi
   206   echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 1990 to 2017, 100) == 83061"   | tee -a $out
   177 #fi
   207   
   178 
   208   
   179 
   209   if (scala_assert "drumb.scala" "drumb_test7.scala") 
       
   210   then
       
   211     echo "  --> success" | tee -a $out
       
   212     marks=$(( marks + 1 ))
       
   213   else
       
   214     echo "  --> test failed" | tee -a $out
       
   215   fi
       
   216 fi
   180 
   217 
   181 ## final marks
   218 ## final marks
   182 echo "Overall mark for CW 6, Part 1 + 2" | tee -a $out
   219 echo >> $out
       
   220 echo "Overall mark for CW 6, Main Part" | tee -a $out
   183 echo "$marks" | tee -a $out
   221 echo "$marks" | tee -a $out