marking1/drumb_test.sh
author Christian Urban <urbanc@in.tum.de>
Tue, 29 Oct 2019 14:12:24 +0000
changeset 281 87b9e3e2c1a7
parent 268 e43f7e92ba26
child 284 9a04eb6a2291
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
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
     2
set -euo pipefail
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
     3
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
out=${1:-output}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     7
echo "" > $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     9
echo `date` >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    10
echo >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    11
echo "Below is the feedback and provisional marks for your submission" >> $out
281
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    12
echo "for the Core Part of Assignment 6 .  Please note all marks are provisional until" >> $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    13
echo "ratified by the assessment board -- this is not an official" >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    14
echo "results transcript." >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    15
echo "" >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    16
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    17
# marks for CW6 main part 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    18
marks=$(( 0 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    19
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    20
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    21
echo "" >> $out
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    22
echo "Below is the feedback for your submission drumb.scala" >> $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
echo "" >> $out
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    25
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
# compilation tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
function scala_compile {
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    29
    (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala "$1" 2> /dev/null 1> /dev/null)
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
# functional tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
function scala_assert {
281
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    35
    (ulimit -t 60; 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
    36
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    38
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
# purity test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
function scala_vars {
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    42
   (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
    43
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    46
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
# var, .par return, ListBuffer test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
#
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    49
echo "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
    50
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
if (scala_vars drumb.scala)
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
then
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    53
  echo "  --> test failed" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  tsts0=$(( 1 ))
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
else
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    56
  echo "  --> success" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
  tsts0=$(( 0 )) 
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
# compilation test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
if  [ $tsts0 -eq 0 ]
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
then 
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    64
  echo "drumb.scala runs?" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    66
  if (scala_compile drumb.scala)
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
  then
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    68
    echo "  --> success" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
    tsts=$(( 0 ))
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  else
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    71
    echo "  --> scala drumb.scala did not run successfully" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
    tsts=$(( 1 )) 
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
  fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
else
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
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    78
echo >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    79
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    80
### get january tests
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    82
if [ $tsts -eq 0 ]
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    83
then
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    84
  echo "  get_january_data(\"GOOG\", 1980) == List()" | tee -a $out
267
9e0216756771 updated myassert workaround
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    85
  echo "  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
    86
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    87
  if (scala_assert "drumb.scala" "drumb_test1.scala")
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    88
  then
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    89
      echo "  --> success" | tee -a $out
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    90
      marks=$(( marks + 1 ))
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    91
  else
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    92
      echo "  --> test failed" | tee -a $out
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    93
  fi
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
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    96
### get first price tests
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    97
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    98
if [ $tsts -eq 0 ]
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    99
then
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   100
  echo "  get_first_price(\"GOOG\", 1980) == None" | tee -a $out
268
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
   101
  echo "  get_first_price(\"GOOG\", 2010) == Some(312.204773)" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   102
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   103
  if (scala_assert "drumb.scala" "drumb_test2.scala")
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   104
  then
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   105
      echo "  --> success" | tee -a $out
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   106
      marks=$(( marks + 1 ))
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   107
  else
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   108
      echo "  --> test failed" | tee -a $out
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   109
  fi
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   110
fi
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
### get prices tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
if [ $tsts -eq 0 ]
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
then
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   116
  echo "  get_prices(List(\"BIDU\"), 2004 to 2008) ==" | tee -a $out
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   117
  echo "       List(List(None), List(None), List(Some(6.35)), " | tee -a $out
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   118
  echo "            List(Some(12.241)), List(Some(38.188)))" | tee -a $out
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   119
  echo " " | tee -a $out  
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   120
  echo "  get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012) ==" | tee -a $out
268
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
   121
  echo "       List(List(Some(312.204773), Some(26.782711))," | tee -a $out
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
   122
  echo "            List(Some(301.0466),   Some(41.244694))," | tee -a $out
e43f7e92ba26 updated
Christian Urban <urbanc@in.tum.de>
parents: 267
diff changeset
   123
  echo "            List(Some(331.462585), Some(51.464207)))" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   125
  if (scala_assert "drumb.scala" "drumb_test3.scala")
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  then
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   127
      echo "  --> success" | tee -a $out
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   128
      marks=$(( marks + 1 ))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
  else
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   130
      echo "  --> test failed" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
  fi
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
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   134
### get_delta test
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   135
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   136
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   137
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   138
  echo "  get_delta(None, None) == None" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   139
  echo "  get_delta(Some(50.0), None) == None" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   140
  echo "  get_delta(None, Some(100.0)) == None" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   141
  echo "  get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   142
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   143
  if (scala_assert "drumb.scala" "drumb_test4.scala")
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   144
  then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   145
      echo "  --> success" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   146
      marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   147
  else
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   148
      echo "  --> test failed" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   149
  fi
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
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   152
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   153
### get_deltas_test
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   154
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   155
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   156
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   157
  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
   158
  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
   159
  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
   160
  echo -e "" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   161
  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
   162
  echo -e "    List(List(None), List(None),                          " | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   163
  echo -e "         List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) " | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   164
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   165
  if (scala_assert "drumb.scala" "drumb_test5.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   166
  then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   167
     echo "  --> success" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   168
     marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   169
  else
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   170
     echo "  --> test failed" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   171
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   172
fi
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   173
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   175
### yield_tests
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   177
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   178
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   179
  echo -e "  val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   180
  echo -e "  yearly_yield(get_deltas(ds, 100, 0)) == 125" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   181
  echo -e "  yearly_yield(get_deltas(ds, 100, 1)) == 117" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   182
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   183
  if (scala_assert "drumb.scala" "drumb_test6.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   184
  then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   185
      echo "  --> success" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   186
      marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   187
  else
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   188
      echo "  --> test failed" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   189
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   190
fi
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   192
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   193
### investment_test
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   194
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   195
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   196
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   197
  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
   198
  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
   199
  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
   200
  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
   201
  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
   202
  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
   203
  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
   204
  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
   205
  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
   206
  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
   207
  
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
  if (scala_assert "drumb.scala" "drumb_test7.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   210
  then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   211
    echo "  --> success" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   212
    marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   213
  else
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   214
    echo "  --> test failed" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   215
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   216
fi
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   217
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   218
## final marks
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   219
echo >> $out
281
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   220
echo "Overall mark for CW 6, Core Part" | tee -a $out
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   221
echo "$marks" | tee -a $out