424
|
1 |
import M5a._
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
|
463
|
3 |
|
|
4 |
import scala.concurrent._
|
|
5 |
import scala.concurrent.duration._
|
|
6 |
import ExecutionContext.Implicits.global
|
|
7 |
import scala.language.postfixOps
|
|
8 |
|
|
9 |
lazy val f = Future {
|
|
10 |
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
assert(run("[-]", Map(0 -> 100)) == Map(0 -> 0))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
assert(run("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
assert(run("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
|
424
|
14 |
|
392
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
val hw_urban = """+++++[->++++++++++<]>--<+++[->>++++++++++
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
<<]>>++<<----------[+>.>.<+<]"""
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
assert(run(hw_urban) == Map(0 -> 0, 1 -> 58, 2 -> 32))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
val hw_urban1 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
assert(run(hw_urban1) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
|
463
|
24 |
|
|
25 |
}
|
|
26 |
|
|
27 |
Await.result(f, 32 second)
|
|
28 |
|