marking1/drumb_test.sh
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 25 Nov 2022 00:03:15 +0000
changeset 448 db2a3e3287a9
parent 333 24bc76d97db2
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
     2
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
     3
# to make the script fail safely
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
     4
set -euo pipefail
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
     5
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
out=${1:-output}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     8
echo "" > $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    10
echo -e `date` >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    11
echo -e "" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    12
echo -e "Below is the feedback and provisional marks for your submission" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    13
echo -e "for the Core Part of Assignment 6.  Please note all marks are provisional until" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    14
echo -e "ratified by the assessment board -- this is not an official" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    15
echo -e "results transcript." >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    16
echo -e "" >> $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    17
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    18
# marks for CW6 main part 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    19
marks=$(( 0 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    20
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    21
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    22
echo -e "" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    23
echo -e "Below is the feedback for your submission drumb.scala" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    24
echo -e "" >> $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    26
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
# compilation tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
function scala_compile {
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
    30
    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null)
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
# functional tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
function scala_assert {
331
e3878cdd38bc updated
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
    36
    (ulimit -t 30; JAVA_OPTS="-Xmx4g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    39
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
# purity test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    42
#function scala_vars {
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    43
#   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    44
#}
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    45
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
function scala_vars {
333
24bc76d97db2 updated
Christian Urban <urbanc@in.tum.de>
parents: 331
diff changeset
    47
   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|new Array' "$1" 2> /dev/null 1> /dev/null)
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
# var, .par return, ListBuffer test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
#
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    52
echo -e "drumb.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
if (scala_vars drumb.scala)
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    56
  echo -e "  --> TEST FAILED\n" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
  tsts0=$(( 1 ))
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    59
  echo -e "  --> success" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
  tsts0=$(( 0 )) 
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
# compilation test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
if  [ $tsts0 -eq 0 ]
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
then 
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    67
  echo -e "drumb.scala runs?" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    69
  if (scala_compile drumb.scala)
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    71
    echo -e "  --> success" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
    tsts=$(( 0 ))
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    74
    echo -e "  --> SCALA DID NOT RUN drumb.scala" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
    tsts=$(( 1 )) 
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
else
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
  tsts=$(( 1 ))     
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    81
echo >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    82
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    83
### get january tests
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    85
if [ $tsts -eq 0 ]
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    86
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    87
  echo -e "  get_january_data(\"GOOG\", 1980) == List()" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    88
  echo -e "  get_january_data(\"GOOG\", 2010).head == \"2010-01-04,312.204773\"" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    89
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    90
  if (scala_assert "drumb.scala" "drumb_test1.scala")
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    91
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    92
      echo -e "  --> success" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    93
      marks=$(( marks + 1 ))
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    94
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    95
      echo -e "  --> TEST FAILED\n" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    96
  fi
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    97
fi
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    98
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    99
### get first price tests
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   100
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   101
if [ $tsts -eq 0 ]
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   102
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   103
  echo -e "  get_first_price(\"GOOG\", 1980) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   104
  echo -e "  get_first_price(\"GOOG\", 2010) == Some(312.204773)" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   105
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   106
  if (scala_assert "drumb.scala" "drumb_test2.scala")
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   107
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   108
      echo -e "  --> success" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   109
      marks=$(( marks + 1 ))
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   110
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   111
      echo -e "  --> TEST FAILED\n" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   112
  fi
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   113
fi
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
### get prices tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
if [ $tsts -eq 0 ]
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   119
  echo -e "  get_prices(List(\"BIDU\"), 2004 to 2008) ==" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   120
  echo -e "       List(List(None), List(None), List(Some(6.35)), " | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   121
  echo -e "            List(Some(12.241)), List(Some(38.188)))" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   122
  echo -e " " | tee -a $out  
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   123
  echo -e "  get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012) ==" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   124
  echo -e "       List(List(Some(312.204773), Some(26.782711))," | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   125
  echo -e "            List(Some(301.0466),   Some(41.244694))," | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   126
  echo -e "            List(Some(331.462585), Some(51.464207)))" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   128
  if (scala_assert "drumb.scala" "drumb_test3.scala")
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   130
      echo -e "  --> success" | tee -a $out
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   131
      marks=$(( marks + 1 ))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   133
      echo -e "  --> TEST FAILED\n" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
  fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   137
### get_delta test
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   138
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   139
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   140
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   141
  echo -e "  get_delta(None, None) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   142
  echo -e "  get_delta(Some(50.0), None) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   143
  echo -e "  get_delta(None, Some(100.0)) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   144
  echo -e "  get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   145
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   146
  if (scala_assert "drumb.scala" "drumb_test4.scala")
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   147
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   148
      echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   149
      marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   150
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   151
      echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   152
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   153
fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   154
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   155
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   156
### get_deltas_test
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   157
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   158
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   159
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   160
  echo -e "  get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)) == " | tee -a $out
268
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
   161
  echo -e "    List(List(Some(-0.03573991804411003), Some(0.539974575389325)), " | tee -a $out
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
   162
  echo -e "         List(Some(0.10103414222249969), Some(0.24777764141006836)))" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   163
  echo -e "" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   164
  echo -e "  get_deltas(get_prices(List(\"BIDU\"), 2004 to 2008)) == " | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   165
  echo -e "    List(List(None), List(None),                          " | tee -a $out
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
   166
  echo -e "         List(Some(0.9277165354330709)), List(Some(2.119679764725104)))" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   167
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   168
  if (scala_assert "drumb.scala" "drumb_test5.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   169
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   170
     echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   171
     marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   172
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   173
     echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   174
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   175
fi
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   176
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   178
### yield_tests
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   180
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   181
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   182
  echo -e "  val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   183
  echo -e "  yearly_yield(ds, 100, 0) == 125" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   184
  echo -e "  yearly_yield(ds, 100, 1) == 117" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   185
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   186
  if (scala_assert "drumb.scala" "drumb_test6.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   187
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   188
      echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   189
      marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   190
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   191
      echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   192
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   193
fi
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   195
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   196
### investment_test
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   197
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   198
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   199
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   200
  echo -e "  All results need to be in the range of -/+ 1% of the given values."   | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   201
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2000, 100) == 100"   | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   202
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2001, 100) == 27 "   | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   203
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2002, 100) == 42 "   | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   204
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2003, 100) == 27 "   | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   205
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2004, 100) == 38 "   | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   206
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2005, 100) == 113"   | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   207
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2006, 100) == 254"   | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   208
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2007, 100) == 349"   | tee -a $out
268
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
   209
  echo -e "   investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 1990 to 2017, 100) == 11504"   | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   210
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   211
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   212
  if (scala_assert "drumb.scala" "drumb_test7.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   213
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   214
    echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   215
    marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   216
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   217
    echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   218
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   219
fi
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   220
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   221
## final marks
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   222
echo -e "" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   223
echo -e "Overall mark for CW 6, Core Part" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   224
echo -e "$marks" | tee -a $out