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 tokenise (and how many tokens)  | 
|         |      8 val uprogs = List(("fact.fun",  113),  | 
|         |      9                   ("hanoi.fun", 92), | 
|         |     10 		  ("mand.fun",  226), | 
|         |     11 		  ("mand2.fun", 245), | 
|         |     12 		  ("sqr.fun",   78)) | 
|         |     13  | 
|         |     14 for ((file, no) <- uprogs) { | 
|         |     15  | 
|         |     16   print(s"Testing tokenisation of $file ") | 
|         |     17   val str = os.read(os.pwd / file) | 
|         |     18  | 
|         |     19   Try(test_string(str)) match { | 
|         |     20     case Success(v) => println(s"--> Success. Lexed tokens.") | 
|         |     21     //case Success(v) => println(s"--> Success? Lexed ${v.length} tokens (should be $no).\n $v") ; throw new Exception("Different") | 
|         |     22     case Failure(e) => println(s"--> FAIL. Exception raised.") ; throw(e) | 
|         |     23   } | 
|         |     24 } |