main_testing3/re_test3.scala
changeset 347 4de31fdc0d67
parent 300 72688efdf17c
child 403 ffce7b61b446
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main_testing3/re_test3.scala	Mon Nov 02 02:31:44 2020 +0000
@@ -0,0 +1,21 @@
+import CW8c._
+
+
+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) ~ CHAR('a')) == CHAR('a'))
+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(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a'))
+assert(simp(ONE | CHAR('a')) == (ONE | CHAR('a')))
+assert(simp(ALT((CHAR('a') | ZERO) ~ ONE,
+                  ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a'))
+assert(simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO)
+assert(simp(ALT(ONE | ONE, ONE | ONE)) == ONE)
+assert(simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a'))
+assert(simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE | CHAR('a'), CHAR('a') | ONE))
+
+