equal
deleted
inserted
replaced
|
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 / "primes.while") |
|
8 val resmap = Map("end" -> 100, "n" -> 100, "f" -> 4, "tmp" -> 1) |
|
9 |
|
10 def mapeq[A, B](m1: Map[A, B], m2: Map[A, B]) : Boolean = { |
|
11 m1.keySet.forall(k => m1(k) == m2(k)) |
|
12 } |
|
13 |
|
14 |
|
15 Try(test_string(str)) match { |
|
16 case Success(v) if mapeq(resmap, v) => Console.println(s" Generated the correct result $v") |
|
17 case Success(v) => Console.println(s" Generated $v\n instead of\n $resmap\n.") ; throw new Exception("Different") |
|
18 case Failure(e) => Console.println(s" Exception raised.") ; throw(e) |
|
19 } |