marking/re1d_test.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 20 Dec 2016 01:48:09 +0000
changeset 92 cfff88de2ff5
child 93 21f41e08457d
permissions -rw-r--r--
updatd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
92
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
import scala.concurrent._
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
import scala.concurrent.duration._
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
import ExecutionContext.Implicits.global
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
import scala.language.postfixOps 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
lazy val f = Future {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
  assert(ders(List.fill(5)('a'), EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b')))
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
  assert(ders(List('b'), EVIL) == ONE)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
  assert(ders(List('b','b'), EVIL) == ZERO)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
  assert(matcher(EVIL, "a" * 5 ++ "b") == true)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
  assert(matcher(EVIL, "b") == true)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
  assert(matcher(EVIL, "bb") == false)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
  assert(matcher("abc", "abc") == true)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
  assert(matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
  assert(matcher(ONE, "") == true)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
  assert(matcher(ZERO, "") == false)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
  assert(matcher(ONE | CHAR('a'), "") == true)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
  assert(matcher(ONE | CHAR('a'), "a") == true)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
Await.result(f, 90 second)