-
Notifications
You must be signed in to change notification settings - Fork 9
/
native-complete-test.el
148 lines (111 loc) · 4.68 KB
/
native-complete-test.el
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
;;; native-complete-test.el --- test for native complete -*- lexical-binding: t -*-
;;; Commentary:
;; Provides test for `ert'
;;; Code:
(require 'ert)
(require 'native-complete)
(defmacro native-complete-test-with-setup (cmd buffer-contents &rest body)
`(cl-destructuring-bind (native-complete--common . native-complete--prefix)
(native-complete--split-command ,cmd)
(with-current-buffer (get-buffer-create native-complete--buffer)
(erase-buffer)
(insert ,buffer-contents))
(let ((native-complete--command ,cmd))
,@body)))
(ert-deftest native-complete-test-tcsh ()
(should (equal (native-complete-test-with-setup
"foo" "foobar y\n"
(native-complete--get-completions))
'("foobar")))
(should (equal (native-complete-test-with-setup
"ls ~/env/"
"ls ~/env/
setup_foo setup_bar* setup_baz*
ls ~/env/setup_y
ubnx000723>"
(native-complete--get-completions))
'("setup_foo" "setup_bar" "setup_baz")))
(should (equal (native-complete-test-with-setup
"git"
"git
git git-cvsserver gitlab-runner git-parse-remote git-show
git-cvsexportcommit git-instaweb git-pack-redundant git-shell git-write-tree
git-cvsimport gitk git-pack-refs git-shortlog
gity
ubnx000723>"
(native-complete--get-completions))
'("git" "git-cvsserver" "gitlab-runner"
"git-parse-remote" "git-show" "git-cvsexportcommit"
"git-instaweb" "git-pack-redundant" "git-shell"
"git-write-tree" "git-cvsimport" "gitk"
"git-pack-refs" "git-shortlog"))))
(ert-deftest native-complete-test-bash ()
(should (equal (native-complete-test-with-setup
"foo"
"foobar yCCCCK
foobaz"
(native-complete--get-completions))
'("foobar")))
(should (equal (native-complete-test-with-setup
"ls ~/env/"
"ls ~/env/
setup_foo setup_bar setup_baz
sodf2093>
ls ~/env/setup_y"
(native-complete--get-completions))
'("setup_foo" "setup_bar" "setup_baz")))
(should (equal (native-complete-test-with-setup
"git"
"git
Display all 146 possibilities? (y or n)
git git-cvsserver gitlab-runner git-patch-id git-show-ref
git-cvsimport gitk git-parse-remote git-show-index
sodf2093>
git"
(native-complete--get-completions))
'("git" "git-cvsserver" "gitlab-runner"
"git-patch-id" "git-show-ref" "git-cvsimport"
"gitk" "git-parse-remote" "git-show-index")))
(should (equal (native-complete-test-with-setup
"di"
"di
dialog diff-jars dijkstra directfb-csource dirs disco disown
diff3 dig directfb-config dirname disable-paste dislocate
sodf2093>
diyK
"
(native-complete--get-completions))
'("dialog" "diff-jars" "dijkstra"
"directfb-csource" "dirs" "disco"
"disown" "diff3" "dig"
"directfb-config" "dirname" "disable-paste"
"dislocate"))))
(ert-deftest native-complete-test-cad ()
(should (equal (native-complete-test-with-setup
"get_"
"get_
get_attribute_list get_attribute_option get_attribute_value
get_tool_option get_transcript_tool get_xfdb_output_directory
get_xset_handling
KSETER> get_yK"
(native-complete--get-completions))
'("get_attribute_list" "get_attribute_option" "get_attribute_value"
"get_tool_option" "get_transcript_tool" "get_xfdb_output_directory"
"get_xset_handling")))
(should (equal (native-complete-test-with-setup
"ls ~/env/"
"ls ~/env/
Display all results? [y/n]
~/env/setup_foo ~/env/setup_bar ~/env/setup_baz
KSETER> ls ~/setup_ySETER> K"
(native-complete--get-completions))
'("setup_foo" "setup_bar" "setup_baz"))))
(provide 'native-complete-test)
;;; native-complete-test.el ends here