921
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
#!/usr/bin/env -S scala-cli shebang -no-indent
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
//> using scala "3.3.1"
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
//> using toolkit latest
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
// course work directories
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
val cws = List("cw1", "cw2", "cw3", "cw4", "cw5")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
// main files that need testing
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
val files = Map("cw1" -> "cw1.sc",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
"cw2" -> "lexer.sc",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
"cw3" -> "parser.sc",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
"cw4" -> "compiler.sc",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
"cw5" -> "fun_llvm.sc"
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
// test files used as input
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
val test_files = Map(
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
"cw1" -> Nil,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
"cw2" -> List("collatz.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
"collatz2.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
"factors.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
"fib.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
"loops.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
"primes.while"),
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
"cw3" -> List("collatz.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
"collatz2.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
27 |
"factors.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
28 |
"fib.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
"loops.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
"primes.while"),
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
"cw4" -> List("collatz2.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
"fib.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
"forloop.while",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
"forloop2.while"),
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
"cw5" -> List("fact.fun",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
"hanoi.fun",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
"mand.fun",
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
38 |
"mand2.fun")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
40 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
41 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
42 |
for (cw <- cws) {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
43 |
val main_file = files(cw)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
44 |
for (arg <- test_files(cw)) {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
45 |
println(s"Testing $cw/$main_file with $arg")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
46 |
val subdir = os.pwd / cw
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
47 |
os.proc("amm", main_file, "test", arg).call(cwd = subdir)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
48 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
49 |
}
|