[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f404a12 30/66: Add some tests for the previous commits
From: |
Dmitry Gutov |
Subject: |
[elpa] master f404a12 30/66: Add some tests for the previous commits |
Date: |
Mon, 5 Nov 2018 18:19:17 -0500 (EST) |
branch: master
commit f404a125b15c9dc57adc07b9efe728ea731c7bfb
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Add some tests for the previous commits
* test/capf-tests.el: New file.
---
test/capf-tests.el | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
diff --git a/test/capf-tests.el b/test/capf-tests.el
new file mode 100644
index 0000000..29965b2
--- /dev/null
+++ b/test/capf-tests.el
@@ -0,0 +1,115 @@
+;;; capf-tests.el --- company tests for the company-capf backend -*-
lexical-binding: t; -*-
+
+;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+
+;; Author: João Távora <address@hidden>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'company-tests)
+(require 'company-capf)
+
+(defmacro company-capf-with-buffer (contents &rest body)
+ (declare (indent 0) (debug (sexp &rest form)))
+ `(with-temp-buffer
+ (insert ,contents)
+ (emacs-lisp-mode)
+ (re-search-backward "|")
+ (replace-match "")
+ (let ((completion-at-point-functions '(elisp-completion-at-point))
+ (company-backends '(company-capf)))
+ ,@body)))
+
+(ert-deftest company-basic-capf ()
+ "Test basic `company-capf' support."
+ (company-capf-with-buffer
+ "(with-current-buffer|)"
+ (company-mode)
+ (company-complete)
+ (should company-candidates)))
+
+(ert-deftest company-non-prefix-capf ()
+ "Test non-prefix `company-capf' in elisp"
+ (company-capf-with-buffer
+ "(w-c-b|)"
+ (company-mode)
+ (company-complete)
+ (should company-candidates)
+ (should (member "with-current-buffer" company-candidates))))
+
+;; Re. "perfect" highliting of the non-prefix in company-capf matches, it is
+;; only working in recent Emacsen containing this commit. The two following
+;; tests reflect that.
+;;
+;; commit 325ef57b0e3977f9509f1049c826999e8b7c226d
+;; Author: Stefan Monnier <address@hidden>
+;; Date: Tue Nov 7 12:17:34 2017 -0500
+
+(ert-deftest company-non-prefix-fancy-capf-highlighting ()
+ "Test highlighting for non-prefix `company-capf' in elisp"
+ (skip-unless (version<= "27.0" emacs-version))
+ (company-capf-with-buffer
+ "(w-c-b|)"
+ (company-mode)
+ (company-complete)
+ (let* ((cand (car (member "with-current-buffer" company-candidates)))
+ (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)
+ (should
+ (ert-equal-including-properties
+ render
+ #("with-current-buffer"
+ 0 1 (face (company-tooltip-common company-tooltip)) ; "w"
+ 1 4 (face (company-tooltip)) ; "ith"
+ 4 6 (face (company-tooltip-common company-tooltip)) ; "-c"
+ 6 12 (face (company-tooltip)) ; "urrent"
+ 12 14 (face (company-tooltip-common company-tooltip)) ; "-b"
+ 14 19 (face (company-tooltip)))))))) ; "uffer"
+
+(ert-deftest company-non-prefix-modest-capf-highlighting ()
+ "Test highlighting for non-prefix `company-capf' in elisp"
+ (skip-unless (version< emacs-version "27.0"))
+ (company-capf-with-buffer
+ "(w-c-b|)"
+ (company-mode)
+ (company-complete)
+ (let* ((cand (car (member "with-current-buffer" company-candidates)))
+ (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)
+ (should
+ (ert-equal-including-properties
+ render
+ #("with-current-buffer"
+ 0 14 (face (company-tooltip-common company-tooltip));
"with-current-b"
+ 14 19 (face (company-tooltip)))))))) ; "uffer"
+
+(provide 'capf-tests)
+;;; capf-tests.el ends here
- [elpa] master 67650de 17/66: Merge pull request #769 from tigersoldier/master, (continued)
- [elpa] master 67650de 17/66: Merge pull request #769 from tigersoldier/master, Dmitry Gutov, 2018/11/05
- [elpa] master 23e6c82 07/66: Add NEWS entry, Dmitry Gutov, 2018/11/05
- [elpa] master 5c2425b 06/66: Work around python-shell-completion-at-point's behavior, Dmitry Gutov, 2018/11/05
- [elpa] master a64d52c 05/66: Deprecate company-nxml too, Dmitry Gutov, 2018/11/05
- [elpa] master 5698be9 10/66: Simplify company-cmake-prefix-dollar-brace-p, Dmitry Gutov, 2018/11/05
- [elpa] master 5118b59 14/66: company-tng: Supress post-completion (#731), Dmitry Gutov, 2018/11/05
- [elpa] master a78f7d8 15/66: Merge pull request #764 from nikital/tng-supress-post-completion, Dmitry Gutov, 2018/11/05
- [elpa] master 5a856d7 13/66: backend: Remove pre-completion command, Dmitry Gutov, 2018/11/05
- [elpa] master 5b11709 31/66: Emacs 24 doesn't have working elisp capf, so don't test it, Dmitry Gutov, 2018/11/05
- [elpa] master b0940fb 29/66: Close #798: look for :company-match function in the capf's metadata, Dmitry Gutov, 2018/11/05
- [elpa] master f404a12 30/66: Add some tests for the previous commits,
Dmitry Gutov <=
- [elpa] master 0325a40 11/66: Remove an unnecessary test, Dmitry Gutov, 2018/11/05
- [elpa] master ed1085f 19/66: Merge pull request #771 from Wilfred/interactive-example, Dmitry Gutov, 2018/11/05
- [elpa] master 7d6ab3c 22/66: company-keywords: Support thrift-mode, Dmitry Gutov, 2018/11/05
- [elpa] master 270976b 25/66: Update Javascript and Python keywords, Dmitry Gutov, 2018/11/05
- [elpa] master 287a5fb 18/66: Make example backend interactive, Dmitry Gutov, 2018/11/05
- [elpa] master 46680da 21/66: company-css: Improve performance, Dmitry Gutov, 2018/11/05
- [elpa] master d26ec71 23/66: Merge pull request #785 from ylectric/company-keywords/thrift-mode, Dmitry Gutov, 2018/11/05
- [elpa] master 392dadd 28/66: Per #798, #762: Fix company-capf's highlighting of non-prefix matches, Dmitry Gutov, 2018/11/05
- [elpa] master f1aef4d 45/66: add reference url for go-mode's keywords, Dmitry Gutov, 2018/11/05
- [elpa] master 4d921fe 39/66: Merge pull request #817 from chunzhouyu/master, Dmitry Gutov, 2018/11/05