From 62b8317cc99de564322992b45666c0a9f715777f Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 27 Apr 2024 11:24:00 -0700 Subject: [PATCH] Added tests --- examples/tests.modal | 13 +++++++++++++ src/modal.c | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/tests.modal b/examples/tests.modal index 62acf6e..68e7c8f 100644 --- a/examples/tests.modal +++ b/examples/tests.modal @@ -93,6 +93,19 @@ reverse (modal) = ladom (reverse 1) test nap tap (inline 1) test +?(?-) (Undefinition) + +<> (undefine-me) (abc) +<> (undefine-me) (def) +<> (undefine-me) (ghi) +>< (undefine-me) + +(undefine-me) = (def) (undefinition 1) test + +>< (undefine-me) + +(undefine-me) = (ghi) (undefinition 2) test + ?(?-) (Late Test Primitives) <> (?x = ?y ?n test) (?(?: ?:) (#fail ?n found: ?x expect: ?y\n)) \ No newline at end of file diff --git a/src/modal.c b/src/modal.c index af90ee5..221ade7 100644 --- a/src/modal.c +++ b/src/modal.c @@ -196,8 +196,9 @@ find_rule(char *s, char *cap) if(*s == '(') s++, cap--; while(r < rules_) { char *ss = s, *a = r->a; - while(*ss++ == *a++) - if(!*a && ss == cap) return r; + if(a) + while(*ss++ == *a++) + if(!*a && ss == cap) return r; r++; } return r;