| author | Christian Urban <christian.urban@kcl.ac.uk> | 
| Mon, 03 Feb 2025 12:34:38 +0000 | |
| changeset 977 | 7a02c5b9e0df | 
| permissions | -rw-r--r-- | 
| 
977
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
1  | 
// for testing evaluation  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
2  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
3  | 
import scala.util.{Try, Success, Failure}
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
4  | 
import $file.cw034_add  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
5  | 
import cw034_add._  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
6  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
7  | 
val str = os.read(os.pwd / "test.while")  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
8  | 
val output = "1\n"  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
9  | 
|
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
10  | 
Try(test_string(str)) match {
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
11  | 
case Success(v) if urban == output => Console.println(s"Generated the correct output\n\"\"\"$urban\"\"\"")  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
12  | 
  case Success(v) => Console.println(s"Generated\n\"\"\"$urban\"\"\"\ninstead of\n\"\"\"$output\"\"\"") ; throw new Exception("Different")
 | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
13  | 
case Failure(e) => Console.println(s"Exception raised.") ; throw(e)  | 
| 
 
7a02c5b9e0df
updated marking scripts
 
Christian Urban <christian.urban@kcl.ac.uk> 
parents:  
diff
changeset
 | 
14  | 
}  |