--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cw5_marking/c6.sc Mon Feb 03 12:34:38 2025 +0000
@@ -0,0 +1,39 @@
+// for testing compilation
+import scala.util.{Try, Success, Failure}
+
+//println("TEST1")
+
+val res = {
+ if (os.exists(os.pwd / "sqr.ll"))
+ os.proc("lli", "sqr.ll").call(cwd = os.pwd, check = false)
+ else throw new Exception("No CLASS file found")
+}
+
+//println("TEST2")
+
+/*
+if (res.exitCode != 0) {
+ throw new Exception("Unsuccessful call")
+}
+*/
+
+def pp(s1: String, s2: String) = {
+ val s1a = s1.replace("\n","").replace(" ","")
+ val s2a = s2.replace("\n","")
+ s1a == s2a
+}
+
+//println("TEST3")
+
+val out = "Squares0149162536496481100"
+val out2 = "\"Squares\"0149162536496481100"
+
+
+//println("TEST4")
+
+Try(res.out.text()) match {
+ case Success(v) if (pp(v, out) || pp(v, out2)) => println(s" Success. Printed out the correct output.\n")
+ case Success(v) => println(s" Printed out wrong or no output.\n${v}") ; throw new Exception("Wrong Output")
+ case Failure(e) => println(s" Fail. Printed ${res.out.text()} instead\n") ; throw(e)
+}
+