diff -r a56a6c28b700 -r 32dfd2ca577b marking1/drumb_test2.sh --- a/marking1/drumb_test2.sh Tue Oct 29 11:11:44 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -#!/bin/bash -set -euo pipefail - - -out=${1:-output} - -echo "" > $out - -echo "Below is the feedback and provisional marks for your submission" >> $out -echo "for assignment 6 Advanced Part 3. Please note all marks are provisional until" >> $out -echo "ratified by the assessment board -- this is not an official" >> $out -echo "results transcript." >> $out -echo "" >> $out - -# marks for CW6 part 3 -marks=$(( 0 )) - - -# compilation tests - -function scala_compile { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2> /dev/null 1> /dev/null) -} - -# functional tests - -function scala_assert { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) -} - - -# purity test - -function scala_vars { - (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) -} - - - -# var, .par return, ListBuffer test -# -echo "drumb.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out - -if (scala_vars drumb.scala) -then - echo " --> test failed" | tee -a $out - tsts0=$(( 1 )) -else - echo " --> success" | tee -a $out - tsts0=$(( 0 )) -fi - - -# compilation test -if [ $tsts0 -eq 0 ] -then - echo "drumb.scala runs?" | tee -a $out - - if (scala_compile drumb.scala) - then - echo " --> success" | tee -a $out - tsts=$(( 0 )) - else - echo " --> scala drumb.scala did not run successfully" | tee -a $out - tsts=$(( 1 )) - fi -else - tsts=$(( 1 )) -fi - - -### get_delta test - -if [ $tsts -eq 0 ] -then - echo " get_delta(None, None) == None" | tee -a $out - echo " get_delta(Some(50.0), None) == None" | tee -a $out - echo " get_delta(None, Some(100.0)) == None" | tee -a $out - echo " get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out - - if (scala_assert "drumb.scala" "drumb_test4.scala") - then - echo " --> success" | tee -a $out - marks=$(( marks + 1 )) - else - echo " --> test failed" | tee -a $out - fi -fi - - -### get_deltas_test - -if [ $tsts -eq 0 ] -then - echo -e " get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)) == " | tee -a $out - echo -e " List(List(Some(-0.03573992567129673), Some(0.539975124774038)), " | tee -a $out - echo -e " List(Some(0.10103412653643493), Some(0.24777709700099845)))" | tee -a $out - echo -e "" | tee -a $out - echo -e " get_deltas(get_prices(List(\"BIDU\"), 2004 to 2008)) == " | tee -a $out - echo -e " List(List(None), List(None), " | tee -a $out - echo -e " List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) " | tee -a $out - - if (scala_assert "drumb.scala" "drumb_test5.scala") - then - echo " --> success" | tee -a $out - marks=$(( marks + 1 )) - else - echo " --> test failed" | tee -a $out - fi -fi - - -### yield_tests - -if [ $tsts -eq 0 ] -then - echo -e " val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out - echo -e " yearly_yield(get_deltas(ds, 100, 0)) == 125" | tee -a $out - echo -e " yearly_yield(get_deltas(ds, 100, 1)) == 117" | tee -a $out - - if (scala_assert "drumb.scala" "drumb_test6.scala") - then - echo " --> success" | tee -a $out - marks=$(( marks + 1 )) - else - echo " --> test failed" | tee -a $out - fi -fi - - -### investment_test - -if [ $tsts -eq 0 ] -then - echo -e " All results need to be in the range of -/+ 1% of the given values." | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2000, 100) == 100" | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2001, 100) == 27 " | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2002, 100) == 42 " | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2003, 100) == 27 " | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2004, 100) == 38 " | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2005, 100) == 113" | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2006, 100) == 254" | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2007, 100) == 349" | tee -a $out - echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 1990 to 2017, 100) == 83061" | tee -a $out - - - if (scala_assert "drumb.scala" "drumb_test7.scala") - then - echo " --> success" | tee -a $out - marks=$(( marks + 1 )) - else - echo " --> test failed" | tee -a $out - fi -fi - - - -## final marks -echo "Overall mark for CW 6, Part 3" | tee -a $out -echo "$marks" | tee -a $out