add new regression tests: lifts, epsilon conjunct
authoradam <adam@megacz.com>
Sun, 27 May 2007 20:18:33 +0000 (16:18 -0400)
committeradam <adam@megacz.com>
Sun, 27 May 2007 20:18:33 +0000 (16:18 -0400)
darcs-hash:20070527201833-5007d-0665414b3f03f123189c2b5847883cd7052b0c11.gz

tests/regression.tc

index 4b1b397..80b83c8 100644 (file)
@@ -208,7 +208,7 @@ testcase "a+b-d*c" {
     idl    = [a-d]
 }
 
     idl    = [a-d]
 }
 
-testcase "a+b*c" {
+testcase "priority" {
     input "a+b*c";
     output "plus:{stringify:{a} times:{stringify:{b} stringify:{c}}}";
     w    = " "
     input "a+b*c";
     output "plus:{stringify:{a} times:{stringify:{b} stringify:{c}}}";
     w    = " "
@@ -225,6 +225,23 @@ testcase "a+b*c" {
     idl    = [a-d]
 }
 
     idl    = [a-d]
 }
 
+testcase "associativity" {
+    input "a*b*c";
+    output "times:{stringify:{a} times:{stringify:{b} stringify:{c}}}";
+    w    = " "
+    l    = id
+    s    = assign:: l "=" r
+         | r
+    r    = l
+         | assign:: l "=" r
+         | plus:: r "+" r
+         | times:: r "*" (r)
+         | "(" r ")"
+         | times:: r r
+    id     = stringify:: idl++
+    idl    = [a-d]
+}
+
 testcase "unnamed" {
   input "aa bb";
   output "{q:{a a} q:{b b}}";
 testcase "unnamed" {
   input "aa bb";
   output "{q:{a a} q:{b b}}";
@@ -413,3 +430,27 @@ testcase "operator: ~~" {
   B:: = ~~(... "bbb" ...)
   C:: = [ab]*
 }
   B:: = ~~(... "bbb" ...)
   C:: = [ab]*
 }
+
+testcase "lifts" {
+    input "a+(b*c)";
+    output "+:{a *:{id:{b} c}}";
+
+    s     = r
+    r     = id
+          | r ^"*" `r
+          | `r ^"+" r
+          | "(" r ")"
+    id::  = [a-z]++
+}
+
+testcase "epsilon as a positive conjunct" {
+    input "abababab";
+    s:: = X*
+    X:: = "a" ("b"+ & ())
+}
+
+testcase "epsilon as a negative conjunct" {
+    input "aaaaa";
+    s:: = X*
+    X:: = "a" ("b"* &~ ())
+}