392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
#!/bin/bash
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
# to make the script fail safely
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
set -euo pipefail
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
out=${1:-output}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
echo -e "" > $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
echo -e `date` >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
echo -e "Below is the feedback and provisional marks for your submission" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
echo -e "for Part 5 (Scala). Please note all marks are provisional until" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
echo -e "ratified by the assessment board -- this is not an official" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
echo -e "results transcript." >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
# marks for CW10 part 1
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
marks=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
# compilation tests
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
function scala_compile {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
(ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
27 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
28 |
# functional tests
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
function scala_assert {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
(ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
function scala_assert_thirty {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
(ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" -e "" 2> /dev/null 1> /dev/null)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
38 |
# purity test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
40 |
function scala_vars {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
41 |
(egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|AtomicInteger|mutable|util.control|new Array' c$out 2> /dev/null 1> /dev/null)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
42 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
43 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
44 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
45 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
46 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
47 |
echo -e "Below is the feedback for your submission of bf.scala" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
48 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
49 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
50 |
# compilation test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
51 |
echo -e "bf.scala runs?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
52 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
53 |
if (scala_compile bf.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
54 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
55 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
56 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
57 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
58 |
echo -e " --> SCALA DID NOT RUN bf.scala\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
59 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
60 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
61 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
62 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
63 |
# var, return, ListBuffer test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
64 |
#
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
65 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
66 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
67 |
echo -e "bf.scala does not contain VARS, RETURNS etc?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
68 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
69 |
if (scala_vars bf.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
70 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
71 |
echo -e " --> TEST FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
72 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
73 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
74 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
75 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
76 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
77 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
78 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
79 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
80 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
81 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
82 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
83 |
### bf1 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
84 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
85 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
86 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
87 |
echo -e " load_bff(\"benchmark.bf\").length == 188" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
88 |
echo -e " load_bff(\"foobar.bf\") == \"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
89 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
90 |
if (scala_assert "bf.scala" "bf_test1.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
91 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
92 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
93 |
marks=$(( marks + 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
94 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
95 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
96 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
97 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
98 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
99 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
100 |
### bf2 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
101 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
102 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
103 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
104 |
echo -e " sread(Map(), 2) == 0" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
105 |
echo -e " sread(Map(2 -> 1), 2) == 1" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
106 |
echo -e " write(Map(), 1, 2) == Map(1 -> 2)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
107 |
echo -e " write(Map(1 -> 0), 1, 2) == Map(1 -> 2)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
108 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
109 |
if (scala_assert "bf.scala" "bf_test2.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
110 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
111 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
112 |
marks=$(( marks + 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
113 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
114 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
115 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
116 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
117 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
118 |
### bf3 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
119 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
120 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
121 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
122 |
echo -e " jumpRight(\"[xxxxxx]xxx\", 1, 0) == 8" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
123 |
echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
124 |
echo -e " jumpRight(\"[xx[x]x]xxx\", 1, 0) == 8" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
125 |
echo -e " jumpRight(\"[xx[xxx]xxx\", 1, 0) == 11" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
126 |
echo -e " jumpRight(\"[x[][]x]xxx\", 1, 0) == 8" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
127 |
echo -e " jumpLeft(\"[xxxxxx]xxx\", 6, 0) == 1" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
128 |
echo -e " jumpLeft(\"[xxxxxx]xxx\", 7, 0) == -1" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
129 |
echo -e " jumpLeft(\"[x[][]x]xxx\", 6, 0) == 1" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
130 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
131 |
if (scala_assert "bf.scala" "bf_test3.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
132 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
133 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
134 |
marks=$(( marks + 2 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
135 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
136 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
137 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
138 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
139 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
140 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
141 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
142 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
143 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
144 |
echo -e " run(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
145 |
echo -e " run(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
146 |
echo -e " run(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
147 |
echo -e " run(\"++++++++++#>+***#\") == Map(0 -> 10, 1 -> 1000)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
148 |
echo -e " run(\"+++>+@+@+@+@+@\") == Map(0 -> 3, 1 -> 7, 4 -> 3, 5 -> 3, 6 -> 3, 7 -> 3)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
149 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
150 |
echo -e " run(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
151 |
echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
152 |
echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
153 |
echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
154 |
echo -e " run(hello, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
155 |
echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
156 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
157 |
if (scala_assert "bf.scala" "bf_test4.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
158 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
159 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
160 |
marks=$(( marks + 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
161 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
162 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
163 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
164 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
165 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
166 |
sleep 10
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
167 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
168 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
169 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
170 |
echo -e " val bench_small = \"\"\">+[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
171 |
echo -e " [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
172 |
echo -e " ++++++++[>++++++++++[>++++++++++[>++++++++++[>+" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
173 |
echo -e " +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
174 |
echo -e " run(bench_small, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
175 |
echo -e " Map(0 -> 10, 5 -> 0, 1 -> 0, 6 -> 0, 2 -> 0, 7 -> 0, 3 -> 0, 4 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
176 |
START=$(date +%s)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
177 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
178 |
if (scala_assert_thirty "bf.scala" "bf_test4b.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
179 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
180 |
END=$(date +%s)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
181 |
DIFF=$(( $END - $START ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
182 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
183 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
184 |
marks=$(( marks + 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
185 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
186 |
END=$(date +%s)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
187 |
DIFF=$(( $END - $START ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
188 |
echo -e " This test ran for $DIFF seconds" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
189 |
echo -e " --> TEST FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
190 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
191 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
192 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
193 |
sleep 10
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
194 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
195 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
196 |
echo -e "Below is the feedback for your submission of bfc.scala" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
197 |
echo -e "" >> $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
198 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
199 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
200 |
# compilation test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
201 |
echo "bfc.scala runs?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
202 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
203 |
if (scala_compile bfc.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
204 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
205 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
206 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
207 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
208 |
echo -e " --> SCALA DID NOT RUN bfc.scala\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
209 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
210 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
211 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
212 |
# var, return, ListBuffer test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
213 |
#
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
214 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
215 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
216 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
217 |
echo "bfc.scala does not contain VARS, RETURNS etc?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
218 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
219 |
if (scala_vars bfc.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
220 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
221 |
echo -e " --> TEST FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
222 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
223 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
224 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
225 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
226 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
227 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
228 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
229 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
230 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
231 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
232 |
### bfc5 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
233 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
234 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
235 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
236 |
echo -e " val p1 = \"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
237 |
echo -e " jtable(p1) == Map(69 -> 61, 5 -> 20, 60 -> 70, 27 -> 44, 43 -> 28, 19 -> 6)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
238 |
echo -e " val p2 = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
239 |
echo -e " jtable(p2) == Map(14 -> 34, 33 -> 15, 45 -> 44, 48 -> 9, 43 -> 46, 8 -> 49)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
240 |
echo -e " run2(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
241 |
echo -e " run2(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
242 |
echo -e " run2(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
243 |
echo -e " run2(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
244 |
echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
245 |
echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
246 |
echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
247 |
echo -e " run2(hello, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
248 |
echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
249 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
250 |
if (scala_assert "bfc.scala" "bf_test5.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
251 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
252 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
253 |
marks=$(( marks + 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
254 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
255 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
256 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
257 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
258 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
259 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
260 |
### bfc6 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
261 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
262 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
263 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
264 |
echo -e " optimise(load_bff(\"benchmark.bf\")).length == 181" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
265 |
echo -e " optimise(load_bff(\"mandelbrot.bf\")).length == 11203" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
266 |
echo -e " run3(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
267 |
echo -e " run3(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
268 |
echo -e " run3(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
269 |
echo -e " run3(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
270 |
echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
271 |
echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
272 |
echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
273 |
echo -e " run3(hello, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
274 |
echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
275 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
276 |
if (scala_assert "bfc.scala" "bf_test6.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
277 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
278 |
echo -e " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
279 |
marks=$(( marks + 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
280 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
281 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
282 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
283 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
284 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
285 |
### bfc7 test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
286 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
287 |
if [ $tsts -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
288 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
289 |
echo -e " combine(optimise(load_bff(\"benchmark.bf\"))).length == 134" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
290 |
echo -e " combine(optimise(load_bff(\"mandelbrot.bf\"))).length == 6509" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
291 |
echo -e " run4(\"[-]\", Map(0 -> 100)) == Map(0 -> 0)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
292 |
echo -e " run4(\"[->+<]\", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
293 |
echo -e " run4(\"[>>+>>+<<<<-]\", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
294 |
echo -e " run4(\"\"\"+++++[->++++++++++<]>--<+++[->>++++++++++" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
295 |
echo -e " <<]>>++<<----------[+>.>.<+<]\"\"\") == Map(0 -> 0, 1 -> 58, 2 -> 32)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
296 |
echo -e " val hello = \"\"\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---." | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
297 |
echo -e " +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\"\"\"" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
298 |
echo -e " run4(hello, Map()) == " | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
299 |
echo -e " Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
300 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
301 |
if (scala_assert "bfc.scala" "bf_test7.scala")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
302 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
303 |
echo -e " --> success (+ 2%)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
304 |
marks=$(( marks + 2 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
305 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
306 |
echo -e " --> ONE OF THE TESTS FAILED\n" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
307 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
308 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
309 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
310 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
311 |
## final marks
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
312 |
echo -e "Overall mark for Part 5 (Scala)" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
313 |
echo -e "$marks" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
314 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
315 |
sleep 10
|