[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/php-mode 9aecbf035a 1/2: Refactor :magic test
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/php-mode 9aecbf035a 1/2: Refactor :magic test |
Date: |
Thu, 15 Sep 2022 10:59:09 -0400 (EDT) |
branch: elpa/php-mode
commit 9aecbf035a42f8030c983dea7a0281b78d74ebb2
Author: USAMI Kenta <tadsan@zonu.me>
Commit: USAMI Kenta <tadsan@zonu.me>
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/php-mode 9aecbf035a 1/2: Refactor :magic test,
ELPA Syncer <=