equal
deleted
inserted
replaced
1 #!/bin/bash |
1 #!/bin/zsh |
2 |
2 |
3 # to make the script fail safely |
3 # to make the script fail safely |
4 set -euo pipefail |
4 set -euo pipefail |
5 |
5 |
6 out=${1:-output} |
6 out=${1:-output} |
14 echo -e "ratified by the assessment board -- this is not an official" >> $out |
14 echo -e "ratified by the assessment board -- this is not an official" >> $out |
15 echo -e "results transcript." >> $out |
15 echo -e "results transcript." >> $out |
16 echo -e "" >> $out |
16 echo -e "" >> $out |
17 |
17 |
18 # marks for CW6 main part |
18 # marks for CW6 main part |
19 marks=$(( 0 )) |
19 marks=$(( 0.0 )) |
20 |
20 |
21 |
21 |
22 echo -e "" >> $out |
22 echo -e "" >> $out |
23 echo -e "Below is the feedback for your submission drumb.scala" >> $out |
23 echo -e "Below is the feedback for your submission drumb.scala" >> $out |
24 echo -e "" >> $out |
24 echo -e "" >> $out |
36 (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) |
36 (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null) |
37 } |
37 } |
38 |
38 |
39 |
39 |
40 # purity test |
40 # purity test |
41 |
|
42 function scala_vars { |
41 function scala_vars { |
43 (egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null) |
42 (sed 's/immutable/ok/g' c$out > cb$out; |
|
43 egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' cb$out 2> /dev/null 1> /dev/null) |
44 } |
44 } |
|
45 |
45 |
46 |
46 # compilation test |
47 # compilation test |
47 echo -e "drumb.scala runs?" | tee -a $out |
48 echo -e "drumb.scala runs?" | tee -a $out |
48 |
49 |
49 if (scala_compile drumb.scala) |
50 if (scala_compile drumb.scala) |
74 tsts=$(( 1 )) |
75 tsts=$(( 1 )) |
75 fi |
76 fi |
76 |
77 |
77 echo >> $out |
78 echo >> $out |
78 |
79 |
79 sleep 15 |
|
80 |
|
81 ### get january tests |
80 ### get january tests |
82 |
81 |
83 if [ $tsts -eq 0 ] |
82 if [ $tsts -eq 0 ] |
84 then |
83 then |
85 echo -e " get_january_data(\"GOOG\", 1980) == List()" | tee -a $out |
84 echo -e " get_january_data(\"GOOG\", 1980) == List()" | tee -a $out |
86 echo -e " get_january_data(\"GOOG\", 2010).head == \"2010-01-04,312.204773\"" | tee -a $out |
85 echo -e " get_january_data(\"GOOG\", 2010).head == \"2010-01-04,312.204773\"" | tee -a $out |
87 |
86 |
88 if (scala_assert "drumb.scala" "drumb_test1.scala") |
87 if (scala_assert "drumb.scala" "drumb_test1.scala") |
89 then |
88 then |
90 echo -e " --> success" | tee -a $out |
89 echo -e " --> success" | tee -a $out |
91 marks=$(( marks + 1 )) |
90 marks=$(( marks + 0.5 )) |
92 else |
91 else |
93 echo -e " --> TEST FAILED\n" | tee -a $out |
92 echo -e " --> TEST FAILED\n" | tee -a $out |
94 fi |
93 fi |
95 fi |
94 fi |
96 |
95 |
102 echo -e " get_first_price(\"GOOG\", 2010) == Some(312.204773)" | tee -a $out |
101 echo -e " get_first_price(\"GOOG\", 2010) == Some(312.204773)" | tee -a $out |
103 |
102 |
104 if (scala_assert "drumb.scala" "drumb_test2.scala") |
103 if (scala_assert "drumb.scala" "drumb_test2.scala") |
105 then |
104 then |
106 echo -e " --> success" | tee -a $out |
105 echo -e " --> success" | tee -a $out |
107 marks=$(( marks + 1 )) |
106 marks=$(( marks + 1.0 )) |
108 else |
107 else |
109 echo -e " --> TEST FAILED\n" | tee -a $out |
108 echo -e " --> TEST FAILED\n" | tee -a $out |
110 fi |
109 fi |
111 fi |
110 fi |
112 |
111 |
124 echo -e " List(Some(331.462585), Some(51.464207)))" | tee -a $out |
123 echo -e " List(Some(331.462585), Some(51.464207)))" | tee -a $out |
125 |
124 |
126 if (scala_assert "drumb.scala" "drumb_test3.scala") |
125 if (scala_assert "drumb.scala" "drumb_test3.scala") |
127 then |
126 then |
128 echo -e " --> success" | tee -a $out |
127 echo -e " --> success" | tee -a $out |
129 marks=$(( marks + 1 )) |
128 marks=$(( marks + 1.0 )) |
130 else |
129 else |
131 echo -e " --> TEST FAILED\n" | tee -a $out |
130 echo -e " --> TEST FAILED\n" | tee -a $out |
132 fi |
131 fi |
133 fi |
132 fi |
134 |
133 |
142 echo -e " get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out |
141 echo -e " get_delta(Some(50.0), Some(100.0)) == Some(1.0)" | tee -a $out |
143 |
142 |
144 if (scala_assert "drumb.scala" "drumb_test4.scala") |
143 if (scala_assert "drumb.scala" "drumb_test4.scala") |
145 then |
144 then |
146 echo -e " --> success" | tee -a $out |
145 echo -e " --> success" | tee -a $out |
147 marks=$(( marks + 1 )) |
146 marks=$(( marks + 1.0 )) |
148 else |
147 else |
149 echo -e " --> TEST FAILED\n" | tee -a $out |
148 echo -e " --> TEST FAILED\n" | tee -a $out |
150 fi |
149 fi |
151 fi |
150 fi |
152 |
151 |
164 echo -e " List(Some(0.9277165354330709)), List(Some(2.119679764725104)))" | tee -a $out |
163 echo -e " List(Some(0.9277165354330709)), List(Some(2.119679764725104)))" | tee -a $out |
165 |
164 |
166 if (scala_assert "drumb.scala" "drumb_test5.scala") |
165 if (scala_assert "drumb.scala" "drumb_test5.scala") |
167 then |
166 then |
168 echo -e " --> success" | tee -a $out |
167 echo -e " --> success" | tee -a $out |
169 marks=$(( marks + 1 )) |
168 marks=$(( marks + 1.0 )) |
170 else |
169 else |
171 echo -e " --> TEST FAILED\n" | tee -a $out |
170 echo -e " --> TEST FAILED\n" | tee -a $out |
172 fi |
171 fi |
173 fi |
172 fi |
174 |
173 |
182 echo -e " yearly_yield(ds, 100, 1) == 117" | tee -a $out |
181 echo -e " yearly_yield(ds, 100, 1) == 117" | tee -a $out |
183 |
182 |
184 if (scala_assert "drumb.scala" "drumb_test6.scala") |
183 if (scala_assert "drumb.scala" "drumb_test6.scala") |
185 then |
184 then |
186 echo -e " --> success" | tee -a $out |
185 echo -e " --> success" | tee -a $out |
187 marks=$(( marks + 1 )) |
186 marks=$(( marks + 1.0 )) |
188 else |
187 else |
189 echo -e " --> TEST FAILED\n" | tee -a $out |
188 echo -e " --> TEST FAILED\n" | tee -a $out |
190 fi |
189 fi |
191 fi |
190 fi |
192 |
191 |
208 |
207 |
209 |
208 |
210 if (scala_assert "drumb.scala" "drumb_test7.scala") |
209 if (scala_assert "drumb.scala" "drumb_test7.scala") |
211 then |
210 then |
212 echo -e " --> success" | tee -a $out |
211 echo -e " --> success" | tee -a $out |
213 marks=$(( marks + 1 )) |
212 marks=$(( marks + 0.5 )) |
214 else |
213 else |
215 echo -e " --> TEST FAILED\n" | tee -a $out |
214 echo -e " --> TEST FAILED\n" | tee -a $out |
216 fi |
215 fi |
217 fi |
216 fi |
218 |
217 |
219 ## final marks |
218 ## final marks |
220 echo -e "" >> $out |
219 echo -e "" >> $out |
221 echo -e "Overall mark for Main Part 1 (Scala)" | tee -a $out |
220 echo -e "Overall mark for Main Part 1 (Scala)" | tee -a $out |
222 echo -e "$marks" | tee -a $out |
221 printf " %0.1f\n" $marks | tee -a $out |
223 |
222 |
224 |
223 |
225 sleep 10 |
|