summaryrefslogtreecommitdiff
path: root/test/lisp/eshell/em-cmpl-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp/eshell/em-cmpl-tests.el')
-rw-r--r--test/lisp/eshell/em-cmpl-tests.el86
1 files changed, 76 insertions, 10 deletions
diff --git a/test/lisp/eshell/em-cmpl-tests.el b/test/lisp/eshell/em-cmpl-tests.el
index ea907f1945d..29a41625d5e 100644
--- a/test/lisp/eshell/em-cmpl-tests.el
+++ b/test/lisp/eshell/em-cmpl-tests.el
@@ -69,11 +69,10 @@ ACTUAL and EXPECTED should both be lists of strings."
(ert-deftest em-cmpl-test/parse-arguments/pipeline ()
"Test that parsing arguments for completion discards earlier commands."
(with-temp-eshell
- (let ((eshell-test-value '("foo" "bar")))
- (insert "echo hi | cat")
- (should (eshell-arguments-equal
- (car (eshell-complete-parse-arguments))
- '("cat"))))))
+ (insert "echo hi | cat")
+ (should (eshell-arguments-equal
+ (car (eshell-complete-parse-arguments))
+ '("cat")))))
(ert-deftest em-cmpl-test/parse-arguments/multiple-dots ()
"Test parsing arguments with multiple dots like \".../\"."
@@ -123,6 +122,45 @@ ACTUAL and EXPECTED should both be lists of strings."
(car (eshell-complete-parse-arguments))
'("echo" "foo" "bar"))))))
+(ert-deftest em-cmpl-test/parse-arguments/unevaluated-subcommand ()
+ "Test that subcommands return a stub when parsing for completion."
+ (with-temp-eshell
+ (insert "echo {echo hi}")
+ (should (eshell-arguments-equal
+ (car (eshell-complete-parse-arguments))
+ `("echo" ,(propertize
+ "\0" 'eshell-argument-stub 'named-command)))))
+ (with-temp-eshell
+ (insert "echo ${echo hi}")
+ (should (eshell-arguments-equal
+ (car (eshell-complete-parse-arguments))
+ `("echo" ,(propertize
+ "\0" 'eshell-argument-stub 'named-command))))))
+
+(ert-deftest em-cmpl-test/parse-arguments/unevaluated-lisp-form ()
+ "Test that Lisp forms return a stub when parsing for completion."
+ (with-temp-eshell
+ (insert "echo (concat \"hi\")")
+ (should (eshell-arguments-equal
+ (car (eshell-complete-parse-arguments))
+ `("echo" ,(propertize
+ "\0" 'eshell-argument-stub 'lisp-command)))))
+ (with-temp-eshell
+ (insert "echo $(concat \"hi\")")
+ (should (eshell-arguments-equal
+ (car (eshell-complete-parse-arguments))
+ `("echo" ,(propertize
+ "\0" 'eshell-argument-stub 'lisp-command))))))
+
+(ert-deftest em-cmpl-test/parse-arguments/unevaluated-inner-subcommand ()
+ "Test that nested subcommands return a stub when parsing for completion."
+ (with-temp-eshell
+ (insert "echo $exec-path[${echo 0}]")
+ (should (eshell-arguments-equal
+ (car (eshell-complete-parse-arguments))
+ `("echo" ,(propertize
+ "\0" 'eshell-argument-stub 'named-command))))))
+
(ert-deftest em-cmpl-test/file-completion/unique ()
"Test completion of file names when there's a unique result."
(with-temp-eshell
@@ -150,14 +188,39 @@ ACTUAL and EXPECTED should both be lists of strings."
(forward-line -1)
(should (looking-at "Complete, but not unique")))))))
+(ert-deftest em-cmpl-test/file-completion/glob ()
+ "Test completion of file names using a glob."
+ (with-temp-eshell
+ (ert-with-temp-directory default-directory
+ (write-region nil nil (expand-file-name "file.txt"))
+ (write-region nil nil (expand-file-name "file.el"))
+ (should (equal (eshell-insert-and-complete "echo fi*.el")
+ "echo file.el ")))))
+
(ert-deftest em-cmpl-test/file-completion/after-list ()
"Test completion of file names after previous list arguments.
See bug#59956."
(with-temp-eshell
- (ert-with-temp-directory default-directory
- (write-region nil nil (expand-file-name "file.txt"))
- (should (equal (eshell-insert-and-complete "echo (list 1 2) fi")
- "echo (list 1 2) file.txt ")))))
+ (let ((eshell-test-value '("foo" "bar")))
+ (ert-with-temp-directory default-directory
+ (write-region nil nil (expand-file-name "file.txt"))
+ (should (equal (eshell-insert-and-complete "echo $eshell-test-value fi")
+ "echo $eshell-test-value file.txt "))))))
+
+(ert-deftest em-cmpl-test/command-completion ()
+ "Test completion of command names like \"command\"."
+ (with-temp-eshell
+ (should (equal (eshell-insert-and-complete "listif")
+ "listify "))))
+
+(ert-deftest em-cmpl-test/subcommand-completion ()
+ "Test completion of command names like \"{command}\"."
+ (with-temp-eshell
+ (should (equal (eshell-insert-and-complete "{ listif")
+ "{ listify ")))
+ (with-temp-eshell
+ (should (equal (eshell-insert-and-complete "echo ${ listif")
+ "echo ${ listify "))))
(ert-deftest em-cmpl-test/lisp-symbol-completion ()
"Test completion of Lisp forms like \"#'symbol\" and \"`symbol\".
@@ -174,7 +237,10 @@ See <lisp/eshell/esh-cmd.el>."
See <lisp/eshell/esh-cmd.el>."
(with-temp-eshell
(should (equal (eshell-insert-and-complete "echo (eshell/ech")
- "echo (eshell/echo"))))
+ "echo (eshell/echo")))
+ (with-temp-eshell
+ (should (equal (eshell-insert-and-complete "echo $(eshell/ech")
+ "echo $(eshell/echo"))))
(ert-deftest em-cmpl-test/special-ref-completion/type ()
"Test completion of the start of special references like \"#<buffer\".