* anything-config.el (anything-completing-read-handlers-alist): Fix docstring. No...
[anything-config.git] / developer-tools / unit-test-anything-config.el
blobd53b1497d12fe1238ce1523b164d9f9756805e79
1 ;;;; unit test
2 ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el")
3 ;; (install-elisp "http://www.emacswiki.org/cgi-bin/wiki/download/el-mock.el")
4 (dont-compile
5 (when (fboundp 'expectations)
6 (expectations
7 (desc "candidates-file plug-in")
8 (expect '(anything-p-candidats-file-init)
9 (assoc-default 'init
10 (car (anything-compile-sources
11 '(((name . "test")
12 (candidates-file . "test.txt")))
13 '(anything-compile-source--candidates-file)))))
14 (expect '(anything-p-candidats-file-init
15 (lambda () 1))
16 (assoc-default 'init
17 (car (anything-compile-sources
18 '(((name . "test")
19 (candidates-file . "test.txt")
20 (init . (lambda () 1))))
21 '(anything-compile-source--candidates-file)))))
22 (expect '(anything-p-candidats-file-init
23 (lambda () 1))
24 (assoc-default 'init
25 (car (anything-compile-sources
26 '(((name . "test")
27 (candidates-file . "test.txt")
28 (init (lambda () 1))))
29 '(anything-compile-source--candidates-file)))))
30 ;; FIXME error
31 ;; (desc "anything-c-source-buffers")
32 ;; (expect '(("Buffers" ("foo" "curbuf")))
33 ;; (stub buffer-list => '("curbuf" " hidden" "foo" "*anything*"))
34 ;; (let ((anything-c-boring-buffer-regexp
35 ;; (rx (or
36 ;; (group bos " ")
37 ;; "*anything"
38 ;; ;; echo area
39 ;; " *Echo Area" " *Minibuf"))))
40 ;; (flet ((buffer-name (&optional x) x))
41 ;; (anything-test-candidates 'anything-c-source-buffers))))
42 (desc "anything-c-stringify")
43 (expect "str1"
44 (anything-c-stringify "str1"))
45 (expect "str2"
46 (anything-c-stringify 'str2))
47 (desc "anything-c-symbolify")
48 (expect 'sym1
49 (anything-c-symbolify "sym1"))
50 (expect 'sym2
51 (anything-c-symbolify 'sym2))
52 (desc "plug-in:default-action")
53 (expect '(((action ("default" . default) ("original" . original))
54 (default-action . ("default" . default))
55 (action ("original" . original))))
56 (anything-compile-sources
57 '(((default-action . ("default" . default))
58 (action ("original" . original))))
59 '(anything-compile-source--default-action)))
60 (expect '(((action ("a1" . a1) ("a2" . a2))
61 (default-action . ("a1" . a1))
62 (action ("a1" . a1) ("a2" . a2))))
63 (anything-compile-sources
64 '(((default-action . ("a1" . a1))
65 (action ("a1" . a1) ("a2" . a2))))
66 '(anything-compile-source--default-action)))
67 (expect '(((action ("a2" . a2) ("a1" . a1))
68 (default-action . ("a2" . a2))
69 (action ("a1" . a1) ("a2" . a2))))
70 (anything-compile-sources
71 '(((default-action . ("a2" . a2))
72 (action ("a1" . a1) ("a2" . a2))))
73 '(anything-compile-source--default-action)))
74 (desc "anything-c-adaptive-store-selection")
75 (expect '(("test adaptative" ("a" ("a" . 1))))
76 (let ((anything-c-adaptive-history nil))
77 (when (anything
78 :sources '(((name . "test adaptative")
79 (candidates . (list "a" "b" "c" "d"))
80 (action . identity)
81 (filtered-candidate-transformer anything-c-adaptive-sort)))
82 :input "a"
83 :execute-action-at-once-if-one t)
84 (anything-c-adaptive-store-selection))
85 anything-c-adaptive-history))
86 (desc "anything-ff-human-size")
87 (expect "6.7G"
88 (anything-ff-human-size 7141892608.0))
89 (expect "1.2M"
90 (anything-ff-human-size 1221554))
91 (expect "386.6K"
92 (anything-ff-human-size 395897))
93 (expect "456"
94 (anything-ff-human-size 456)))))