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

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

[elpa] 03/35: Test new prefix behavior, option company-abort-manual-when


From: Dmitry Gutov
Subject: [elpa] 03/35: Test new prefix behavior, option company-abort-manual-when-too-short
Date: Sat, 19 Apr 2014 10:12:13 +0000

dgutov pushed a commit to branch master
in repository elpa.

commit d38e705667bb649ebd4f6e07eb5b3383425594d0
Author: Ingo Lohmar <address@hidden>
Date:   Tue Mar 25 22:42:09 2014 +0100

    Test new prefix behavior, option company-abort-manual-when-too-short
---
 company-tests.el |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/company-tests.el b/company-tests.el
index 5a26086..e5fd2f7 100644
--- a/company-tests.el
+++ b/company-tests.el
@@ -46,13 +46,48 @@
 
 (ert-deftest company-good-prefix ()
   (let ((company-minimum-prefix-length 5)
-        company--explicit-action)
+        company--explicit-action
+        (company-selection-changed t))  ;never enough
     (should (eq t (company--good-prefix-p "address@hidden")))
     (should (eq nil (company--good-prefix-p "abcd")))
     (should (eq nil (company--good-prefix-p 'stop)))
     (should (eq t (company--good-prefix-p '("foo" . 5))))
     (should (eq nil (company--good-prefix-p '("foo" . 4))))))
 
+(ert-deftest company--manual-prefix-set-and-unset ()
+  (with-temp-buffer
+    (insert "ab")
+    (company-mode)
+    (let (company-frontends
+          (company-backends
+           (list (lambda (command &optional arg)
+                   (case command
+                     (prefix (buffer-substring (point-min) (point)))
+                     (candidates '("abc" "abd")))))))
+      (company-manual-begin)
+      (should (equal "ab" company--manual-prefix))
+      (company-abort)
+      (should (null company--manual-prefix)))))
+
+(ert-deftest company-abort-manual-when-too-short ()
+  (let ((company-minimum-prefix-length 5)
+        (company-abort-manual-when-too-short t)
+        (company-selection-changed t))    ;never enough
+    (let ((company--explicit-action nil)) ;idle begin
+      (should (eq t (company--good-prefix-p "address@hidden")))
+      (should (eq nil (company--good-prefix-p "abcd")))
+      (should (eq nil (company--good-prefix-p 'stop)))
+      (should (eq t (company--good-prefix-p '("foo" . 5))))
+      (should (eq nil (company--good-prefix-p '("foo" . 4)))))
+    (let ((company--explicit-action t)
+          (company--manual-prefix "abc")) ;manual begin from this prefix
+      (should (eq t (company--good-prefix-p "address@hidden")))
+      (should (eq nil (company--good-prefix-p "ab")))
+      (should (eq nil (company--good-prefix-p 'stop)))
+      (should (eq t (company--good-prefix-p '("foo" . 4))))
+      (should (eq t (company--good-prefix-p "abcd")))
+      (should (eq t (company--good-prefix-p "abcd"))))))
+
 (ert-deftest company-multi-backend-with-lambdas ()
   (let ((company-backend
          (list (lambda (command &optional arg &rest ignore)



reply via email to

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