updatd
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 20 Dec 2016 01:48:09 +0000
changeset 92 cfff88de2ff5
parent 91 b43c81c65341
child 93 21f41e08457d
updatd
marking/re1c_test.scala
marking/re1d_test.scala
marking/re1e_test.scala
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking/re1c_test.scala	Tue Dec 20 01:48:09 2016 +0000
@@ -0,0 +1,19 @@
+
+import scala.concurrent._
+import scala.concurrent.duration._
+import ExecutionContext.Implicits.global
+import scala.language.postfixOps 
+
+
+
+lazy val f = Future {
+  assert(simp(ZERO | ONE) == ONE)
+  assert(simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE))
+  assert(simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a'))
+  assert(simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO)
+  assert(simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a'))
+  assert(simp(CHAR('a') | CHAR('a')) == CHAR('a'))
+  assert(simp(ONE | CHAR('a')) == (ONE | CHAR('a')))
+}
+
+Await.result(f, 30 second)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking/re1d_test.scala	Tue Dec 20 01:48:09 2016 +0000
@@ -0,0 +1,25 @@
+
+import scala.concurrent._
+import scala.concurrent.duration._
+import ExecutionContext.Implicits.global
+import scala.language.postfixOps 
+
+
+val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
+
+lazy val f = Future {
+  assert(ders(List.fill(5)('a'), EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b')))
+  assert(ders(List('b'), EVIL) == ONE)
+  assert(ders(List('b','b'), EVIL) == ZERO)
+  assert(matcher(EVIL, "a" * 5 ++ "b") == true)
+  assert(matcher(EVIL, "b") == true)
+  assert(matcher(EVIL, "bb") == false)
+  assert(matcher("abc", "abc") == true)
+  assert(matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true)
+  assert(matcher(ONE, "") == true)
+  assert(matcher(ZERO, "") == false)
+  assert(matcher(ONE | CHAR('a'), "") == true)
+  assert(matcher(ONE | CHAR('a'), "a") == true)
+}
+
+Await.result(f, 90 second)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking/re1e_test.scala	Tue Dec 20 01:48:09 2016 +0000
@@ -0,0 +1,14 @@
+
+import scala.concurrent._
+import scala.concurrent.duration._
+import ExecutionContext.Implicits.global
+import scala.language.postfixOps 
+
+
+
+lazy val f = Future {
+  assert(replace("aa".% | "bb", "aabbbaaaaaaabaaaaabbaaaabb" , "c") == "ccbcabcaccc")
+  assert(replace("aa".% | "bb", "abba" , "") == "aa")
+}
+
+Await.result(f, 120 second)