| author | Christian Urban <christian.urban@kcl.ac.uk> |
| Fri, 19 Sep 2025 18:41:04 +0100 | |
| changeset 989 | aa976b429904 |
| parent 978 | 8778d23fef92 |
| permissions | -rw-r--r-- |
|
978
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
// for testing compilation |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
import scala.util.{Try, Success, Failure}
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
//println("TEST1")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
val res = {
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
if (os.exists(os.pwd / "mand.ll")) |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
os.proc("lli", "mand.ll").call(cwd = os.pwd, check = false)
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
else throw new Exception("No CLASS file found")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
} |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
//println("TEST2")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
/* |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
if (res.exitCode != 0) {
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
throw new Exception("Unsuccessful call")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
} |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
*/ |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
def pp(s1: String, s2: String) = {
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
val s1a = s1.split("\n").toList
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
val s2a = s2.split("\n").toList
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
for (n <- 0 to (s1a.length - 1)) {
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
println(s"|${s1a(n)}|")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
println(s">${Try(s2a(n)).getOrElse("")}<")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
} |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
27 |
} |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
28 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
//println("TEST3")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
val out = os.read(os.pwd / "mand.out") |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
//println("TEST4")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
Try(res.out.text()) match {
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
case Success(v) if v == out => println(s" Success. Printed out the correct picture.\n") |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
case Success(v) => println(s" Printed out wrong or no picture.\n${pp(v, out)}") ; throw new Exception("Wrong picture")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
38 |
case Failure(e) => println(s" Fail. Printed ${res.out.text()} instead\n") ; throw(e)
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
} |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
40 |