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

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

[elpa] master 32809ad 30/60: Add parsec-error-new-2


From: Junpeng Qiu
Subject: [elpa] master 32809ad 30/60: Add parsec-error-new-2
Date: Tue, 25 Oct 2016 17:45:14 +0000 (UTC)

branch: master
commit 32809ad80d5af6281a5a70727c74ecd659c73364
Author: Junpeng Qiu <address@hidden>
Commit: Junpeng Qiu <address@hidden>

    Add parsec-error-new-2
---
 parsec-tests.el |   18 +++++++-----------
 parsec.el       |   11 +++++++----
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/parsec-tests.el b/parsec-tests.el
index 5e8abd0..63721b3 100644
--- a/parsec-tests.el
+++ b/parsec-tests.el
@@ -27,10 +27,6 @@
 (require 'ert)
 (require 'parsec)
 
-(defun test-parsec-error-new (expected found)
-  (parsec-error-new (format "Found \"%s\" -> Expected \"%s\""
-                            found expected)))
-
 (ert-deftest test-parsec-ch ()
   (should
    (equal
@@ -88,7 +84,7 @@
     (parsec-with-input "\ra"
       (parsec-eol)
       (parsech-ch ?a))
-    (test-parsec-error-new "\n" "a"))))
+    (parsec-error-new-2 "\n" "a"))))
 
 (ert-deftest test-parsec-eof ()
   (should
@@ -153,7 +149,7 @@
     (parsec-with-input "abc"
       (parsec-or (parsec-string "ac")
                  (parsec-ch ?a)))
-    (test-parsec-error-new "c" "b")))
+    (parsec-error-new-2 "c" "b")))
   (should
    (equal
     (parsec-with-input "abc"
@@ -173,7 +169,7 @@
     (parsec-with-input "124"
       (parsec-or (parsec-string "13")
                  (parsec-ch ?1)))
-    (test-parsec-error-new "3" "2")))
+    (parsec-error-new-2 "3" "2")))
   (should
    (equal
     (parsec-with-input "124"
@@ -262,12 +258,12 @@
        (parsec-many-as-string (parsec-ch ?c))
        (parsec-many1-as-string (parsec-ch ?b))
        (parsec-many1-as-string (parsec-ch ?c))))
-    (test-parsec-error-new "c" "`EOF'")))
+    (parsec-error-new-2 "c" "`EOF'")))
   (should
    (equal
     (parsec-with-input "abababaa"
       (parsec-many1-as-string (parsec-string "ab")))
-    (test-parsec-error-new "b" "a")))
+    (parsec-error-new-2 "b" "a")))
   (should
    (equal
     (parsec-with-input "abababaa"
@@ -364,7 +360,7 @@
        (parsec-or
         (parsec-string "ac")
         (parsec-many-as-string (parsec-letter)))))
-    (test-parsec-error-new "c" "b"))))
+    (parsec-error-new-2 "c" "b"))))
 
 (ert-deftest test-parsec-count ()
   (should
@@ -379,7 +375,7 @@
    (equal
     (parsec-with-input "ab"
       (parsec-option "opt" (parsec-string "ac")))
-    (test-parsec-error-new "c" "b")))
+    (parsec-error-new-2 "c" "b")))
   (should
    (equal
     (parsec-with-input "ab"
diff --git a/parsec.el b/parsec.el
index d6283a0..8c9b2e2 100644
--- a/parsec.el
+++ b/parsec.el
@@ -41,6 +41,10 @@
 (defun parsec-error-new (msg)
   (cons 'parsec-error msg))
 
+(defun parsec-error-new-2 (expected found)
+  (parsec-error-new (format "Found \"%s\" -> Expected \"%s\""
+                            found expected)))
+
 (defun parsec-error-p (obj)
   (and (consp obj)
        (eq (car obj) 'parsec-error)))
@@ -59,10 +63,9 @@
            (when (or (stringp msg)
                      (and (stringp expected)
                           (stringp found)))
-             (parsec-error-new (if (stringp msg)
-                                   msg
-                                 (format "Found \"%s\" -> Expected \"%s\""
-                                         found expected))))))))
+             (if (stringp msg)
+                 (parsec-error-new msg)
+               (parsec-error-new-2 expected found)))))))
 
 (defun parsec-ch (ch)
   (let ((next-char (char-after)))



reply via email to

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