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-- |
92
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
|
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
import scala.concurrent._ |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
import scala.concurrent.duration._ |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
import ExecutionContext.Implicits.global |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
import scala.language.postfixOps |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
|
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
|
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
lazy val f = Future { |
cfff88de2ff5
updatd
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'))) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
assert(ders(List('b'), EVIL) == ONE) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
assert(ders(List('b','b'), EVIL) == ZERO) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
assert(matcher(EVIL, "a" * 5 ++ "b") == true) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
assert(matcher(EVIL, "b") == true) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
assert(matcher(EVIL, "bb") == false) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
assert(matcher("abc", "abc") == true) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
assert(matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
assert(matcher(ONE, "") == true) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
assert(matcher(ZERO, "") == false) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
assert(matcher(ONE | CHAR('a'), "") == true) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
assert(matcher(ONE | CHAR('a'), "a") == true) |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
} |
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
|
cfff88de2ff5
updatd
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
Await.result(f, 90 second) |