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

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

[elpa] master 668e4b0 22/31: Merge pull request #880 from joaotavora/fix


From: Dmitry Gutov
Subject: [elpa] master 668e4b0 22/31: Merge pull request #880 from joaotavora/fix-tests-with-arbitrary-completion-properties
Date: Sun, 14 Apr 2019 22:06:19 -0400 (EDT)

branch: master
commit 668e4b05008c69ed74179be2634353f7810a1d17
Merge: f965786 1974d83
Author: Dmitry Gutov <address@hidden>
Commit: GitHub <address@hidden>

    Merge pull request #880 from 
joaotavora/fix-tests-with-arbitrary-completion-properties
    
    Make tests resilient to arbitrary text properties in completions
---
 test/capf-tests.el | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/test/capf-tests.el b/test/capf-tests.el
index c8d4202..80a204d 100644
--- a/test/capf-tests.el
+++ b/test/capf-tests.el
@@ -26,6 +26,7 @@
 
 (require 'company-tests)
 (require 'company-capf)
+(require 'cl-lib)
 
 (defmacro company-capf-with-buffer (contents &rest body)
   (declare (indent 0) (debug (sexp &rest form)))
@@ -55,6 +56,19 @@
     (should company-candidates)
     (should (member "with-current-buffer" company-candidates))))
 
+(defun company--remove-but-these-properties (string keep)
+  "Remove from STRING all text properties but the ones in KEEP."
+  (remove-list-of-text-properties
+   0 (length string)
+   (cl-set-difference
+    (cl-loop for start = 0 then (next-property-change start string)
+             while start
+             append (cl-loop for (k _v) on (text-properties-at start string)
+                             by #'cddr collect k))
+    keep)
+   string)
+  string)
+
 (ert-deftest company-basic-capf-highlighting ()
   "Test basic `company-capf' support, with basic prefix completion."
   (company-capf-with-buffer
@@ -66,10 +80,8 @@
            (render
             (and cand
                  (company-fill-propertize cand nil (length cand) nil nil 
nil))))
-      ;; remove `font-lock-face' and `mouse-face' text properties that aren't
-      ;; relevant to our test
-      (remove-list-of-text-properties
-       0 (length cand) '(font-lock-face mouse-face) render)
+      ;; remove text properties that aren't relevant to our test
+      (company--remove-but-these-properties render '(face))
       (should
        (ert-equal-including-properties
         render
@@ -99,10 +111,8 @@
            (render
             (and cand
                  (company-fill-propertize cand nil (length cand) nil nil 
nil))))
-      ;; remove `font-lock-face' and `mouse-face' text properties that aren't
-      ;; relevant to our test
-      (remove-list-of-text-properties
-       0 (length cand) '(font-lock-face mouse-face) render)
+      ;; remove text properties that aren't relevant to our test
+      (company--remove-but-these-properties render '(face))
       (should
        (ert-equal-including-properties
         render
@@ -125,10 +135,8 @@
            (render
             (and cand
                  (company-fill-propertize cand nil (length cand) nil nil 
nil))))
-      ;; remove `font-lock-face' and `mouse-face' text properties that aren't
-      ;; relevant to our test
-      (remove-list-of-text-properties
-       0 (length cand) '(font-lock-face mouse-face) render)
+      ;; remove text properties that aren't relevant to our test
+      (company--remove-but-these-properties render '(face))
       (should
        (ert-equal-including-properties
         render



reply via email to

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