equal
  deleted
  inserted
  replaced
  
    
    
|         |      1 // for testing tokenisation | 
|         |      2  | 
|         |      3 import scala.util.{Try, Success, Failure} | 
|         |      4 import $file.cw05_add | 
|         |      5 import cw05_add._ | 
|         |      6  | 
|         |      7 // programs to test (and number of toplevel definitions) | 
|         |      8 val uprogs = List(("fact.fun",  5),  | 
|         |      9                   ("hanoi.fun", 2), | 
|         |     10 		  ("mand.fun", 11),  | 
|         |     11 		  ("sqr.fun",   4))  | 
|         |     12  | 
|         |     13 for ((file, no) <- uprogs) { | 
|         |     14  | 
|         |     15   print(s"Testing Parsing of $file ") | 
|         |     16   val str = os.read(os.pwd / file) | 
|         |     17    | 
|         |     18  | 
|         |     19   Try(test_string(str).length) match { | 
|         |     20     case Success(v) if v == no => println(s"--> Success. Parsed $no top-level definitions.") | 
|         |     21     case Success(v) => println(s"--> Success? Parsed $v top-level definitions (should be $no).")// ; throw new Exception("Different") | 
|         |     22     case Failure(e) => println(s"--> FAIL. Exception raised.") ; throw(e) | 
|         |     23   } | 
|         |     24 } |