main_marking5/bf_test7.scala
changeset 463 0315d9983cd0
parent 424 daf561a83ba6
equal deleted inserted replaced
462:34feeb53c0ba 463:0315d9983cd0
     1 import M5b._
     1 import M5b._
     2 
     2 
     3 assert(combine(optimise(load_bff("benchmark.bf"))).length == 134)
     3 import io.Source
     4 assert(combine(optimise(load_bff("mandelbrot.bf"))).length == 6511)
     4 import scala.util._
       
     5 
       
     6 def urban_load_bff(name: String) : String = 
       
     7   Try(Source.fromFile(name)("ISO-8859-1").mkString).getOrElse("")
     5 
     8 
     6 
     9 
       
    10 
       
    11 import scala.concurrent._
       
    12 import scala.concurrent.duration._
       
    13 import ExecutionContext.Implicits.global
       
    14 import scala.language.postfixOps 
       
    15 
       
    16 lazy val f = Future {
       
    17 assert(combine(optimise(urban_load_bff("benchmark.bf"))).length == 134)
       
    18 assert(combine(optimise(urban_load_bff("sierpinski.bf"))).length == 122)
     7 
    19 
     8 assert(run4("[-]", Map(0 -> 100)) == Map(0 -> 0))
    20 assert(run4("[-]", Map(0 -> 100)) == Map(0 -> 0))
     9 assert(run4("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
    21 assert(run4("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
    10 assert(run4("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
    22 assert(run4("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
    11 val hw_urban2 = """+++++[->++++++++++<]>--<+++[->>++++++++++
    23 val hw_urban2 = """+++++[->++++++++++<]>--<+++[->>++++++++++
    14 
    26 
    15 val hw_urban3 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.
    27 val hw_urban3 = """++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.
    16                    +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
    28                    +++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."""
    17 
    29 
    18 assert(run4(hw_urban3) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
    30 assert(run4(hw_urban3) == Map(0 -> 0, 5 -> 33, 1 -> 0, 6 -> 10, 2 -> 72, 3 -> 100, 4 -> 87))
       
    31 }
       
    32 
       
    33 Await.result(f, 32 second)