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

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

[elpa] master a193f4e 08/16: Refactor position level assertion.


From: Jackson Ray Hamilton
Subject: [elpa] master a193f4e 08/16: Refactor position level assertion.
Date: Sun, 18 Oct 2015 11:21:44 +0000

branch: master
commit a193f4e870a1c0a66a4ddd2ad79d3998f40330c8
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Refactor position level assertion.
---
 test/context-coloring-test.el |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index e267941..c8574da 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -365,21 +365,21 @@ signaled."
 
 ;;; Coloring tests
 
+(defun context-coloring-test-face-to-level (face)
+  "Convert FACE symbol to its corresponding level, or nil."
+  (when face
+    (let* ((face-string (symbol-name face))
+           (matches (string-match
+                     context-coloring-level-face-regexp
+                     face-string)))
+      (when matches
+        (string-to-number (match-string 1 face-string))))))
+
 (defun context-coloring-test-assert-position-level (position level)
   "Assert that POSITION has LEVEL."
-  (let ((face (get-text-property position 'face))
-        actual-level)
-    (when (not (and face
-                    (let* ((face-string (symbol-name face))
-                           (matches (string-match
-                                     context-coloring-level-face-regexp
-                                     face-string)))
-                      (when matches
-                        (setq actual-level (string-to-number
-                                            (substring face-string
-                                                       (match-beginning 1)
-                                                       (match-end 1))))
-                        (= level actual-level)))))
+  (let* ((face (get-text-property position 'face))
+         (actual-level (context-coloring-test-face-to-level face)))
+    (when (not (= level actual-level))
       (ert-fail (format (concat "Expected level at position %s, "
                                 "which is \"%s\", to be %s; "
                                 "but it was %s")



reply via email to

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