marking1/drumb_test2.sh
changeset 261 8997430d9765
parent 260 b4812c877b05
child 264 ecd989eee8bd
equal deleted inserted replaced
260:b4812c877b05 261:8997430d9765
     1 #!/bin/bash
     1 #!/bin/bash
     2 set -euo pipefail
     2 set -euo pipefail
     3 
     3 
     4 
     4 
     5 out=${1:-output}
     5 out=${1:-output}
       
     6 
       
     7 echo "" > $out
     6 
     8 
     7 echo "Below is the feedback and provisional marks for your submission" >> $out
     9 echo "Below is the feedback and provisional marks for your submission" >> $out
     8 echo "for assignment 6 Advanced Part 3.  Please note all marks are provisional until" >> $out
    10 echo "for assignment 6 Advanced Part 3.  Please note all marks are provisional until" >> $out
     9 echo "ratified by the assessment board -- this is not an official" >> $out
    11 echo "ratified by the assessment board -- this is not an official" >> $out
    10 echo "results transcript." >> $out
    12 echo "results transcript." >> $out
    21 }
    23 }
    22 
    24 
    23 # functional tests
    25 # functional tests
    24 
    26 
    25 function scala_assert {
    27 function scala_assert {
    26     (ulimit -t 30; JAVA_OPTS="-Xmx4g" scala -i -nc "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
    28     (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i  "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
    27 }
    29 }
    28 
    30 
    29 
    31 
    30 # purity test
    32 # purity test
    31 
    33 
    70 ### get_delta test
    72 ### get_delta test
    71 
    73 
    72 if [ $tsts -eq 0 ]
    74 if [ $tsts -eq 0 ]
    73 then
    75 then
    74   echo "  get_delta(None, None) == None" | tee -a $out
    76   echo "  get_delta(None, None) == None" | tee -a $out
    75   echo "  get_delta(Some(100.0), None) == None" | tee -a $out
    77   echo "  get_delta(Some(50.0), None) == None" | tee -a $out
    76   echo "  get_delta(None, Some(50.0)) == None" | tee -a $out
    78   echo "  get_delta(None, Some(100.0)) == None" | tee -a $out
    77   echo "  get_delta(Some(100.0), Some(50.0)) == Some(1.0)" | tee -a $out
    79   echo "  get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out
    78 
    80 
    79   if (scala_assert "drumb.scala" "drumb_test4.scala")
    81   if (scala_assert "drumb.scala" "drumb_test4.scala")
    80   then
    82   then
    81       echo "  --> success" | tee -a $out
    83       echo "  --> success" | tee -a $out
    82       marks=$(( marks + 1 ))
    84       marks=$(( marks + 1 ))
    98   echo -e "    List(List(None), List(None),                          " | tee -a $out
   100   echo -e "    List(List(None), List(None),                          " | tee -a $out
    99   echo -e "         List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) " | tee -a $out
   101   echo -e "         List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) " | tee -a $out
   100   
   102   
   101   if (scala_assert "drumb.scala" "drumb_test5.scala") 
   103   if (scala_assert "drumb.scala" "drumb_test5.scala") 
   102   then
   104   then
   103      echo -e "  --> success" | tee -a $out
   105      echo "  --> success" | tee -a $out
   104      marks=$(( marks + 1 ))
   106      marks=$(( marks + 1 ))
   105   else
   107   else
   106      echo "  --> test failed" | tee -a $out
   108      echo "  --> test failed" | tee -a $out
   107   fi
   109   fi
   108 fi
   110 fi
   111 ### yield_tests
   113 ### yield_tests
   112 
   114 
   113 if [ $tsts -eq 0 ]
   115 if [ $tsts -eq 0 ]
   114 then
   116 then
   115   echo -e "  val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out
   117   echo -e "  val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out
   116   echo -e "  yearly_yield(get_deltas(ds, 100, 0) == 125" | tee -a $out
   118   echo -e "  yearly_yield(get_deltas(ds, 100, 0)) == 125" | tee -a $out
   117   echo -e "  yearly_yield(get_deltas(ds, 100, 1) == 117" | tee -a $out
   119   echo -e "  yearly_yield(get_deltas(ds, 100, 1)) == 117" | tee -a $out
   118   
   120   
   119   if (scala_assert "drumb.scala" "drumb_test6.scala") 
   121   if (scala_assert "drumb.scala" "drumb_test6.scala") 
   120   then
   122   then
   121       echo -e "  --> success" | tee -a $out
   123       echo "  --> success" | tee -a $out
   122       marks=$(( marks + 1 ))
   124       marks=$(( marks + 1 ))
   123   else
   125   else
   124       echo "  --> test failed" | tee -a $out
   126       echo "  --> test failed" | tee -a $out
   125   fi
   127   fi
   126 fi
   128 fi
   136   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2003, 100) == 27 "   | tee -a $out
   138   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2003, 100) == 27 "   | tee -a $out
   137   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2004, 100) == 38 "   | tee -a $out
   139   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2004, 100) == 38 "   | tee -a $out
   138   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2005, 100) == 113"   | tee -a $out
   140   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2005, 100) == 113"   | tee -a $out
   139   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2006, 100) == 254"   | tee -a $out
   141   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2006, 100) == 254"   | tee -a $out
   140   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2007, 100) == 349"   | tee -a $out
   142   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2007, 100) == 349"   | tee -a $out
       
   143   echo -e "  investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 1990 to 2017, 100) == 83061"   | tee -a $out
   141   
   144   
   142   if (scala_assert "drumb.scala" "drumb_test7.scala") 
   145   if (scala_assert "drumb.scala" "drumb_test7.scala") 
   143   then
   146   then
   144       echo -e "  --> success" | tee -a $out
   147     echo "  --> success" | tee -a $out
   145       marks=$(( marks + 1 ))
   148     marks=$(( marks + 1 ))
   146   else
   149   else
   147       echo "  --> test failed" | tee -a $out
   150     echo "  --> test failed" | tee -a $out
   148   fi
   151   fi
   149 fi
   152 fi
   150 
   153 
   151 
   154 
   152 
   155