cw4_marking/c4.sc
changeset 978 8778d23fef92
equal deleted inserted replaced
977:1e6eca42d90b 978:8778d23fef92
       
     1 // for testing compilation
       
     2 import scala.util.{Try, Success, Failure}
       
     3 
       
     4 
       
     5 val res = {
       
     6   if (os.exists(os.pwd / "br.class")) 
       
     7     os.proc("java", "br").call(cwd = os.pwd)
       
     8   else if (os.exists(os.pwd / "br" / "br.class")) 
       
     9     os.proc("java", "br.br").call(cwd = os.pwd)
       
    10   else throw new Exception("No CLASS file found")
       
    11 }
       
    12 
       
    13 if (res.exitCode != 0) {
       
    14   throw new Exception("Unsuccessful call")
       
    15 }
       
    16 
       
    17 Try(res.out.text().replace("\n", "") == "23467") match {
       
    18   case Success(v) => Console.println(s"   Success. Printed ${res.out.text().replace("\n", "")}.")
       
    19   case Failure(e) => Console.println(s"   Fail. Printed ${res.out.text()} instead of \"2,3,4,6,7\"\n") ; throw(e)
       
    20 }
       
    21