author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Sun, 18 Dec 2016 02:01:18 +0000 | |
changeset 89 | fac25de665d2 |
parent 88 | 990a1531135d |
child 93 | 21f41e08457d |
permissions | -rwxr-xr-x |
86 | 1 |
#!/bin/bash |
2 |
set -e |
|
3 |
||
4 |
out=${1:-output} |
|
5 |
||
6 |
echo "" > $out |
|
7 |
||
8 |
echo "Below is the feedback and provisional mark for your submission" >> $out |
|
9 |
echo "for CW 7, Part 2. Please note all marks are provisional until" >> $out |
|
10 |
echo "ratified by the assessment board -- this is not an official" >> $out |
|
11 |
echo "results transcript." >> $out |
|
12 |
echo "" >> $out |
|
13 |
||
14 |
function scala_vars { |
|
87
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
15 |
(egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null) |
86 | 16 |
} |
17 |
||
18 |
||
19 |
# compilation tests |
|
20 |
||
21 |
function scala_compile { |
|
22 |
(scala "$1" 2> /dev/null 1> /dev/null) |
|
23 |
} |
|
24 |
||
25 |
||
26 |
# functional tests |
|
27 |
||
28 |
function scala_assert { |
|
29 |
(scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) |
|
30 |
} |
|
31 |
||
32 |
||
33 |
# marks for CW2b |
|
34 |
marks=$(( 0 )) |
|
35 |
||
36 |
||
37 |
# knights3: var, comments test |
|
38 |
# |
|
39 |
echo "knight3.scala does not contain vars, returns etc?" | tee -a $out |
|
40 |
||
41 |
if (scala_vars knight3.scala) |
|
42 |
then |
|
43 |
echo " --> fail" | tee -a $out |
|
44 |
tsts0=$(( 1 )) |
|
45 |
else |
|
46 |
echo " --> yes" | tee -a $out |
|
47 |
tsts0=$(( 0 )) |
|
48 |
fi |
|
49 |
||
50 |
||
51 |
# compilation test |
|
52 |
if [ $tsts0 -eq 0 ] |
|
53 |
then |
|
54 |
echo "knight3.scala runs?" | tee -a $out |
|
55 |
||
56 |
if (scala_compile knight3.scala.bak) |
|
57 |
then |
|
58 |
echo " --> yes" | tee -a $out |
|
59 |
tsts1=$(( 0 )) |
|
60 |
else |
|
61 |
echo " --> scala knight3.scala did not run successfully" | tee -a $out |
|
62 |
tsts1=$(( 1 )) |
|
63 |
fi |
|
64 |
else |
|
65 |
tsts1=$(( 1 )) |
|
66 |
fi |
|
67 |
||
87
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
68 |
if [ $tsts1 -eq 0 ] |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
69 |
then |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
70 |
echo " ordered_moves(8, List((3,4), (3,2)), (1, 3)) == List((0,1), (0,5), (2,1), (2,5))" | tee -a $out |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
71 |
echo " ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2))" | tee -a $out |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
72 |
echo " ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1))" | tee -a $out |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
73 |
|
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
74 |
if (scala_assert "knight3.scala.bak" "../../../marking/knight3a_test.scala") |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
75 |
then |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
76 |
echo " --> success" | tee -a $out |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
77 |
marks=$(( marks + 1 )) |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
78 |
else |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
79 |
echo " --> test failed" | tee -a $out |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
80 |
fi |
9384b8c98014
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
86
diff
changeset
|
81 |
fi |
86 | 82 |
|
88
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
83 |
if [ $tsts1 -eq 0 ] |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
84 |
then |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
85 |
echo " first_closed_tour_heuristic(6, List((3, 3))) found and ok?" | tee -a $out |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
86 |
|
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
87 |
if (scala_assert "knight3.scala.bak" "../../../marking/knight3b_test.scala") |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
88 |
then |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
89 |
echo " --> success" | tee -a $out |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
90 |
marks=$(( marks + 1 )) |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
91 |
else |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
92 |
echo " --> test failed" | tee -a $out |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
93 |
fi |
990a1531135d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
87
diff
changeset
|
94 |
fi |
86 | 95 |
|
89
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
96 |
if [ $tsts1 -eq 0 ] |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
97 |
then |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
98 |
echo " first_tour_heuristic(8, List((0,0))) found and ok?" | tee -a $out |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
99 |
echo " first_tour_heuristic(50, List((0,0))) found and ok?" | tee -a $out |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
100 |
|
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
101 |
if (scala_assert "knight3.scala.bak" "../../../marking/knight3c_test.scala") |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
102 |
then |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
103 |
echo " --> success" | tee -a $out |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
104 |
marks=$(( marks + 1 )) |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
105 |
else |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
106 |
echo " --> test failed" | tee -a $out |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
107 |
fi |
fac25de665d2
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
88
diff
changeset
|
108 |
fi |
86 | 109 |
|
110 |
||
111 |
## final marks |
|
112 |
echo "Overall mark for CW 7, Part 2" | tee -a $out |
|
113 |
echo "$marks" | tee -a $out |