1 import M5b._ |
1 import M5b._ |
2 |
2 |
3 assert(optimise(load_bff("benchmark.bf")).length == 181) |
3 import io.Source |
4 assert(optimise(load_bff("mandelbrot.bf")).length == 11205) |
4 import scala.util._ |
5 |
5 |
|
6 def urban_load_bff(name: String) : String = |
|
7 Try(Source.fromFile(name)("ISO-8859-1").mkString).getOrElse("") |
6 |
8 |
|
9 import scala.concurrent._ |
|
10 import scala.concurrent.duration._ |
|
11 import ExecutionContext.Implicits.global |
|
12 import scala.language.postfixOps |
7 |
13 |
8 assert(run3("[-]", Map(0 -> 100)) == Map(0 -> 0)) |
14 lazy val f = Future { |
9 assert(run3("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)) |
15 assert(optimise(urban_load_bff("benchmark.bf")).length == 181) |
10 assert(run3("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)) |
16 assert(optimise(urban_load_bff("sierpinski.bf")).length == 110) |
11 val hw_urban2 = """+++++[->++++++++++<]>--<+++[->>++++++++++ |
17 |
|
18 assert(run3("[-]", Map(0 -> 100)) == Map(0 -> 0)) |
|
19 assert(run3("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10)) |
|
20 assert(run3("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42)) |
|
21 val hw_urban2 = """+++++[->++++++++++<]>--<+++[->>++++++++++ |
12 <<]>>++<<----------[+>.>.<+<]""" |
22 <<]>>++<<----------[+>.>.<+<]""" |
13 assert(run3(hw_urban2) == Map(0 -> 0, 1 -> 58, 2 -> 32)) |
23 assert(run3(hw_urban2) == Map(0 -> 0, 1 -> 58, 2 -> 32)) |
14 |
24 |
15 val hw_urban3 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---. |
25 val hw_urban3 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---. |
16 +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.""" |
26 +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.""" |
17 |
27 |
18 assert(run3(hw_urban3) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)) |
28 assert(run3(hw_urban3) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87)) |
|
29 |
|
30 } |
|
31 |
|
32 Await.result(f, 32 second) |
|
33 |