cw3_marking/c5.sc
changeset 977 7a02c5b9e0df
equal deleted inserted replaced
976:4be299d9b41b 977:7a02c5b9e0df
       
     1 // for testing evaluation
       
     2 
       
     3 import scala.util.{Try, Success, Failure}
       
     4 import $file.cw034_add
       
     5 import cw034_add._
       
     6 
       
     7 val str = os.read(os.pwd / "test.while")
       
     8 val output = "1\n"
       
     9 
       
    10 Try(test_string(str)) match {
       
    11   case Success(v) if urban == output => Console.println(s"Generated the correct output\n\"\"\"$urban\"\"\"")
       
    12   case Success(v) => Console.println(s"Generated\n\"\"\"$urban\"\"\"\ninstead of\n\"\"\"$output\"\"\"") ; throw new Exception("Different")
       
    13   case Failure(e) => Console.println(s"Exception raised.") ; throw(e)
       
    14 }