marking/re1d_test.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 21 Dec 2016 01:19:25 +0000
changeset 93 21f41e08457d
parent 92 cfff88de2ff5
permissions -rw-r--r--
updated
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
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
     8
val EVIL_urban = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
92
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 {
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    11
  println("1")
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    12
  assert(ders(List.fill(5)('a'), EVIL_urban) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b')))
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    13
  println("2")
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    14
  assert(ders(List('b'), EVIL_urban) == ONE)
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    15
  println("3")
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    16
  assert(ders(List('b','b'), EVIL_urban) == ZERO)
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    17
  println("4")
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    18
  assert(matcher(EVIL_urban, "a" * 5 ++ "b") == true)
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    19
  println("5")
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    20
  assert(matcher(EVIL_urban, "b") == true)
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    21
  println("6") 
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    22
  assert(matcher(EVIL_urban, "bb") == false)
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    23
  println("7")
92
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
  assert(matcher("abc", "abc") == true)
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    25
  println("8")
92
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
  assert(matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true)
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    27
  println("9")
92
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
  assert(matcher(ONE, "") == true)
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    29
  println("10")
92
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
  assert(matcher(ZERO, "") == false)
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    31
  println("11")
92
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
  assert(matcher(ONE | CHAR('a'), "") == true)
93
21f41e08457d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
    33
  println("12")
92
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
  assert(matcher(ONE | CHAR('a'), "a") == true)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
Await.result(f, 90 second)