--- a/exps/bit-test.scala Fri May 10 17:23:28 2019 +0100
+++ b/exps/bit-test.scala Tue May 14 21:43:11 2019 +0100
@@ -419,7 +419,7 @@
(result, (end - start))
}
-//size: of a Aregx for testing purposes
+//size: of a Rrexp and ARexp for testing purposes
def size(r: Rexp) : Int = r match {
case ZERO => 1
case ONE => 1
@@ -690,6 +690,30 @@
enum(2, "abc").map(tests_ders_bsimp(strs(1, "abc"))).
flatten.toSet.flatten.minBy(a => asize(a._1))
+// tests about good
+def good (a: ARexp) : Boolean = a match {
+ case AZERO => false
+ case AONE(_) => true
+ case APRED(_, _, _) => true
+ case AALTS(_, Nil) => false
+ case AALTS(_, rs) => rs.forall(good(_))
+ case ASEQ(_, r1, r2) => good(r1) & good(r2)
+ case ASTAR(_, _) => true
+}
+
+def tests_good(r: Rexp) = {
+ val a = bsimp(internalise(r))
+ if (! good(a) & a != AZERO) {
+ println(s"Counter-example on ${astring(a)}")
+ Some(a)
+ } else None
+}
+
+enum(2, "abc").map(tests_good).toSet
+
+val g1 = AALTS(Nil, Nil)
+good(g1)
+good(bsimp(g1))
//tests retrieve and lexing