emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob 2de4f4934712414c2520d7b17da9f81e33297d0d 4991 bytes (raw)
name: testing/lisp/test-org-pcomplete.el 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
 
;;; test-org-pcomplete.el --- test pcomplete integration

;; Copyright (C) 2015-2016, 2019  Alexey Lebedeff
;; Authors: Alexey Lebedeff

;; This file is not part of GNU Emacs.

;; 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 <http://www.gnu.org/licenses/>.

;;; Comments:

\f

;;; Code:

(ert-deftest test-org-pcomplete/clocktable ()
  "Test completion of clock table parameters."
  (should
   (equal "#+begin: clocktable :scope"
	  (org-test-with-temp-text "#+begin: clocktable :sco<point>"
	    (pcomplete)
	    (buffer-string)))))

(ert-deftest test-org-pcomplete/drawer ()
  "Test drawer completion."
  (should
   (equal "* Foo\n:PROPERTIES:"
	  (org-test-with-temp-text "* Foo\n:<point>"
	    (pcomplete)
	    (buffer-string))))
  (should
   (equal ":DRAWER:\nContents\n:END:\n* Foo\n:DRAWER:"
	  (org-test-with-temp-text ":DRAWER:\nContents\n:END:\n* Foo\n:D<point>"
	    (pcomplete)
	    (buffer-string)))))

(ert-deftest test-org-pcomplete/entity ()
  "Test entity completion."
  (should
   (equal "\\alpha"
	  (org-test-with-temp-text "\\alp<point>"
	    (pcomplete)
	    (buffer-string))))
  (should
   (equal "\\frac12"
	  (org-test-with-temp-text "\\frac1<point>"
	    (pcomplete)
	    (buffer-string)))))

(ert-deftest test-org-pcomplete/keyword ()
  "Test keyword and block completion."
  (should
   (string-prefix-p
    "#+startup: "
    (org-test-with-temp-text "#+start<point>"
      (pcomplete)
      (buffer-string))
    t))
  (should
   (string-prefix-p
    "#+begin_center"
    (org-test-with-temp-text "#+begin_ce<point>"
      (pcomplete)
      (buffer-string))
    t)))

(ert-deftest test-org-pcomplete/src-block ()
  "Test Babel source block header arguments completion."
  (should
   (string-prefix-p
    "#+begin_src emacs-lisp"
    (org-test-with-temp-text "#+begin_src emac<point>"
      (pcomplete)
      (buffer-string))))
  (should
   (string-prefix-p
    "#+begin_src emacs-lisp :session"
    (org-test-with-temp-text "#+begin_src emacs-lisp :sess<point>"
      (pcomplete)
      (buffer-string)))))

(ert-deftest test-org-pcomplete/link ()
  "Test link completion"
  (should
   (equal "[[org:"
	  (org-test-with-temp-text "[[o<point>"
	    (let ((org-link-abbrev-alist '(("org" . "https://orgmode.org/"))))
	      (pcomplete))
	    (buffer-string))))
  (should-not
   (equal "[org:"
	  (org-test-with-temp-text "[[o<point>"
	    (let ((org-link-abbrev-alist '(("org" . "https://orgmode.org/"))))
	      (pcomplete))
	    (buffer-string)))))

(ert-deftest test-org-pcomplete/prop ()
  "Test property completion."
  (should
   (equal
    "
* a
:PROPERTIES:
:pname:\s
:END:
* b
:PROPERTIES:
:pname: pvalue
:END:
"
    (org-test-with-temp-text "
* a
:PROPERTIES:
:pna<point>
:END:
* b
:PROPERTIES:
:pname: pvalue
:END:
"
      (pcomplete)
      (buffer-string)))))

(ert-deftest test-org-pcomplete/search-heading ()
  "Test search heading completion."
  (should
   (equal "* Foo\n[[*Foo"
	  (org-test-with-temp-text "* Foo\n[[*<point>"
	    (pcomplete)
	    (buffer-string)))))

(ert-deftest test-org-pcomplete/tag ()
  "Test tag completion."
  ;; Complete at end of line, according to `org-current-tag-alist'.
  (should
   (equal "* H :foo:"
	  (org-test-with-temp-text "* H :<point>"
	    (let ((org-current-tag-alist '(("foo")))) (pcomplete))
	    (buffer-string))))
  (should
   (equal "* H :foo:bar:"
	  (org-test-with-temp-text "* H :foo:b<point>"
	    (let ((org-current-tag-alist '(("bar")))) (pcomplete))
	    (buffer-string))))
  ;; If `org-current-tag-alist' is non-nil, complete against tags in
  ;; buffer.
  (should
   (equal "* H1 :bar:\n* H2 :bar:"
	  (org-test-with-temp-text "* H1 :bar:\n* H2 :<point>"
	    (let ((org-current-tag-alist nil)) (pcomplete))
	    (buffer-string))))
  ;; Do not complete in the middle of a line.
  (should
   (equal "* H :notag: :real:tags:"
	  (org-test-with-temp-text "* H :notag:<point> :real:tags:"
	    (let ((org-current-tag-alist '(("foo")))) (pcomplete))
	    (buffer-string))))
  ;; Complete even when there's a match on the line.
  (should
   (equal "* foo: :foo:"
	  (org-test-with-temp-text "* foo: :<point>"
	    (let ((org-current-tag-alist '(("foo")))) (pcomplete))
	    (buffer-string)))))

(ert-deftest test-org-pcomplete/todo ()
  "Test TODO completion."
  (should
   (equal "* TODO"
	  (org-test-with-temp-text "* T<point>"
	    (pcomplete)
	    (buffer-string)))))

(provide 'test-org-pcomplete)
;;; test-org-pcomplete.el ends here

debug log:

solving 2de4f4934 ...
found 2de4f4934 in https://git.savannah.gnu.org/cgit/emacs/org-mode.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).