diff options
Diffstat (limited to 'test/lisp/progmodes/peg-tests.el')
-rw-r--r-- | test/lisp/progmodes/peg-tests.el | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/lisp/progmodes/peg-tests.el b/test/lisp/progmodes/peg-tests.el index 8fab549bcab..b9e9c47ab7c 100644 --- a/test/lisp/progmodes/peg-tests.el +++ b/test/lisp/progmodes/peg-tests.el @@ -180,6 +180,20 @@ resp. succeeded instead of signaling an error." (should (eobp))) ) +(define-peg-ruleset peg-test-myrules + (sign () (or "+" "-" "")) + (digit () [0-9]) + (nat () digit (* digit)) + (int () sign digit (* digit)) + (float () int "." nat)) + +(ert-deftest peg-test-ruleset () + (with-peg-rules + (peg-test-myrules + (complex float "+i" float)) + (should (peg-parse-string nat "123" t)) + (should (not (peg-parse-string nat "home" t))))) + ;;; Examples: ;; peg-ex-recognize-int recognizes integers. An integer begins with a |