ido-ubiquitous-test.el 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. ;;; -*- lexical-binding: t -*-
  2. (require 'ido-completing-read+)
  3. (require 'ido-ubiquitous)
  4. (require 'ert)
  5. (require 'cl-lib)
  6. ;; This is a series of macros to facilitate the non-interactive
  7. ;; testing of interactive functions by simulating user input.
  8. (defmacro keyboard-quit-to-error (&rest body)
  9. "Evaluate BODY but signal an error on `keyboard-quit'."
  10. `(condition-case nil
  11. (progn ,@body)
  12. (quit
  13. (error "Caught `keyboard-quit'"))))
  14. (defmacro with-simulated-input (keys &rest body)
  15. "Eval body with KEYS as simulated input.
  16. This macro is intended for testing normally interactive functions
  17. by simulating input. If BODY tries to read more input events than
  18. KEYS provides, `keyboard-quit' is invoked (by means of appending
  19. multple C-g keys to KEYS). This is to ensure that BODY will never
  20. block waiting for input, since this macro is intended for
  21. noninteractive use. As such, BODY should not invoke
  22. `keyboard-quit' under normal operation, and KEYS should not
  23. include C-g, or this macro will interpret it as reading past the
  24. end of input."
  25. ;; It would be better to detect end-of-input by overriding
  26. ;; `read-event' to throw an error, since theoretically C-g could be
  27. ;; rebound to something other than `keyboard-quit'. But apparently
  28. ;; some functions read input directly in C code, and redefining
  29. ;; `read-event' has no effect on those. So the suboptimal solution
  30. ;; is to rely on C-g.
  31. (declare (indent 1))
  32. `(let* ((key-sequence (listify-key-sequence (kbd ,keys)))
  33. (C-g-key-sequence
  34. (listify-key-sequence
  35. ;; We *really* want to trigger `keyboard-quit' if we reach
  36. ;; the end of the input.
  37. (kbd "C-g C-g C-g C-g C-g C-g C-g")))
  38. (unread-command-events
  39. (append key-sequence C-g-key-sequence)))
  40. (when (member (car C-g-key-sequence) key-sequence)
  41. (error "KEYS must not include C-g"))
  42. (condition-case nil
  43. (progn ,@body)
  44. (quit
  45. (error "Reached end of simulated input while evaluating body")))))
  46. (defmacro with-mode (mode arg &rest body)
  47. "Eval (MODE ARG), then body, then restore previous status of MODE.
  48. This will only work on modes that respect the normal conventions
  49. for activation and deactivation."
  50. (declare (indent 2))
  51. `(let* ((orig-status ,mode)
  52. (restore-arg (if orig-status 1 0)))
  53. (unwind-protect
  54. (progn
  55. (,mode ,arg)
  56. ,@body)
  57. (message "Restoring mode %s to %s" ',mode restore-arg)
  58. (,mode restore-arg))))
  59. (defmacro with-ido-ubiquitous-standard-env (&rest body)
  60. "Execute BODY with standard ido-ubiquitous settings.\n\nAll ido-ubiquitous and ido-cr+ options will be let-bound to their\ndefault values, and `ido-ubiquitous-mode' will be enabled."
  61. (declare (indent 0))
  62. (let*
  63. ((ido-ubiquitous-options
  64. '(ido-ubiquitous-allow-on-functional-collection
  65. ido-ubiquitous-command-overrides
  66. ido-ubiquitous-debug-mode
  67. ido-ubiquitous-default-state
  68. ido-ubiquitous-function-overrides
  69. ido-cr+-fallback-function
  70. ido-cr+-max-items
  71. ido-cr+-replace-completely
  72. ido-confirm-unique-completion))
  73. (idu-bindings
  74. (cl-loop for var in ido-ubiquitous-options collect
  75. (list var
  76. (list 'quote
  77. (eval (car (get var 'standard-value))))))))
  78. `(with-mode ido-ubiquitous-mode 1
  79. (let ,idu-bindings ,@body))))
  80. (defmacro collection-as-function (collection)
  81. "Return a function equivalent to COLLECTION.
  82. The returned function will work equivalently to COLLECTION when
  83. passed to `all-completions' and `try-completion'."
  84. `(completion-table-dynamic (lambda (string) (all-completions string ,collection))))
  85. (cl-defmacro should-with-tag (form &key tag)
  86. "Equivalent to `(should FORM)' but with a TAG on the output.
  87. This is useful if the same `should' form will be called multiple
  88. times in different contexts. Each test can pass a different tag
  89. so it's clear in the ERT output which context is causing the
  90. failure.
  91. Note that although this is a macro, the TAG argument is evaluated normally."
  92. `(let ((tagvalue ,tag))
  93. (condition-case err
  94. (should ,form)
  95. (ert-test-failed
  96. (message "Error symbol: %S" (car err))
  97. (message "Error data: %S" (cdr err))
  98. (when tagvalue
  99. (setf (cadr err) (append (cadr err) (list :tag tagvalue))))
  100. (message "New error data: %S" (cdr err))
  101. (signal (car err) (cdr err))))))
  102. (defun plist-delete (plist property)
  103. "Delete PROPERTY from PLIST.
  104. This is in contrast to merely setting it to 0."
  105. (let (p)
  106. (while plist
  107. (if (not (eq property (car plist)))
  108. (setq p (plist-put p (car plist) (nth 1 plist))))
  109. (setq plist (cddr plist)))
  110. p))
  111. (cl-defmacro should-error-with-tag (form &rest other-keys &key tag &allow-other-keys)
  112. "Equivalent to `(should FORM)' but with a TAG on the output.
  113. See `should-with-tag'.
  114. Note that although this is a macro, the TAG argument is evaluated normally."
  115. (setq other-keys (plist-delete other-keys :tag))
  116. `(let ((tagvalue ,tag))
  117. (condition-case err
  118. (should-error ,form ,@other-keys)
  119. (ert-test-failed
  120. (message "Error symbol: %S" (car err))
  121. (message "Error data: %S" (cdr err))
  122. (when tagvalue
  123. (setf (cadr err) (append (cadr err) (list :tag tagvalue))))
  124. (message "New error data: %S" (cdr err))
  125. (signal (car err) (cdr err))))))
  126. (defun test-ido-ubiquitous-expected-mode (override &optional tag)
  127. "Test whether observed ido-ubiquitous behavior matches OVERRIDE."
  128. (declare (indent 1))
  129. (if (eq override 'disable)
  130. (progn
  131. (should-with-tag
  132. ;; Verify that we get standard completion
  133. (string=
  134. "g"
  135. (with-simulated-input "g RET"
  136. (completing-read "Prompt: " '("blue" "yellow" "green"))))
  137. :tag tag)
  138. (should-with-tag
  139. (string=
  140. "green"
  141. (with-simulated-input "g RET"
  142. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  143. :tag tag)
  144. ;; Standard completion should refuse to finish with incomplete
  145. ;; input if match is required
  146. (should-error-with-tag
  147. (with-simulated-input "b RET"
  148. (completing-read "Prompt: " '("brown" "blue" "yellow" "green") nil t))
  149. :type 'error
  150. :tag tag))
  151. ;; Common tests whenever ido-ubiquitous is enabled in any way
  152. (should-with-tag
  153. ;; Verify that ido completion is active
  154. (string=
  155. "green"
  156. (with-simulated-input "g RET"
  157. (completing-read "Prompt: " '("blue" "yellow" "green"))))
  158. :tag tag)
  159. ;; Verify that C-j is working correctly
  160. (should-with-tag
  161. (string=
  162. "g"
  163. (with-simulated-input "g C-j"
  164. (completing-read "Prompt: " '("blue" "yellow" "green"))))
  165. :tag tag)
  166. (let ((collection '("brown" "blue" "yellow" "green")))
  167. (should-with-tag
  168. (member
  169. (with-simulated-input "b RET"
  170. (completing-read "Prompt: " collection))
  171. (all-completions "b" collection))
  172. :tag tag))
  173. (cl-case override
  174. (enable
  175. ;; Test for new style
  176. (should-with-tag
  177. (string=
  178. "blue"
  179. (with-simulated-input "RET"
  180. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  181. :tag tag)
  182. (should-with-tag
  183. (string=
  184. ""
  185. (with-simulated-input "C-j"
  186. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  187. :tag tag))
  188. (enable-old
  189. (should-with-tag
  190. (string=
  191. ""
  192. (with-simulated-input "RET"
  193. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  194. :tag tag)
  195. (should-with-tag
  196. (string=
  197. "blue"
  198. (with-simulated-input "C-j"
  199. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  200. :tag tag)
  201. ;; Verify that doing other stuff reverts RET and C-j to standard
  202. ;; meanings
  203. (should-with-tag
  204. (string=
  205. "blue"
  206. (with-simulated-input "g DEL RET"
  207. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  208. :tag tag)
  209. (should-with-tag
  210. (string=
  211. "blue"
  212. (with-simulated-input "<right> <left> RET"
  213. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  214. :tag tag)
  215. (should-with-tag
  216. (string=
  217. ""
  218. (with-simulated-input "g DEL C-j"
  219. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  220. :tag tag)
  221. (should-with-tag
  222. (string=
  223. ""
  224. (with-simulated-input "<right> <left> C-j"
  225. (completing-read "Prompt: " '("blue" "yellow" "green") nil t)))
  226. :tag tag))
  227. (otherwise (error "Unknown override %S" override)))))
  228. (defvar original-completing-read (symbol-function #'completing-read))
  229. (defun test-ido-ubiquitous-expected-mode-on-functional-collection (override &optional tag)
  230. "Test whether observed ido-ubiquitous behavior on functional collection matches OVERRIDE."
  231. (declare (indent 1))
  232. ;; This just temporarily replaces `completing-read' with a wrapper
  233. ;; that always converts the collection argument to an equivalent
  234. ;; function. That way, any use of `completing-read' will always see
  235. ;; a functional collection.
  236. (cl-letf (((symbol-function 'completing-read)
  237. (lambda (prompt collection &rest args)
  238. (apply original-completing-read prompt
  239. (collection-as-function collection)
  240. args))))
  241. (test-ido-ubiquitous-expected-mode override tag)))
  242. (ert-deftest ido-ubiquitous-test-simple ()
  243. :tags '(ido ido-ubiquitous)
  244. "Test that basic ido-ubiquitous functionality is working."
  245. (with-ido-ubiquitous-standard-env
  246. (ido-ubiquitous-mode 1)
  247. (test-ido-ubiquitous-expected-mode 'enable
  248. :simple-enable)
  249. (ido-ubiquitous-mode 0)
  250. (test-ido-ubiquitous-expected-mode 'disable
  251. :simple-disable)))
  252. (ert-deftest ido-ubiquitous-test-oldstyle ()
  253. :tags '(ido ido-ubiquitous)
  254. "Test whether old-style completion works as expected."
  255. (with-ido-ubiquitous-standard-env
  256. (let ((ido-ubiquitous-default-state 'enable-old))
  257. (test-ido-ubiquitous-expected-mode 'enable-old
  258. :simple-oldstyle))))
  259. (ert-deftest ido-ubiquitous-test-maxitems ()
  260. :tags '(ido ido-ubiquitous)
  261. "Test whether the large-collection fallback works."
  262. (with-ido-ubiquitous-standard-env
  263. (let ((ido-cr+-max-items -1))
  264. (test-ido-ubiquitous-expected-mode 'disable
  265. :maxitems))))
  266. (ert-deftest ido-ubiquitous-test-override ()
  267. :tags '(ido ido-ubiquitous)
  268. "Test whether ido-ubiquitous overrides work."
  269. (with-ido-ubiquitous-standard-env
  270. (ido-ubiquitous-with-override 'enable
  271. (test-ido-ubiquitous-expected-mode 'enable
  272. :override-enable))
  273. (ido-ubiquitous-with-override 'enable-old
  274. (test-ido-ubiquitous-expected-mode 'enable-old
  275. :override-enable-old))
  276. (ido-ubiquitous-with-override 'disable
  277. (test-ido-ubiquitous-expected-mode 'disable
  278. :override-disable))))
  279. (ert-deftest ido-ubiquitous-test-functional-collection ()
  280. :tags '(ido ido-ubiquitous)
  281. "Test whether ido-ubiquitous overrides work when collection is a function."
  282. (with-ido-ubiquitous-standard-env
  283. (test-ido-ubiquitous-expected-mode-on-functional-collection 'disable
  284. :collfunc)
  285. (ido-ubiquitous-with-override 'enable
  286. (test-ido-ubiquitous-expected-mode-on-functional-collection 'enable
  287. :override-enable-collfunc))
  288. (ido-ubiquitous-with-override 'enable-old
  289. (test-ido-ubiquitous-expected-mode-on-functional-collection 'enable-old
  290. :override-enable-old-collfunc))))
  291. (ert-deftest ido-cr+-require-match ()
  292. :tags '(ido ido-cr+)
  293. "Test whether require-match works."
  294. (with-ido-ubiquitous-standard-env
  295. ;; "C-j" should be allowed to return an empty string even if
  296. ;; require-match is non-nil, as long as default is nil
  297. (should
  298. (string=
  299. ""
  300. (with-simulated-input "C-j"
  301. (ido-completing-read+
  302. "Prompt: "
  303. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
  304. ;; "C-j" should NOT be allowed to return an empty string if
  305. ;; require-match and default are both non-nil.
  306. (should-error
  307. (with-simulated-input "C-j"
  308. (ido-completing-read+
  309. "Prompt: "
  310. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t nil nil "yellow")))
  311. ;; Multiple presses of C-j won't just select the first match
  312. (should-error
  313. (with-simulated-input "b C-j C-j C-j"
  314. (ido-completing-read+
  315. "Prompt: "
  316. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
  317. ;; First press of C-j should complete unique common prefix after the
  318. ;; first b, but then get stuck on the choice for the second b.
  319. (should-error
  320. (with-simulated-input "b C-j b C-j C-j"
  321. (ido-completing-read+
  322. "Prompt: "
  323. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
  324. ;; This should complete to "blueberry" via 2 rounds of unique common
  325. ;; prefix completion, and then return on the 3rd "C-j"
  326. (should
  327. (string=
  328. "blueberry"
  329. (with-simulated-input "b C-j b C-j e C-j C-j"
  330. (ido-completing-read+
  331. "Prompt: "
  332. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
  333. ;; The "C-j" should complete to "bluegrass" and return, because
  334. ;; `ido-confirm-unique-completion is nil.
  335. (should
  336. (string=
  337. "bluegrass"
  338. (with-simulated-input "b l u e g C-j"
  339. (ido-completing-read+
  340. "Prompt: "
  341. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
  342. (let ((ido-confirm-unique-completion t))
  343. ;; Now the first "C-j" should complete to "bluegrass" but should
  344. ;; not return.
  345. (should-error
  346. (with-simulated-input "b l u e g C-j"
  347. (ido-completing-read+
  348. "Prompt: "
  349. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
  350. ;; The first "C-j" should complete to "bluegrass", and the second
  351. ;; should return.
  352. (should
  353. (string=
  354. "bluegrass"
  355. (with-simulated-input "b l u e g C-j C-j"
  356. (ido-completing-read+
  357. "Prompt: "
  358. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))))
  359. ;; Finally, a few tests for the expected wrong behavior without
  360. ;; ido-cr+. If ido.el ever fixes this bug, it will cause this test
  361. ;; to fail as a signal that the workaround can be phased out.
  362. (should
  363. (string=
  364. ""
  365. (with-simulated-input "C-j"
  366. (ido-completing-read
  367. "Prompt: "
  368. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
  369. (should
  370. (string=
  371. "b"
  372. (with-simulated-input "b C-j"
  373. (ido-completing-read
  374. "Prompt: "
  375. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))))
  376. ;; Functions to define overrides on for testing
  377. (defun idu-no-override-testfunc ()
  378. (test-ido-ubiquitous-expected-mode 'enable
  379. :func-override-none)
  380. (test-ido-ubiquitous-expected-mode-on-functional-collection 'disable
  381. :func-override-none-collfunc))
  382. (defun idu-enabled-testfunc (&rest args)
  383. (test-ido-ubiquitous-expected-mode 'enable
  384. :func-override-enable)
  385. (test-ido-ubiquitous-expected-mode-on-functional-collection 'enable
  386. :func-override-enable-collfunc))
  387. (defun idu-disabled-testfunc (&rest args)
  388. (test-ido-ubiquitous-expected-mode 'disable
  389. :func-override-disable)
  390. (test-ido-ubiquitous-expected-mode-on-functional-collection 'disable
  391. :func-override-disable-collfunc))
  392. (defun idu-enabled-oldstyle-testfunc (&rest args)
  393. (test-ido-ubiquitous-expected-mode 'enable-old
  394. :func-override-enable-old)
  395. (test-ido-ubiquitous-expected-mode-on-functional-collection 'enable-old
  396. :func-override-enable-old-collfunc))
  397. ;; commands to define overrides on for testing
  398. (defun idu-no-override-testcmd (&rest args)
  399. (interactive
  400. (list
  401. (test-ido-ubiquitous-expected-mode 'enable
  402. :cmd-override-none)
  403. (test-ido-ubiquitous-expected-mode-on-functional-collection 'disable
  404. :cmd-override-none-collfunc)))
  405. (test-ido-ubiquitous-expected-mode 'enable
  406. :cmd-override-none)
  407. (test-ido-ubiquitous-expected-mode-on-functional-collection 'disable
  408. :cmd-override-non-collfunc))
  409. (defun idu-enabled-testcmd (&rest args)
  410. (interactive
  411. (list
  412. (test-ido-ubiquitous-expected-mode 'enable
  413. :cmd-override-enable)
  414. (test-ido-ubiquitous-expected-mode-on-functional-collection 'enable
  415. :cmd-override-enable-collfunc)))
  416. (test-ido-ubiquitous-expected-mode 'enable
  417. :cmd-override-enable)
  418. (test-ido-ubiquitous-expected-mode-on-functional-collection 'enable
  419. :cmd-override-enable-collfunc))
  420. (defun idu-disabled-testcmd (&rest args)
  421. (interactive
  422. (list
  423. (test-ido-ubiquitous-expected-mode 'disable
  424. :cmd-override-disable)
  425. (test-ido-ubiquitous-expected-mode-on-functional-collection 'disable
  426. :cmd-override-disable-collfunc)))
  427. (test-ido-ubiquitous-expected-mode 'disable
  428. :cmd-override-disable)
  429. (test-ido-ubiquitous-expected-mode-on-functional-collection 'disable
  430. :cmd-override-disable-collfunc))
  431. (defun idu-enabled-oldstyle-testcmd (&rest args)
  432. (interactive
  433. (list
  434. (test-ido-ubiquitous-expected-mode 'enable-old
  435. :cmd-override-enable-old)
  436. (test-ido-ubiquitous-expected-mode-on-functional-collection 'enable-old
  437. :cmd-override-enable-old-collfunc)))
  438. (test-ido-ubiquitous-expected-mode 'enable-old
  439. :cmd-override-enable-old)
  440. (test-ido-ubiquitous-expected-mode-on-functional-collection 'enable-old
  441. :cmd-override-enable-old-collfunc))
  442. (ert-deftest ido-ubiquitous-test-command-and-function-overrides ()
  443. :tags '(ido ido-ubiquitous)
  444. "Test whether command- and function-specific overrides work."
  445. (let ((orig-func-overrides ido-ubiquitous-function-overrides)
  446. (orig-cmd-overrides ido-ubiquitous-command-overrides))
  447. (unwind-protect
  448. (with-ido-ubiquitous-standard-env
  449. (customize-set-variable
  450. 'ido-ubiquitous-function-overrides
  451. (append ido-ubiquitous-function-overrides
  452. '((enable exact "idu-enabled-testfunc")
  453. (disable exact "idu-disabled-testfunc")
  454. (enable-old exact "idu-enabled-oldstyle-testfunc"))))
  455. (cl-loop for func in
  456. '(idu-no-override-testfunc
  457. idu-enabled-testfunc
  458. idu-disabled-testfunc
  459. idu-enabled-oldstyle-testfunc)
  460. do (funcall func))
  461. (customize-set-variable
  462. 'ido-ubiquitous-command-overrides
  463. (append ido-ubiquitous-command-overrides
  464. '((enable exact "idu-enabled-testcmd")
  465. (disable exact "idu-disabled-testcmd")
  466. (enable-old exact "idu-enabled-oldstyle-testcmd"))))
  467. (cl-loop for cmd in
  468. '(idu-no-override-testcmd
  469. idu-enabled-testcmd
  470. idu-disabled-testcmd
  471. idu-enabled-oldstyle-testcmd)
  472. do (call-interactively cmd)))
  473. (customize-set-variable 'ido-ubiquitous-function-overrides orig-func-overrides)
  474. (customize-set-variable 'ido-ubiquitous-command-overrides orig-cmd-overrides))))
  475. (ert-deftest ido-ubiquitous-test-fallback ()
  476. :tags '(ido ido-ubiquitous)
  477. "Test whether manually invoking fallback works."
  478. (with-ido-ubiquitous-standard-env
  479. (should
  480. ;; C-b/f not at beginning/end of input should not fall back
  481. (string=
  482. "green"
  483. (with-simulated-input "g C-b C-f RET"
  484. (completing-read "Prompt: " '("blue" "yellow" "green")))))
  485. (should
  486. ;; C-f at end of input should fall back
  487. (string=
  488. "g"
  489. (with-simulated-input "g C-f RET"
  490. (completing-read "Prompt: " '("blue" "yellow" "green")))))
  491. (should
  492. ;; Repeated C-b should not fall back
  493. (string=
  494. "green"
  495. (with-simulated-input "g C-b C-b C-b C-b RET"
  496. (completing-read "Prompt: " '("blue" "yellow" "green")))))
  497. (should
  498. ;; C-b at beginning of line should fall back (if previous action
  499. ;; was not also C-b)
  500. (string=
  501. "g"
  502. (with-simulated-input "g C-b x DEL C-b RET"
  503. (completing-read "Prompt: " '("blue" "yellow" "green")))))))
  504. (ert-deftest ido-ubiquitous-dot-prefix-empty-string ()
  505. :tags '(ido ido-ubiquitous)
  506. "Test whether ido-ubiquitous successfully works around a bug in ido.
  507. See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26997 for more
  508. information on this bug."
  509. (with-ido-ubiquitous-standard-env
  510. (let ((ido-enable-dot-prefix t))
  511. (should
  512. (string=
  513. ""
  514. (with-simulated-input "RET"
  515. (completing-read "Pick: " '("" "aaa" "aab" "aac")))))
  516. (should
  517. (string=
  518. "aab"
  519. (with-simulated-input "a a b RET"
  520. (completing-read "Pick: " '("" "aaa" "aab" "aac"))))))))
  521. (defun ido-ubiquitous-run-all-tests ()
  522. (interactive)
  523. (ert "^ido-\\(ubiquitous\\|cr\\+\\)-"))
  524. (provide 'ido-ubiquitous-test)
  525. ;;; ido-ubiquitous-test.el ends here