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

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

[nongnu] elpa/php-mode 817ac846f1 2/2: Merge pull request #707 from emac


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode 817ac846f1 2/2: Merge pull request #707 from emacs-php/refactor/test-magic-comparison
Date: Thu, 15 Sep 2022 10:59:10 -0400 (EDT)

branch: elpa/php-mode
commit 817ac846f11d47760222702ca7b212049aa66be7
Merge: 6f9a471e5c 9aecbf035a
Author: USAMI Kenta <tadsan@pixiv.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #707 from emacs-php/refactor/test-magic-comparison
    
    Refactor :magic test
---
 tests/php-mode-test.el | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/tests/php-mode-test.el b/tests/php-mode-test.el
index f31b8daae9..3a9c4de4d4 100644
--- a/tests/php-mode-test.el
+++ b/tests/php-mode-test.el
@@ -63,22 +63,24 @@ These are the ###php-mode-test### comments. Valid magics are
 listed in `php-mode-test-valid-magics'; no other directives will
 be processed."
   (cl-letf (((symbol-function 'indent)
-             (lambda (offset) (equal (current-indentation) offset))))
+             (lambda (offset)
+               (let ((current-offset (current-indentation)))
+                 (unless (eq current-offset offset)
+                   (list :line (line-number-at-pos)
+                         :expected offset
+                         :actual current-offset))))))
     (let (directives answers)
       (save-excursion
         (goto-char (point-min))
-        (while (re-search-forward php-mode-test-magic-regexp nil t)
-          (setq directives (read (buffer-substring (match-beginning 1)
-                                                   (match-end 1))))
-          (setq answers
-                (append (mapcar (lambda (curr)
-                                  (let ((fn (car curr))
-                                        (args (mapcar 'eval (cdr-safe curr))))
-                                    (if (memq fn php-mode-test-valid-magics)
-                                        (apply fn args))))
-                                directives)
-                        answers))))
-      answers)))
+        (cl-loop while (re-search-forward php-mode-test-magic-regexp nil t)
+                 for directives = (read (buffer-substring (match-beginning 1) 
(match-end 1)))
+                 for result = (mapcar (lambda (expr)
+                                        (let ((fn (car expr))
+                                              (args (mapcar 'eval (cdr-safe 
expr))))
+                                          (if (memq fn 
php-mode-test-valid-magics)
+                                              (apply fn args))))
+                                      directives)
+                 append (cl-remove-if #'null result))))))
 
 (defun php-mode-test--buffer-face-list (buffer)
   "Return list of (STRING . FACE) from `BUFFER'."
@@ -154,8 +156,9 @@ file name and check that the faces of the fonts in the 
buffer match."
      ,(if indent
           '(let ((inhibit-message t)) (indent-region (point-min) (point-max))))
      ,(if magic
-          '(should (cl-reduce (lambda (l r) (and l r))
-                              (php-mode-test-process-magics))))
+          `(should (equal
+                    (cons ,file nil)
+                    (cons ,file (php-mode-test-process-magics)))))
      ,(if faces
           `(should (equal
                     (cons ,file



reply via email to

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