changeset 244 | a359976a6f3e |
parent 243 | 9bb36426c781 |
child 250 | 1b08b8ac13fd |
243:9bb36426c781 | 244:a359976a6f3e |
---|---|
28 # functional tests |
28 # functional tests |
29 |
29 |
30 function scala_assert { |
30 function scala_assert { |
31 (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) |
31 (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) |
32 } |
32 } |
33 |
|
34 function scala_assert_long { |
|
35 (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) |
|
36 } |
|
37 |
|
38 function scala_assert_elong { |
|
39 (ulimit -t 90; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) |
|
40 } |
|
41 |
|
33 |
42 |
34 # purity test |
43 # purity test |
35 |
44 |
36 function scala_vars { |
45 function scala_vars { |
37 (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) |
46 (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) |
113 |
122 |
114 if [ $tsts1 -eq 0 ] |
123 if [ $tsts1 -eq 0 ] |
115 then |
124 then |
116 echo " all_tours from every position on the board" | tee -a $out |
125 echo " all_tours from every position on the board" | tee -a $out |
117 echo " dim = 1: 1" | tee -a $out |
126 echo " dim = 1: 1" | tee -a $out |
118 echo " 2: 0,0,0,0" >> $out |
127 echo " 2: 0,0,0,0" | tee -a $out |
119 echo " 3: 0,0,0,0,0,0,0,0,0" >> $out |
128 echo " 3: 0,0,0,0,0,0,0,0,0" | tee -a $out |
120 echo " 4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | tee -a $out |
129 echo " 4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | tee -a $out |
121 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 |
130 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 |
122 |
131 |
123 if (scala_assert "knight1.scala" "knight1_test3a.scala") |
132 if (time scala_assert_elong "knight1.scala" "knight1_test3a.scala") |
124 then |
133 then |
125 echo " --> success" | tee -a $out |
134 echo " --> success" | tee -a $out |
126 marks=$(( marks + 1 )) |
135 marks=$(( marks + 1 )) |
127 else |
136 else |
128 echo " --> test failed" | tee -a $out |
137 echo " --> test failed" | tee -a $out |
131 |
140 |
132 if [ $tsts1 -eq 0 ] |
141 if [ $tsts1 -eq 0 ] |
133 then |
142 then |
134 echo " enum_tours(5, List((0,2)) ) => 56 tours? and all correct?" | tee -a $out |
143 echo " enum_tours(5, List((0,2)) ) => 56 tours? and all correct?" | tee -a $out |
135 |
144 |
136 if (scala_assert "knight1.scala" "knight1_test3b.scala") |
145 if (time scala_assert "knight1.scala" "knight1_test3b.scala") |
137 then |
146 then |
138 echo " --> success" | tee -a $out |
147 echo " --> success" | tee -a $out |
139 marks=$(( marks + 1 )) |
148 marks=$(( marks + 1 )) |
140 else |
149 else |
141 echo " --> test failed" | tee -a $out |
150 echo " --> test failed" | tee -a $out |
142 fi |
151 fi |
143 fi |
152 fi |
144 |
153 |
145 |
154 |
146 ### knight2a test |
155 ### knight4 test |
147 |
156 |
148 if [ $tsts1 -eq 0 ] |
157 if [ $tsts1 -eq 0 ] |
149 then |
158 then |
150 echo " val f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " | tee -a $out |
159 echo " val f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " | tee -a $out |
151 echo " first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" | tee -a $out |
160 echo " first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" | tee -a $out |
159 echo " --> test failed" | tee -a $out |
168 echo " --> test failed" | tee -a $out |
160 fi |
169 fi |
161 fi |
170 fi |
162 |
171 |
163 |
172 |
164 ### knight2b test |
173 ### knight5 test |
165 |
174 |
166 if [ $tsts1 -eq 0 ] |
175 if [ $tsts1 -eq 0 ] |
167 then |
176 then |
168 echo " is first_tour(8, List((0, 0))) ok? " | tee -a $out |
177 echo " is first_tour(8, List((0, 0))) ok? " | tee -a $out |
169 echo " is first_tour(4, List((0, 0))) == None " | tee -a $out |
178 echo " is first_tour(4, List((0, 0))) == None " | tee -a $out |
170 |
179 |
171 if (scala_assert "knight1.scala" "knight5_test.scala") |
180 if (time scala_assert_long "knight1.scala" "knight1_test5.scala") |
172 then |
181 then |
173 echo " --> success" | tee -a $out |
182 echo " --> success" | tee -a $out |
174 marks=$(( marks + 2 )) |
183 marks=$(( marks + 1 )) |
175 else |
184 else |
176 echo " --> test failed" | tee -a $out |
185 echo " --> test failed" | tee -a $out |
177 fi |
186 fi |
178 fi |
187 fi |
179 |
188 |