marking1/drumb_test.sh
author Christian Urban <urbanc@in.tum.de>
Tue, 04 Feb 2020 11:20:31 +0000
changeset 330 c3d3461a5e77
parent 284 9a04eb6a2291
child 331 e3878cdd38bc
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
out=${1:-output}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
     6
echo "" > $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
     8
echo -e `date` >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
     9
echo -e "" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    10
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
    11
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
    12
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
    13
echo -e "results transcript." >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    14
echo -e "" >> $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    15
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    16
# marks for CW6 main part 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    17
marks=$(( 0 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    18
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    19
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    20
echo -e "" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    21
echo -e "Below is the feedback for your submission drumb.scala" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    22
echo -e "" >> $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    24
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
# compilation tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
function scala_compile {
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    28
    (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
    29
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
# functional tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
function scala_assert {
281
87b9e3e2c1a7 updated
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    34
    (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
    35
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    37
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
# purity test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
function scala_vars {
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    41
   (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
    42
}
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    45
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
# var, .par return, ListBuffer test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
#
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    48
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
    49
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
if (scala_vars drumb.scala)
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    52
  echo -e "  --> TEST FAILED\n" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
  tsts0=$(( 1 ))
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    55
  echo -e "  --> success" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  tsts0=$(( 0 )) 
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
# compilation test
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
if  [ $tsts0 -eq 0 ]
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
then 
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    63
  echo -e "drumb.scala runs?" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
    65
  if (scala_compile drumb.scala)
158
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 "  --> success" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
    tsts=$(( 0 ))
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    70
    echo -e "  --> SCALA DID NOT RUN drumb.scala" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
    tsts=$(( 1 )) 
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
else
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  tsts=$(( 1 ))     
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
fi
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    77
echo >> $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
    78
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    79
### get january tests
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    81
if [ $tsts -eq 0 ]
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    82
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    83
  echo -e "  get_january_data(\"GOOG\", 1980) == List()" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    84
  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
    85
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    86
  if (scala_assert "drumb.scala" "drumb_test1.scala")
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    87
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    88
      echo -e "  --> success" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    89
      marks=$(( marks + 1 ))
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    90
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    91
      echo -e "  --> TEST FAILED\n" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    92
  fi
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
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    95
### get first price tests
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
if [ $tsts -eq 0 ]
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
    98
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
    99
  echo -e "  get_first_price(\"GOOG\", 1980) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   100
  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
   101
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   102
  if (scala_assert "drumb.scala" "drumb_test2.scala")
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   103
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   104
      echo -e "  --> success" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   105
      marks=$(( marks + 1 ))
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   106
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   107
      echo -e "  --> TEST FAILED\n" | tee -a $out
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   108
  fi
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   109
fi
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
### get prices tests
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
if [ $tsts -eq 0 ]
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   115
  echo -e "  get_prices(List(\"BIDU\"), 2004 to 2008) ==" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   116
  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
   117
  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
   118
  echo -e " " | tee -a $out  
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   119
  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
   120
  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
   121
  echo -e "            List(Some(301.0466),   Some(41.244694))," | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   122
  echo -e "            List(Some(331.462585), Some(51.464207)))" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   124
  if (scala_assert "drumb.scala" "drumb_test3.scala")
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   126
      echo -e "  --> success" | tee -a $out
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   127
      marks=$(( marks + 1 ))
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   129
      echo -e "  --> TEST FAILED\n" | tee -a $out
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
  fi
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
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   133
### get_delta test
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   134
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   135
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   136
then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   137
  echo -e "  get_delta(None, None) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   138
  echo -e "  get_delta(Some(50.0), None) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   139
  echo -e "  get_delta(None, Some(100.0)) == None" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   140
  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
   141
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   142
  if (scala_assert "drumb.scala" "drumb_test4.scala")
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   143
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   144
      echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   145
      marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   146
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   147
      echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   148
  fi
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
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   151
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   152
### get_deltas_test
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   153
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   154
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   155
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   156
  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
   157
  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
   158
  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
   159
  echo -e "" | tee -a $out
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   160
  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
   161
  echo -e "    List(List(None), List(None),                          " | tee -a $out
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 281
diff changeset
   162
  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
   163
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   164
  if (scala_assert "drumb.scala" "drumb_test5.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   165
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   166
     echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   167
     marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   168
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   169
     echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   170
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   171
fi
210
63a1376cbebd updated
Christian Urban <urbanc@in.tum.de>
parents: 169
diff changeset
   172
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   174
### yield_tests
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
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   177
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   178
  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
   179
  echo -e "  yearly_yield(ds, 100, 0) == 125" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   180
  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
   181
  
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   182
  if (scala_assert "drumb.scala" "drumb_test6.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   183
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   184
      echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   185
      marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   186
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   187
      echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   188
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   189
fi
158
94b11ac19b41 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   191
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   192
### investment_test
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   193
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   194
if [ $tsts -eq 0 ]
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   195
then
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   196
  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
   197
  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
   198
  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
   199
  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
   200
  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
   201
  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
   202
  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
   203
  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
   204
  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
   205
  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
   206
  
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
  if (scala_assert "drumb.scala" "drumb_test7.scala") 
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   209
  then
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   210
    echo -e "  --> success" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   211
    marks=$(( marks + 1 ))
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   212
  else
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   213
    echo -e "  --> TEST FAILED\n" | tee -a $out
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   214
  fi
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 261
diff changeset
   215
fi
169
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   216
b37052895281 updated
Christian Urban <urbanc@in.tum.de>
parents: 158
diff changeset
   217
## final marks
330
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   218
echo -e "" >> $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   219
echo -e "Overall mark for CW 6, Core Part" | tee -a $out
c3d3461a5e77 updated
Christian Urban <urbanc@in.tum.de>
parents: 284
diff changeset
   220
echo -e "$marks" | tee -a $out