| author | Christian Urban <christian.urban@kcl.ac.uk> |
| Wed, 08 Oct 2025 10:42:10 +0100 | |
| changeset 1003 | bae8c3eb51c7 |
| 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 / "sqr.ll")) |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
os.proc("lli", "sqr.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.replace("\n","").replace(" ","")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
val s2a = s2.replace("\n","")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
s1a == s2a |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
} |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
//println("TEST3")
|
|
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 |
val out = "Squares0149162536496481100" |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
val out2 = "\"Squares\"0149162536496481100" |
|
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 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
//println("TEST4")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
Try(res.out.text()) match {
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
case Success(v) if (pp(v, out) || pp(v, out2)) => println(s" Success. Printed out the correct output.\n") |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
case Success(v) => println(s" Printed out wrong or no output.\n${v}") ; throw new Exception("Wrong Output")
|
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
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
|
38 |
} |
|
8778d23fef92
updated marking scripts
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |