31 |
31 |
32 |
32 |
33 # marks for CW2 |
33 # marks for CW2 |
34 marks=$(( 0 )) |
34 marks=$(( 0 )) |
35 |
35 |
36 # var, comments test |
36 # knights1: var, comments test |
37 echo "knight1.scala contains any vars, returns etc?" | tee -a $out |
37 |
|
38 echo "knight1.scala does not contain vars, returns etc?" | tee -a $out |
38 |
39 |
39 if (scala_vars knight1.scala) |
40 if (scala_vars knight1.scala) |
40 then |
41 then |
41 echo " --> fail" | tee -a $out |
42 echo " --> fail" | tee -a $out |
42 tsts0=$(( 1 )) |
43 tsts0=$(( 1 )) |
43 else |
44 else |
44 echo " --> success" | tee -a $out |
45 echo " --> yes" | tee -a $out |
45 tsts0=$(( 0 )) |
46 tsts0=$(( 0 )) |
46 fi |
47 fi |
47 |
48 |
48 |
49 |
49 # compilation test |
50 # compilation test |
50 if [ $tsts0 -eq 0 ] |
51 |
|
52 if [ $tsts0 -eq 0 ] |
51 then |
53 then |
52 echo "knight1.scala runs?" | tee -a $out |
54 echo "knight1.scala runs?" | tee -a $out |
53 |
55 |
54 if (scala_compile knight1.scala.bak) |
56 if (scala_compile knight1.scala.bak) |
55 then |
57 then |
56 echo " --> success" | tee -a $out |
58 echo " --> yes" | tee -a $out |
57 tsts1=$(( 0 )) |
59 tsts1=$(( 0 )) |
58 else |
60 else |
59 echo " --> scala did not run knight1.scala" | tee -a $out |
61 echo " --> scala did not run knight1.scala" | tee -a $out |
60 tsts1=$(( 1 )) |
62 tsts1=$(( 1 )) |
61 fi |
63 fi |
|
64 else |
|
65 tsts1=$(( 1 )) |
62 fi |
66 fi |
63 |
67 |
64 ### knight1a test |
68 ### knight1a test |
|
69 |
|
70 if [ $tsts1 -eq 0 ] |
|
71 then |
|
72 echo " is_legal(8, Nil) (3,4) == true " | tee -a $out |
|
73 echo " is_legal(8, (4,1) (1,0)) (4,1) == false " | tee -a $out |
|
74 echo " is_legal(2, Nil) (0,0) == true" | tee -a $out |
|
75 |
|
76 if (scala_assert "knight1.scala.bak" "../../../marking/knight1c_test.scala") |
|
77 then |
|
78 echo " --> success" | tee -a $out |
|
79 marks=$(( marks + 1 )) |
|
80 else |
|
81 echo " --> test failed" | tee -a $out |
|
82 fi |
|
83 fi |
65 |
84 |
66 if [ $tsts1 -eq 0 ] |
85 if [ $tsts1 -eq 0 ] |
67 then |
86 then |
68 echo " legal_moves(8, Nil, (2,2)) = (3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4)" | tee -a $out |
87 echo " legal_moves(8, Nil, (2,2)) = (3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4)" | tee -a $out |
69 echo " legal_moves(8, Nil, (7,7)) = (6,5), (5,6)" | tee -a $out |
88 echo " legal_moves(8, Nil, (7,7)) = (6,5), (5,6)" | tee -a $out |
71 echo " legal_moves(8, (6,6), (7,7)) = (6,5), (5,6)" | tee -a $out |
90 echo " legal_moves(8, (6,6), (7,7)) = (6,5), (5,6)" | tee -a $out |
72 echo " legal_moves(1, Nil, (0,0)) = Nil" | tee -a $out |
91 echo " legal_moves(1, Nil, (0,0)) = Nil" | tee -a $out |
73 echo " legal_moves(2, Nil, (0,0)) = Nil" | tee -a $out |
92 echo " legal_moves(2, Nil, (0,0)) = Nil" | tee -a $out |
74 echo " legal_moves(3, Nil, (0,0)) = (1,2), (2,1)" | tee -a $out |
93 echo " legal_moves(3, Nil, (0,0)) = (1,2), (2,1)" | tee -a $out |
75 |
94 |
76 if (scala_assert "knight1.scala" "../../../marking/knight1_test.scala") |
95 if (scala_assert "knight1.scala.bak" "../../../marking/knight1_test.scala") |
77 then |
96 then |
78 echo " --> success" | tee -a $out |
97 echo " --> success" | tee -a $out |
79 marks=$(( marks + 1 )) |
98 marks=$(( marks + 1 )) |
80 else |
99 else |
81 echo " --> test failed" | tee -a $out |
100 echo " --> test failed" | tee -a $out |
82 fi |
101 fi |
83 fi |
102 fi |
84 |
103 |
|
104 ### knight1b test |
|
105 |
|
106 if [ $tsts1 -eq 0 ] |
|
107 then |
|
108 echo " all_tours from every position on the board" | tee -a $out |
|
109 echo " dim = 1: 1" | tee -a $out |
|
110 echo " 2: 0,0,0,0" | tee -a $out |
|
111 echo " 3: 0,0,0,0,0,0,0,0,0" | tee -a $out |
|
112 echo " 4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | tee -a $out |
|
113 echo " 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56,0,56,0,56,0,304,0,56,0,304" | tee -a $out |
|
114 echo " enum_tours(5, (0,2) ) = 56 and all correct?" | tee -a $out |
|
115 |
|
116 if (scala_assert "knight1.scala.bak" "../../../marking/knight1b_test.scala") |
|
117 then |
|
118 echo " --> success" | tee -a $out |
|
119 marks=$(( marks + 2 )) |
|
120 else |
|
121 echo " --> test failed" | tee -a $out |
|
122 fi |
|
123 fi |
|
124 |
|
125 |
|
126 |
|
127 # knights2: var, comments test |
|
128 |
|
129 echo "knight2.scala does not contain vars, returns etc?" | tee -a $out |
|
130 |
|
131 if (scala_vars knight2.scala) |
|
132 then |
|
133 echo " --> fail" | tee -a $out |
|
134 tsts0=$(( 1 )) |
|
135 else |
|
136 echo " --> yes" | tee -a $out |
|
137 tsts0=$(( 0 )) |
|
138 fi |
|
139 |
|
140 |
|
141 # compilation test |
|
142 if [ $tsts0 -eq 0 ] |
|
143 then |
|
144 echo "knight2.scala runs?" | tee -a $out |
|
145 |
|
146 if (scala_compile knight2.scala.bak) |
|
147 then |
|
148 echo " --> yes" | tee -a $out |
|
149 tsts1=$(( 0 )) |
|
150 else |
|
151 echo " --> scala did not run knight2.scala" | tee -a $out |
|
152 tsts1=$(( 1 )) |
|
153 fi |
|
154 else |
|
155 tsts1=$(( 1 )) |
|
156 fi |
|
157 |
85 ### knight2 test |
158 ### knight2 test |
86 |
159 |
87 #if [ $tsts -eq 0 ] |
160 if [ $tsts1 -eq 0 ] |
|
161 then |
|
162 echo " Let f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " | tee -a $out |
|
163 echo " first((1,0),(2,0),(3,0),(4,0), f) == Some(List((4,0)))" | tee -a $out |
|
164 echo " first((1,0),(2,0),(3,0), f) == None" | tee -a $out |
|
165 |
|
166 if (scala_assert "knight2.scala.bak" "../../../marking/knight2_test.scala") |
|
167 then |
|
168 echo " --> success" | tee -a $out |
|
169 marks=$(( marks + 1 )) |
|
170 else |
|
171 echo " --> test failed" | tee -a $out |
|
172 fi |
|
173 fi |
|
174 |
|
175 ### knight2b test |
|
176 |
|
177 if [ $tsts1 -eq 0 ] |
|
178 then |
|
179 echo " is first_tour(8, (0, 0)) ok? " | tee -a $out |
|
180 echo " is first_tour(4, (0, 0)) == None " | tee -a $out |
|
181 |
|
182 if (scala_assert "knight2.scala.bak" "../../../marking/knight2b_test.scala") |
|
183 then |
|
184 echo " --> success" | tee -a $out |
|
185 marks=$(( marks + 2 )) |
|
186 else |
|
187 echo " --> test failed" | tee -a $out |
|
188 fi |
|
189 fi |
|
190 |
|
191 |
|
192 # knights3: var, comments test |
|
193 # |
|
194 #echo "knight3.scala does not contain vars, returns etc?" | tee -a $out |
|
195 |
|
196 #if (scala_vars knight3.scala) |
88 #then |
197 #then |
89 # echo " legal_moves(8, Nil, (2,2) = (3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4)" | tee -a $out |
198 # echo " --> fail" | tee -a $out |
90 # echo " List(List(Some(0.07596697626574789), None), " | tee -a $out |
199 # tsts0=$(( 1 )) |
91 # echo " List(Some(-0.152620823795232), None)," | tee -a $out |
200 #else |
92 # echo " List(Some(0.20126676681483952), Some(0.9277165354330709))," | tee -a $out |
201 # echo " --> success" | tee -a $out |
93 # echo " List(Some(0.09141762603007778), Some(2.119679764725104)))" | tee -a $out |
202 # tsts0=$(( 0 )) |
94 # |
203 #fi |
95 # if (scala_assert "drumb.scala" "../drumb_test2.scala") |
204 |
|
205 |
|
206 # compilation test |
|
207 #if [ $tsts0 -eq 0 ] |
|
208 #then |
|
209 # echo "knight3.scala runs?" | tee -a $out |
|
210 # |
|
211 # if (scala_compile knight3.scala.bak) |
96 # then |
212 # then |
97 # echo " --> success" | tee -a $out |
213 # echo " --> success" | tee -a $out |
98 # marks=$(( marks + 1 )) |
214 # tsts1=$(( 0 )) |
99 # else |
215 # else |
100 # echo " --> test failed" | tee -a $out |
216 # echo " --> scala did not run knight3.scala" | tee -a $out |
|
217 # tsts1=$(( 1 )) |
101 # fi |
218 # fi |
|
219 #else |
|
220 # tsts1=$(( 1 )) |
102 #fi |
221 #fi |
103 |
222 |
104 ### knight3 test |
|
105 |
|
106 #if [ $tsts -eq 0 ] |
|
107 #then |
|
108 # echo " yearly_yield(IBM + BIDU, 04 - 08, 100, 0) - 107).abs <= 2 " | tee -a $out |
|
109 # echo " yearly_yield(IBM + BIDU, 04 - 08, 100, 1) - 85).abs <= 2 " | tee -a $out |
|
110 # echo " yearly_yield(IBM + BIDU, 04 - 08, 100, 2) - 156).abs <= 2 " | tee -a $out |
|
111 # echo " yearly_yield(IBM + BIDU, 04 - 08, 100, 3) - 210).abs <= 2 " | tee -a $out |
|
112 # echo " investment(List(\"IBM\", \"BIDU\"), 2004 to 2008, 100) - 298).abs <= 10" | tee -a $out |
|
113 # |
|
114 # if (scala_assert "drumb.scala" "../drumb_test3.scala") |
|
115 # then |
|
116 # echo " --> success" | tee -a $out |
|
117 # marks=$(( marks + 1 )) |
|
118 # else |
|
119 # echo " --> test failed" | tee -a $out |
|
120 # fi |
|
121 #fi |
|
122 |
223 |
123 ## final marks |
224 ## final marks |
124 echo "Overall mark for CW 2" | tee -a $out |
225 echo "Overall mark for CW 2, Part 1 " | tee -a $out |
125 echo "$marks" | tee -a $out |
226 echo "$marks" | tee -a $out |