marking1/drumb_test.sh
author Christian Urban <urbanc@in.tum.de>
Tue, 04 Feb 2020 14:15:42 +0000
changeset 331 e3878cdd38bc
parent 330 c3d3461a5e77
child 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
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
function scala_vars {
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    43
   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    47
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
# var, .par return, ListBuffer test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
#
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    50
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
    51
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
if (scala_vars drumb.scala)
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    54
  echo -e "  --> TEST FAILED\n" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  tsts0=$(( 1 ))
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    57
  echo -e "  --> success" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
  tsts0=$(( 0 )) 
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
# compilation test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
if  [ $tsts0 -eq 0 ]
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
then 
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    65
  echo -e "drumb.scala runs?" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    67
  if (scala_compile drumb.scala)
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    69
    echo -e "  --> success" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
    tsts=$(( 0 ))
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    72
    echo -e "  --> SCALA DID NOT RUN drumb.scala" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
    tsts=$(( 1 )) 
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
else
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  tsts=$(( 1 ))     
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    79
echo >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    80
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    81
### get january tests
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    83
if [ $tsts -eq 0 ]
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    84
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    85
  echo -e "  get_january_data(\"GOOG\", 1980) == List()" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    86
  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
    87
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    88
  if (scala_assert "drumb.scala" "drumb_test1.scala")
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    89
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    90
      echo -e "  --> success" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    91
      marks=$(( marks + 1 ))
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    92
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    93
      echo -e "  --> TEST FAILED\n" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    94
  fi
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    95
fi
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    96
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    97
### get first price tests
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
if [ $tsts -eq 0 ]
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   100
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   101
  echo -e "  get_first_price(\"GOOG\", 1980) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   102
  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
   103
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   104
  if (scala_assert "drumb.scala" "drumb_test2.scala")
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   105
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   106
      echo -e "  --> success" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   107
      marks=$(( marks + 1 ))
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   108
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   109
      echo -e "  --> TEST FAILED\n" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   110
  fi
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   111
fi
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
### get prices tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
if [ $tsts -eq 0 ]
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   117
  echo -e "  get_prices(List(\"BIDU\"), 2004 to 2008) ==" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   118
  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
   119
  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
   120
  echo -e " " | tee -a $out  
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   121
  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
   122
  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
   123
  echo -e "            List(Some(301.0466),   Some(41.244694))," | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   124
  echo -e "            List(Some(331.462585), Some(51.464207)))" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   126
  if (scala_assert "drumb.scala" "drumb_test3.scala")
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   128
      echo -e "  --> success" | tee -a $out
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   129
      marks=$(( marks + 1 ))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   131
      echo -e "  --> TEST FAILED\n" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
  fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   135
### get_delta test
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   136
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   137
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   138
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   139
  echo -e "  get_delta(None, None) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   140
  echo -e "  get_delta(Some(50.0), None) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   141
  echo -e "  get_delta(None, Some(100.0)) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   142
  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
   143
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   144
  if (scala_assert "drumb.scala" "drumb_test4.scala")
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   145
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   146
      echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   147
      marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   148
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   149
      echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   150
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   151
fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   152
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   153
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   154
### get_deltas_test
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   155
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   156
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   157
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   158
  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
   159
  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
   160
  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
   161
  echo -e "" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   162
  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
   163
  echo -e "    List(List(None), List(None),                          " | tee -a $out
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
   164
  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
   165
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   166
  if (scala_assert "drumb.scala" "drumb_test5.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   167
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   168
     echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   169
     marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   170
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   171
     echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   172
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   173
fi
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   174
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   176
### yield_tests
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
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   179
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   180
  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
   181
  echo -e "  yearly_yield(ds, 100, 0) == 125" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   182
  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
   183
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   184
  if (scala_assert "drumb.scala" "drumb_test6.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   185
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   186
      echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   187
      marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   188
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   189
      echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   190
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   191
fi
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   193
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   194
### investment_test
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   195
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   196
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   197
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   198
  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
   199
  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
   200
  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
   201
  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
   202
  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
   203
  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
   204
  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
   205
  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
   206
  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
   207
  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
   208
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   209
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   210
  if (scala_assert "drumb.scala" "drumb_test7.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   211
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   212
    echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   213
    marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   214
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   215
    echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   216
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   217
fi
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   218
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   219
## final marks
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   220
echo -e "" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   221
echo -e "Overall mark for CW 6, Core Part" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   222
echo -e "$marks" | tee -a $out