cw3_marking/c5.sc
changeset 978 8778d23fef92
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cw3_marking/c5.sc	Mon Feb 03 12:34:38 2025 +0000
@@ -0,0 +1,14 @@
+// for testing evaluation
+
+import scala.util.{Try, Success, Failure}
+import $file.cw034_add
+import cw034_add._
+
+val str = os.read(os.pwd / "test.while")
+val output = "1\n"
+
+Try(test_string(str)) match {
+  case Success(v) if urban == output => Console.println(s"Generated the correct output\n\"\"\"$urban\"\"\"")
+  case Success(v) => Console.println(s"Generated\n\"\"\"$urban\"\"\"\ninstead of\n\"\"\"$output\"\"\"") ; throw new Exception("Different")
+  case Failure(e) => Console.println(s"Exception raised.") ; throw(e)
+}