44 |
43 |
45 |
44 |
46 |
45 |
47 # var, .par return, ListBuffer test |
46 # var, .par return, ListBuffer test |
48 # |
47 # |
49 echo "drumb.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out |
48 echo -e "drumb.scala does not contain vars, returns, Arrays, ListBuffers etc?" | tee -a $out |
50 |
49 |
51 if (scala_vars drumb.scala) |
50 if (scala_vars drumb.scala) |
52 then |
51 then |
53 echo " --> test failed" | tee -a $out |
52 echo -e " --> TEST FAILED\n" | tee -a $out |
54 tsts0=$(( 1 )) |
53 tsts0=$(( 1 )) |
55 else |
54 else |
56 echo " --> success" | tee -a $out |
55 echo -e " --> success" | tee -a $out |
57 tsts0=$(( 0 )) |
56 tsts0=$(( 0 )) |
58 fi |
57 fi |
59 |
58 |
60 |
59 |
61 # compilation test |
60 # compilation test |
62 if [ $tsts0 -eq 0 ] |
61 if [ $tsts0 -eq 0 ] |
63 then |
62 then |
64 echo "drumb.scala runs?" | tee -a $out |
63 echo -e "drumb.scala runs?" | tee -a $out |
65 |
64 |
66 if (scala_compile drumb.scala) |
65 if (scala_compile drumb.scala) |
67 then |
66 then |
68 echo " --> success" | tee -a $out |
67 echo -e " --> success" | tee -a $out |
69 tsts=$(( 0 )) |
68 tsts=$(( 0 )) |
70 else |
69 else |
71 echo " --> scala drumb.scala did not run successfully" | tee -a $out |
70 echo -e " --> SCALA DID NOT RUN drumb.scala" | tee -a $out |
72 tsts=$(( 1 )) |
71 tsts=$(( 1 )) |
73 fi |
72 fi |
74 else |
73 else |
75 tsts=$(( 1 )) |
74 tsts=$(( 1 )) |
76 fi |
75 fi |
79 |
78 |
80 ### get january tests |
79 ### get january tests |
81 |
80 |
82 if [ $tsts -eq 0 ] |
81 if [ $tsts -eq 0 ] |
83 then |
82 then |
84 echo " get_january_data(\"GOOG\", 1980) == List()" | tee -a $out |
83 echo -e " get_january_data(\"GOOG\", 1980) == List()" | tee -a $out |
85 echo " get_january_data(\"GOOG\", 2010).head == \"2010-01-04,312.204773\"" | tee -a $out |
84 echo -e " get_january_data(\"GOOG\", 2010).head == \"2010-01-04,312.204773\"" | tee -a $out |
86 |
85 |
87 if (scala_assert "drumb.scala" "drumb_test1.scala") |
86 if (scala_assert "drumb.scala" "drumb_test1.scala") |
88 then |
87 then |
89 echo " --> success" | tee -a $out |
88 echo -e " --> success" | tee -a $out |
90 marks=$(( marks + 1 )) |
89 marks=$(( marks + 1 )) |
91 else |
90 else |
92 echo " --> test failed" | tee -a $out |
91 echo -e " --> TEST FAILED\n" | tee -a $out |
93 fi |
92 fi |
94 fi |
93 fi |
95 |
94 |
96 ### get first price tests |
95 ### get first price tests |
97 |
96 |
98 if [ $tsts -eq 0 ] |
97 if [ $tsts -eq 0 ] |
99 then |
98 then |
100 echo " get_first_price(\"GOOG\", 1980) == None" | tee -a $out |
99 echo -e " get_first_price(\"GOOG\", 1980) == None" | tee -a $out |
101 echo " get_first_price(\"GOOG\", 2010) == Some(312.204773)" | tee -a $out |
100 echo -e " get_first_price(\"GOOG\", 2010) == Some(312.204773)" | tee -a $out |
102 |
101 |
103 if (scala_assert "drumb.scala" "drumb_test2.scala") |
102 if (scala_assert "drumb.scala" "drumb_test2.scala") |
104 then |
103 then |
105 echo " --> success" | tee -a $out |
104 echo -e " --> success" | tee -a $out |
106 marks=$(( marks + 1 )) |
105 marks=$(( marks + 1 )) |
107 else |
106 else |
108 echo " --> test failed" | tee -a $out |
107 echo -e " --> TEST FAILED\n" | tee -a $out |
109 fi |
108 fi |
110 fi |
109 fi |
111 |
110 |
112 ### get prices tests |
111 ### get prices tests |
113 |
112 |
114 if [ $tsts -eq 0 ] |
113 if [ $tsts -eq 0 ] |
115 then |
114 then |
116 echo " get_prices(List(\"BIDU\"), 2004 to 2008) ==" | tee -a $out |
115 echo -e " get_prices(List(\"BIDU\"), 2004 to 2008) ==" | tee -a $out |
117 echo " List(List(None), List(None), List(Some(6.35)), " | tee -a $out |
116 echo -e " List(List(None), List(None), List(Some(6.35)), " | tee -a $out |
118 echo " List(Some(12.241)), List(Some(38.188)))" | tee -a $out |
117 echo -e " List(Some(12.241)), List(Some(38.188)))" | tee -a $out |
119 echo " " | tee -a $out |
118 echo -e " " | tee -a $out |
120 echo " get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012) ==" | tee -a $out |
119 echo -e " get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012) ==" | tee -a $out |
121 echo " List(List(Some(312.204773), Some(26.782711))," | tee -a $out |
120 echo -e " List(List(Some(312.204773), Some(26.782711))," | tee -a $out |
122 echo " List(Some(301.0466), Some(41.244694))," | tee -a $out |
121 echo -e " List(Some(301.0466), Some(41.244694))," | tee -a $out |
123 echo " List(Some(331.462585), Some(51.464207)))" | tee -a $out |
122 echo -e " List(Some(331.462585), Some(51.464207)))" | tee -a $out |
124 |
123 |
125 if (scala_assert "drumb.scala" "drumb_test3.scala") |
124 if (scala_assert "drumb.scala" "drumb_test3.scala") |
126 then |
125 then |
127 echo " --> success" | tee -a $out |
126 echo -e " --> success" | tee -a $out |
128 marks=$(( marks + 1 )) |
127 marks=$(( marks + 1 )) |
129 else |
128 else |
130 echo " --> test failed" | tee -a $out |
129 echo -e " --> TEST FAILED\n" | tee -a $out |
131 fi |
130 fi |
132 fi |
131 fi |
133 |
132 |
134 ### get_delta test |
133 ### get_delta test |
135 |
134 |
136 if [ $tsts -eq 0 ] |
135 if [ $tsts -eq 0 ] |
137 then |
136 then |
138 echo " get_delta(None, None) == None" | tee -a $out |
137 echo -e " get_delta(None, None) == None" | tee -a $out |
139 echo " get_delta(Some(50.0), None) == None" | tee -a $out |
138 echo -e " get_delta(Some(50.0), None) == None" | tee -a $out |
140 echo " get_delta(None, Some(100.0)) == None" | tee -a $out |
139 echo -e " get_delta(None, Some(100.0)) == None" | tee -a $out |
141 echo " get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out |
140 echo -e " get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out |
142 |
141 |
143 if (scala_assert "drumb.scala" "drumb_test4.scala") |
142 if (scala_assert "drumb.scala" "drumb_test4.scala") |
144 then |
143 then |
145 echo " --> success" | tee -a $out |
144 echo -e " --> success" | tee -a $out |
146 marks=$(( marks + 1 )) |
145 marks=$(( marks + 1 )) |
147 else |
146 else |
148 echo " --> test failed" | tee -a $out |
147 echo -e " --> TEST FAILED\n" | tee -a $out |
149 fi |
148 fi |
150 fi |
149 fi |
151 |
150 |
152 |
151 |
153 ### get_deltas_test |
152 ### get_deltas_test |
162 echo -e " List(List(None), List(None), " | tee -a $out |
161 echo -e " List(List(None), List(None), " | tee -a $out |
163 echo -e " List(Some(0.9277165354330709)), List(Some(2.119679764725104)))" | tee -a $out |
162 echo -e " List(Some(0.9277165354330709)), List(Some(2.119679764725104)))" | tee -a $out |
164 |
163 |
165 if (scala_assert "drumb.scala" "drumb_test5.scala") |
164 if (scala_assert "drumb.scala" "drumb_test5.scala") |
166 then |
165 then |
167 echo " --> success" | tee -a $out |
166 echo -e " --> success" | tee -a $out |
168 marks=$(( marks + 1 )) |
167 marks=$(( marks + 1 )) |
169 else |
168 else |
170 echo " --> test failed" | tee -a $out |
169 echo -e " --> TEST FAILED\n" | tee -a $out |
171 fi |
170 fi |
172 fi |
171 fi |
173 |
172 |
174 |
173 |
175 ### yield_tests |
174 ### yield_tests |
176 |
175 |
177 if [ $tsts -eq 0 ] |
176 if [ $tsts -eq 0 ] |
178 then |
177 then |
179 echo -e " val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out |
178 echo -e " val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" | tee -a $out |
180 echo -e " yearly_yield(get_deltas(ds, 100, 0)) == 125" | tee -a $out |
179 echo -e " yearly_yield(ds, 100, 0) == 125" | tee -a $out |
181 echo -e " yearly_yield(get_deltas(ds, 100, 1)) == 117" | tee -a $out |
180 echo -e " yearly_yield(ds, 100, 1) == 117" | tee -a $out |
182 |
181 |
183 if (scala_assert "drumb.scala" "drumb_test6.scala") |
182 if (scala_assert "drumb.scala" "drumb_test6.scala") |
184 then |
183 then |
185 echo " --> success" | tee -a $out |
184 echo -e " --> success" | tee -a $out |
186 marks=$(( marks + 1 )) |
185 marks=$(( marks + 1 )) |
187 else |
186 else |
188 echo " --> test failed" | tee -a $out |
187 echo -e " --> TEST FAILED\n" | tee -a $out |
189 fi |
188 fi |
190 fi |
189 fi |
191 |
190 |
192 |
191 |
193 ### investment_test |
192 ### investment_test |
206 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 1990 to 2017, 100) == 11504" | tee -a $out |
205 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 1990 to 2017, 100) == 11504" | tee -a $out |
207 |
206 |
208 |
207 |
209 if (scala_assert "drumb.scala" "drumb_test7.scala") |
208 if (scala_assert "drumb.scala" "drumb_test7.scala") |
210 then |
209 then |
211 echo " --> success" | tee -a $out |
210 echo -e " --> success" | tee -a $out |
212 marks=$(( marks + 1 )) |
211 marks=$(( marks + 1 )) |
213 else |
212 else |
214 echo " --> test failed" | tee -a $out |
213 echo -e " --> TEST FAILED\n" | tee -a $out |
215 fi |
214 fi |
216 fi |
215 fi |
217 |
216 |
218 ## final marks |
217 ## final marks |
219 echo >> $out |
218 echo -e "" >> $out |
220 echo "Overall mark for CW 6, Core Part" | tee -a $out |
219 echo -e "Overall mark for CW 6, Core Part" | tee -a $out |
221 echo "$marks" | tee -a $out |
220 echo -e "$marks" | tee -a $out |