emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/peg ecac802 1/3: * peg-tests.el (peg-test): Define as E


From: Stefan Monnier
Subject: [elpa] externals/peg ecac802 1/3: * peg-tests.el (peg-test): Define as ERT test
Date: Mon, 11 Mar 2019 11:30:25 -0400 (EDT)

branch: externals/peg
commit ecac802ff994c1d347a99d8c743e8b7b6d44f973
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * peg-tests.el (peg-test): Define as ERT test
---
 peg-tests.el | 127 +++++++++++++++++++++++++++++------------------------------
 1 file changed, 62 insertions(+), 65 deletions(-)

diff --git a/peg-tests.el b/peg-tests.el
index 8d1e1d5..0afaf32 100644
--- a/peg-tests.el
+++ b/peg-tests.el
@@ -26,87 +26,86 @@
 
 ;;; Tests:
 
-(defun peg-test ()
-  (interactive)
-  (cl-assert (peg-parse-string ((s "a")) "a" t))
-  (cl-assert (not (peg-parse-string ((s "a")) "b" t)))
-  (cl-assert (peg-parse-string ((s (not "a"))) "b" t))
-  (cl-assert (not (peg-parse-string ((s (not "a"))) "a" t)))
-  (cl-assert (peg-parse-string ((s (if "a"))) "a" t))
-  (cl-assert (not (peg-parse-string ((s (if "a"))) "b" t)))
-  (cl-assert (peg-parse-string ((s "ab")) "ab" t))
-  (cl-assert (not (peg-parse-string ((s "ab")) "ba" t)))
-  (cl-assert (not (peg-parse-string ((s "ab")) "a" t)))
-  (cl-assert (peg-parse-string ((s (range ?0 ?9))) "0" t))
-  (cl-assert (not (peg-parse-string ((s (range ?0 ?9))) "a" t)))
-  (cl-assert (peg-parse-string ((s [0-9])) "0" t))
-  (cl-assert (not (peg-parse-string ((s [0-9])) "a" t)))
-  (cl-assert (not (peg-parse-string ((s [0-9])) "" t)))
-  (cl-assert (peg-parse-string ((s (any))) "0" t))
-  (cl-assert (not (peg-parse-string ((s (any))) "" t)))
-  (cl-assert (peg-parse-string ((s (eob))) "" t))
-  (cl-assert (peg-parse-string ((s (not (eob)))) "a" t))
-  (cl-assert (peg-parse-string ((s (or "a" "b"))) "a" t))
-  (cl-assert (peg-parse-string ((s (or "a" "b"))) "b" t))
-  (cl-assert (not (peg-parse-string ((s (or "a" "b"))) "c" t)))
-  (cl-assert (peg-parse-string ((s (and "a" "b"))) "ab" t))
-  (cl-assert (peg-parse-string ((s (and "a" "b"))) "abc" t))
-  (cl-assert (not (peg-parse-string ((s (and "a" "b"))) "ba" t)))
-  (cl-assert (peg-parse-string ((s (and "a" "b" "c"))) "abc" t))
-  (cl-assert (peg-parse-string ((s (* "a") "b" (eob))) "b" t))
-  (cl-assert (peg-parse-string ((s (* "a") "b" (eob))) "ab" t))
-  (cl-assert (peg-parse-string ((s (* "a") "b" (eob))) "aaab" t))
-  (cl-assert (not (peg-parse-string ((s (* "a") "b" (eob))) "abc" t)))
-  (cl-assert (peg-parse-string ((s "")) "abc" t))
-  (cl-assert (peg-parse-string ((s "" (eob))) "" t))
-  (cl-assert (peg-parse-string ((s (opt "a") "b")) "abc" t))
-  (cl-assert (peg-parse-string ((s (opt "a") "b")) "bc" t))
-  (cl-assert (not (peg-parse-string ((s (or))) "ab" t)))
-  (cl-assert (peg-parse-string ((s (and))) "ab" t))
-  (cl-assert (peg-parse-string ((s (and))) "" t))
-  (cl-assert (peg-parse-string ((s ["^"])) "^" t))
-  (cl-assert (peg-parse-string ((s ["^a"])) "a" t))
-  (cl-assert (peg-parse-string ((s ["-"])) "-" t))
-  (cl-assert (peg-parse-string ((s ["]-"])) "]" t))
-  (cl-assert (peg-parse-string ((s ["^]"])) "^" t))
-  (cl-assert (peg-parse-string ((s [alpha])) "z" t))
-  (cl-assert (not (peg-parse-string ((s [alpha])) "0" t)))
-  (cl-assert (not (peg-parse-string ((s [alpha])) "" t)))
-  (cl-assert (not (peg-parse-string ((s ["][:alpha:]"])) "z" t)))
-  (cl-assert (peg-parse-string ((s (bob))) "" t))
-  (cl-assert (peg-parse-string ((s (bos))) "x" t))
-  (cl-assert (not (peg-parse-string ((s (bos))) " x" t)))
-  (cl-assert (peg-parse-string ((s "x" (eos))) "x" t))
-  (cl-assert (peg-parse-string ((s (syntax-class whitespace))) " " t))
-  (cl-assert (peg-parse-string ((s (= "foo"))) "foo" t))
-  (cl-assert (let ((f "foo")) (peg-parse-string ((s (= f))) "foo" t)))
-  (cl-assert (not (peg-parse-string ((s (= "foo"))) "xfoo" t)))
-  (cl-assert (equal (peg-parse-string ((s `(-- 1 2))) "") '(2 1)))
-  (cl-assert (equal (peg-parse-string ((s `(-- 1 2) `(a b -- a b))) "") '(2 
1)))
-  (cl-assert (equal (peg-parse-string ((s (or (and (any) s)
+(ert-deftest peg-test ()
+  (should (peg-parse-string ((s "a")) "a" t))
+  (should (not (peg-parse-string ((s "a")) "b" t)))
+  (should (peg-parse-string ((s (not "a"))) "b" t))
+  (should (not (peg-parse-string ((s (not "a"))) "a" t)))
+  (should (peg-parse-string ((s (if "a"))) "a" t))
+  (should (not (peg-parse-string ((s (if "a"))) "b" t)))
+  (should (peg-parse-string ((s "ab")) "ab" t))
+  (should (not (peg-parse-string ((s "ab")) "ba" t)))
+  (should (not (peg-parse-string ((s "ab")) "a" t)))
+  (should (peg-parse-string ((s (range ?0 ?9))) "0" t))
+  (should (not (peg-parse-string ((s (range ?0 ?9))) "a" t)))
+  (should (peg-parse-string ((s [0-9])) "0" t))
+  (should (not (peg-parse-string ((s [0-9])) "a" t)))
+  (should (not (peg-parse-string ((s [0-9])) "" t)))
+  (should (peg-parse-string ((s (any))) "0" t))
+  (should (not (peg-parse-string ((s (any))) "" t)))
+  (should (peg-parse-string ((s (eob))) "" t))
+  (should (peg-parse-string ((s (not (eob)))) "a" t))
+  (should (peg-parse-string ((s (or "a" "b"))) "a" t))
+  (should (peg-parse-string ((s (or "a" "b"))) "b" t))
+  (should (not (peg-parse-string ((s (or "a" "b"))) "c" t)))
+  (should (peg-parse-string ((s (and "a" "b"))) "ab" t))
+  (should (peg-parse-string ((s (and "a" "b"))) "abc" t))
+  (should (not (peg-parse-string ((s (and "a" "b"))) "ba" t)))
+  (should (peg-parse-string ((s (and "a" "b" "c"))) "abc" t))
+  (should (peg-parse-string ((s (* "a") "b" (eob))) "b" t))
+  (should (peg-parse-string ((s (* "a") "b" (eob))) "ab" t))
+  (should (peg-parse-string ((s (* "a") "b" (eob))) "aaab" t))
+  (should (not (peg-parse-string ((s (* "a") "b" (eob))) "abc" t)))
+  (should (peg-parse-string ((s "")) "abc" t))
+  (should (peg-parse-string ((s "" (eob))) "" t))
+  (should (peg-parse-string ((s (opt "a") "b")) "abc" t))
+  (should (peg-parse-string ((s (opt "a") "b")) "bc" t))
+  (should (not (peg-parse-string ((s (or))) "ab" t)))
+  (should (peg-parse-string ((s (and))) "ab" t))
+  (should (peg-parse-string ((s (and))) "" t))
+  (should (peg-parse-string ((s ["^"])) "^" t))
+  (should (peg-parse-string ((s ["^a"])) "a" t))
+  (should (peg-parse-string ((s ["-"])) "-" t))
+  (should (peg-parse-string ((s ["]-"])) "]" t))
+  (should (peg-parse-string ((s ["^]"])) "^" t))
+  (should (peg-parse-string ((s [alpha])) "z" t))
+  (should (not (peg-parse-string ((s [alpha])) "0" t)))
+  (should (not (peg-parse-string ((s [alpha])) "" t)))
+  (should (not (peg-parse-string ((s ["][:alpha:]"])) "z" t)))
+  (should (peg-parse-string ((s (bob))) "" t))
+  (should (peg-parse-string ((s (bos))) "x" t))
+  (should (not (peg-parse-string ((s (bos))) " x" t)))
+  (should (peg-parse-string ((s "x" (eos))) "x" t))
+  (should (peg-parse-string ((s (syntax-class whitespace))) " " t))
+  (should (peg-parse-string ((s (= "foo"))) "foo" t))
+  (should (let ((f "foo")) (peg-parse-string ((s (= f))) "foo" t)))
+  (should (not (peg-parse-string ((s (= "foo"))) "xfoo" t)))
+  (should (equal (peg-parse-string ((s `(-- 1 2))) "") '(2 1)))
+  (should (equal (peg-parse-string ((s `(-- 1 2) `(a b -- a b))) "") '(2 1)))
+  (should (equal (peg-parse-string ((s (or (and (any) s)
                                           (substring [0-9]))))
                                   "ab0cd1ef2gh")
                 '("2")))
-  (cl-assert (equal (peg-parse-string ((s (list x y))
+  (should (equal (peg-parse-string ((s (list x y))
                                    (x `(-- 1))
                                    (y `(-- 2)))
                                   "")
                 '((1 2))))
-  (cl-assert (equal (peg-parse-string ((s (list (* x)))
+  (should (equal (peg-parse-string ((s (list (* x)))
                                    (x "x" `(-- 'x)))
                                   "xxx")
                 '((x x x))))
-  (cl-assert (equal (peg-parse-string ((s (region (* x)))
+  (should (equal (peg-parse-string ((s (region (* x)))
                                    (x "x" `(-- 'x)))
                                   "xxx")
                  ;; FIXME: Since string positions start at 0, this should
                  ;; really be '(3 x x x 0) !!
                 '(4 x x x 1)))
-  (cl-assert (equal (peg-parse-string ((s (region (list (* x))))
+  (should (equal (peg-parse-string ((s (region (list (* x))))
                                    (x "x" `(-- 'x 'y)))
                                   "xxx")
                 '(4 (x y x y x y) 1)))
-  (cl-assert (equal (with-temp-buffer
+  (should (equal (with-temp-buffer
                   (save-excursion (insert "abcdef"))
                   (list
                    (peg-parse (x "a"
@@ -117,8 +116,6 @@
                 '(nil "axyf")))
   )
 
-(peg-test)
-
 ;;; Examples:
 
 ;; peg-ex-recognize-int recognizes integers.  An integer begins with a



reply via email to

[Prev in Thread] Current Thread [Next in Thread]