| author | Christian Urban <christian.urban@kcl.ac.uk> | 
| Sat, 04 Oct 2025 22:28:07 +0100 | |
| changeset 999 | 1d3c195a9f14 | 
| parent 977 | 7a02c5b9e0df | 
| permissions | -rw-r--r-- | 
| 
977
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
1  | 
// for testing compilation  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
2  | 
import scala.util.{Try, Success, Failure}
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
3  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
4  | 
//println("TEST1")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
5  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
6  | 
val res = {
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
7  | 
if (os.exists(os.pwd / "mand.ll"))  | 
| 
 
7a02c5b9e0df
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)
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
9  | 
  else throw new Exception("No CLASS file found")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
10  | 
}  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
11  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
12  | 
//println("TEST2")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
13  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
14  | 
/*  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
15  | 
if (res.exitCode != 0) {
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
16  | 
  throw new Exception("Unsuccessful call")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
17  | 
}  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
18  | 
*/  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
19  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
20  | 
def pp(s1: String, s2: String) = {
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
21  | 
  val s1a = s1.split("\n").toList
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
22  | 
  val s2a = s2.split("\n").toList
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
23  | 
  for (n <- 0 to (s1a.length - 1)) {
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
24  | 
    println(s"|${s1a(n)}|")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
25  | 
    println(s">${Try(s2a(n)).getOrElse("")}<")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
26  | 
}  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
27  | 
}  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
28  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
29  | 
//println("TEST3")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
30  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
31  | 
val out = os.read(os.pwd / "mand.out")  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
32  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
33  | 
//println("TEST4")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
34  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
35  | 
Try(res.out.text()) match {
 | 
| 
 
7a02c5b9e0df
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")  | 
| 
 
7a02c5b9e0df
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")
 | 
| 
 
7a02c5b9e0df
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)
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
39  | 
}  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
40  |