diff options
| author | Jim Porter | 2024-05-16 20:33:18 -0700 |
|---|---|---|
| committer | Jim Porter | 2024-05-16 20:33:18 -0700 |
| commit | 2f7d011d180b1e8d8dc6784cd9b48cf5690b7c62 (patch) | |
| tree | 17e687de2dd74aaf3081b3b6e84eaada18cf6c54 /test | |
| parent | 113bd2082c982df933df9b12c3994d6d582c8268 (diff) | |
| download | emacs-2f7d011d180b1e8d8dc6784cd9b48cf5690b7c62.tar.gz emacs-2f7d011d180b1e8d8dc6784cd9b48cf5690b7c62.zip | |
Add new Eshell built-in command 'funcall'
* lisp/eshell/esh-cmd.el (eshell/funcall): New function...
* test/lisp/eshell/em-glob-tests.el (em-glob-test/expand/splice-results)
(em-glob-test/expand/no-splice-results)
(em-glob-test/expand/explicitly-splice-results)
(em-glob-test/expand/explicitly-listify-results):
* test/lisp/eshell/esh-var-tests.el
(esh-var-test/quoted-interp-lisp-indices)
(esh-var-test/quoted-interp-cmd-indices)
(esh-var-test/interp-convert-quoted-var-number)
(esh-var-test/quoted-interp-convert-var-number)
(esh-var-test/quoted-interp-convert-quoted-var-number)
(esh-var-test/last-status-var-lisp-command)
(esh-var-test/last-result-var-split-indices)
(esh-var-test/last-arg-var-split-indices): ... use it in tests.
* doc/misc/eshell.texi (List of Built-ins): Describe this command.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/eshell/em-glob-tests.el | 24 | ||||
| -rw-r--r-- | test/lisp/eshell/esh-var-tests.el | 37 |
2 files changed, 32 insertions, 29 deletions
diff --git a/test/lisp/eshell/em-glob-tests.el b/test/lisp/eshell/em-glob-tests.el index d7d8f59eda0..2efb3a9df69 100644 --- a/test/lisp/eshell/em-glob-tests.el +++ b/test/lisp/eshell/em-glob-tests.el | |||
| @@ -72,9 +72,9 @@ component ending in \"symlink\" is treated as a symbolic link." | |||
| 72 | (eshell-glob-splice-results t)) | 72 | (eshell-glob-splice-results t)) |
| 73 | (with-fake-files '("a.el" "b.el" "c.txt") | 73 | (with-fake-files '("a.el" "b.el" "c.txt") |
| 74 | ;; Ensure the default expansion splices the glob. | 74 | ;; Ensure the default expansion splices the glob. |
| 75 | (eshell-command-result-equal "list *.el" '("a.el" "b.el")) | 75 | (eshell-command-result-equal "funcall list *.el" '("a.el" "b.el")) |
| 76 | (eshell-command-result-equal "list *.txt" '("c.txt")) | 76 | (eshell-command-result-equal "funcall list *.txt" '("c.txt")) |
| 77 | (eshell-command-result-equal "list *.no" '("*.no"))))) | 77 | (eshell-command-result-equal "funcall list *.no" '("*.no"))))) |
| 78 | 78 | ||
| 79 | (ert-deftest em-glob-test/expand/no-splice-results () | 79 | (ert-deftest em-glob-test/expand/no-splice-results () |
| 80 | "Test that globs are treated as lists when | 80 | "Test that globs are treated as lists when |
| @@ -83,11 +83,11 @@ component ending in \"symlink\" is treated as a symbolic link." | |||
| 83 | (eshell-glob-splice-results nil)) | 83 | (eshell-glob-splice-results nil)) |
| 84 | (with-fake-files '("a.el" "b.el" "c.txt") | 84 | (with-fake-files '("a.el" "b.el" "c.txt") |
| 85 | ;; Ensure the default expansion splices the glob. | 85 | ;; Ensure the default expansion splices the glob. |
| 86 | (eshell-command-result-equal "list *.el" '(("a.el" "b.el"))) | 86 | (eshell-command-result-equal "funcall list *.el" '(("a.el" "b.el"))) |
| 87 | (eshell-command-result-equal "list *.txt" '(("c.txt"))) | 87 | (eshell-command-result-equal "funcall list *.txt" '(("c.txt"))) |
| 88 | ;; The no-matches case is special here: the glob is just the | 88 | ;; The no-matches case is special here: the glob is just the |
| 89 | ;; string, not the list of results. | 89 | ;; string, not the list of results. |
| 90 | (eshell-command-result-equal "list *.no" '("*.no"))))) | 90 | (eshell-command-result-equal "funcall list *.no" '("*.no"))))) |
| 91 | 91 | ||
| 92 | (ert-deftest em-glob-test/expand/explicitly-splice-results () | 92 | (ert-deftest em-glob-test/expand/explicitly-splice-results () |
| 93 | "Test explicitly splicing globs works the same no matter the | 93 | "Test explicitly splicing globs works the same no matter the |
| @@ -97,11 +97,11 @@ value of `eshell-glob-splice-results'." | |||
| 97 | (ert-info ((format "eshell-glob-splice-results: %s" | 97 | (ert-info ((format "eshell-glob-splice-results: %s" |
| 98 | eshell-glob-splice-results)) | 98 | eshell-glob-splice-results)) |
| 99 | (with-fake-files '("a.el" "b.el" "c.txt") | 99 | (with-fake-files '("a.el" "b.el" "c.txt") |
| 100 | (eshell-command-result-equal "list $@{listify *.el}" | 100 | (eshell-command-result-equal "funcall list $@{listify *.el}" |
| 101 | '("a.el" "b.el")) | 101 | '("a.el" "b.el")) |
| 102 | (eshell-command-result-equal "list $@{listify *.txt}" | 102 | (eshell-command-result-equal "funcall list $@{listify *.txt}" |
| 103 | '("c.txt")) | 103 | '("c.txt")) |
| 104 | (eshell-command-result-equal "list $@{listify *.no}" | 104 | (eshell-command-result-equal "funcall list $@{listify *.no}" |
| 105 | '("*.no"))))))) | 105 | '("*.no"))))))) |
| 106 | 106 | ||
| 107 | (ert-deftest em-glob-test/expand/explicitly-listify-results () | 107 | (ert-deftest em-glob-test/expand/explicitly-listify-results () |
| @@ -112,11 +112,11 @@ value of `eshell-glob-splice-results'." | |||
| 112 | (ert-info ((format "eshell-glob-splice-results: %s" | 112 | (ert-info ((format "eshell-glob-splice-results: %s" |
| 113 | eshell-glob-splice-results)) | 113 | eshell-glob-splice-results)) |
| 114 | (with-fake-files '("a.el" "b.el" "c.txt") | 114 | (with-fake-files '("a.el" "b.el" "c.txt") |
| 115 | (eshell-command-result-equal "list ${listify *.el}" | 115 | (eshell-command-result-equal "funcall list ${listify *.el}" |
| 116 | '(("a.el" "b.el"))) | 116 | '(("a.el" "b.el"))) |
| 117 | (eshell-command-result-equal "list ${listify *.txt}" | 117 | (eshell-command-result-equal "funcall list ${listify *.txt}" |
| 118 | '(("c.txt"))) | 118 | '(("c.txt"))) |
| 119 | (eshell-command-result-equal "list ${listify *.no}" | 119 | (eshell-command-result-equal "funcall list ${listify *.no}" |
| 120 | '(("*.no")))))))) | 120 | '(("*.no")))))))) |
| 121 | 121 | ||
| 122 | 122 | ||
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index b94e8a276d7..1b46b214e77 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el | |||
| @@ -436,7 +436,7 @@ nil, use FUNCTION instead." | |||
| 436 | 436 | ||
| 437 | (ert-deftest esh-var-test/quoted-interp-lisp-indices () | 437 | (ert-deftest esh-var-test/quoted-interp-lisp-indices () |
| 438 | "Interpolate Lisp form evaluation with index." | 438 | "Interpolate Lisp form evaluation with index." |
| 439 | (eshell-command-result-equal "concat \"$(list 1 2)[1]\" cool" | 439 | (eshell-command-result-equal "funcall concat \"$(list 1 2)[1]\" cool" |
| 440 | "2cool")) | 440 | "2cool")) |
| 441 | 441 | ||
| 442 | (ert-deftest esh-var-test/quoted-interp-cmd () | 442 | (ert-deftest esh-var-test/quoted-interp-cmd () |
| @@ -446,7 +446,7 @@ nil, use FUNCTION instead." | |||
| 446 | 446 | ||
| 447 | (ert-deftest esh-var-test/quoted-interp-cmd-indices () | 447 | (ert-deftest esh-var-test/quoted-interp-cmd-indices () |
| 448 | "Interpolate command result with index inside double-quotes." | 448 | "Interpolate command result with index inside double-quotes." |
| 449 | (eshell-command-result-equal "concat \"${listify 1 2}[1]\" cool" | 449 | (eshell-command-result-equal "funcall concat \"${listify 1 2}[1]\" cool" |
| 450 | "2cool")) | 450 | "2cool")) |
| 451 | 451 | ||
| 452 | (ert-deftest esh-var-test/quoted-interp-temp-cmd () | 452 | (ert-deftest esh-var-test/quoted-interp-temp-cmd () |
| @@ -504,9 +504,9 @@ nil, use FUNCTION instead." | |||
| 504 | (ert-deftest esh-var-test/interp-convert-quoted-var-number () | 504 | (ert-deftest esh-var-test/interp-convert-quoted-var-number () |
| 505 | "Interpolate numeric quoted numeric variable." | 505 | "Interpolate numeric quoted numeric variable." |
| 506 | (let ((eshell-test-value 123)) | 506 | (let ((eshell-test-value 123)) |
| 507 | (eshell-command-result-equal "type-of $'eshell-test-value'" | 507 | (eshell-command-result-equal "funcall type-of $'eshell-test-value'" |
| 508 | 'integer) | 508 | 'integer) |
| 509 | (eshell-command-result-equal "type-of $\"eshell-test-value\"" | 509 | (eshell-command-result-equal "funcall type-of $\"eshell-test-value\"" |
| 510 | 'integer))) | 510 | 'integer))) |
| 511 | 511 | ||
| 512 | (ert-deftest esh-var-test/interp-convert-quoted-var-split-indices () | 512 | (ert-deftest esh-var-test/interp-convert-quoted-var-split-indices () |
| @@ -546,7 +546,7 @@ nil, use FUNCTION instead." | |||
| 546 | (ert-deftest esh-var-test/quoted-interp-convert-var-number () | 546 | (ert-deftest esh-var-test/quoted-interp-convert-var-number () |
| 547 | "Interpolate numeric variable inside double-quotes." | 547 | "Interpolate numeric variable inside double-quotes." |
| 548 | (let ((eshell-test-value 123)) | 548 | (let ((eshell-test-value 123)) |
| 549 | (eshell-command-result-equal "type-of \"$eshell-test-value\"" | 549 | (eshell-command-result-equal "funcall type-of \"$eshell-test-value\"" |
| 550 | 'string))) | 550 | 'string))) |
| 551 | 551 | ||
| 552 | (ert-deftest esh-var-test/quoted-interp-convert-var-split-indices () | 552 | (ert-deftest esh-var-test/quoted-interp-convert-var-split-indices () |
| @@ -560,10 +560,11 @@ nil, use FUNCTION instead." | |||
| 560 | (ert-deftest esh-var-test/quoted-interp-convert-quoted-var-number () | 560 | (ert-deftest esh-var-test/quoted-interp-convert-quoted-var-number () |
| 561 | "Interpolate numeric quoted variable inside double-quotes." | 561 | "Interpolate numeric quoted variable inside double-quotes." |
| 562 | (let ((eshell-test-value 123)) | 562 | (let ((eshell-test-value 123)) |
| 563 | (eshell-command-result-equal "type-of \"$'eshell-test-value'\"" | 563 | (eshell-command-result-equal "funcall type-of \"$'eshell-test-value'\"" |
| 564 | 'string) | 564 | 'string) |
| 565 | (eshell-command-result-equal "type-of \"$\\\"eshell-test-value\\\"\"" | 565 | (eshell-command-result-equal |
| 566 | 'string))) | 566 | "funcall type-of \"$\\\"eshell-test-value\\\"\"" |
| 567 | 'string))) | ||
| 567 | 568 | ||
| 568 | (ert-deftest esh-var-test/quoted-interp-convert-quoted-var-split-indices () | 569 | (ert-deftest esh-var-test/quoted-interp-convert-quoted-var-split-indices () |
| 569 | "Interpolate quoted string variable with indices inside double-quotes." | 570 | "Interpolate quoted string variable with indices inside double-quotes." |
| @@ -905,11 +906,11 @@ the value of the $PAGER env var." | |||
| 905 | (ert-deftest esh-var-test/last-status-var-lisp-command () | 906 | (ert-deftest esh-var-test/last-status-var-lisp-command () |
| 906 | "Test using the \"last exit status\" ($?) variable with a Lisp command." | 907 | "Test using the \"last exit status\" ($?) variable with a Lisp command." |
| 907 | (with-temp-eshell | 908 | (with-temp-eshell |
| 908 | (eshell-match-command-output "zerop 0; echo $?" | 909 | (eshell-match-command-output "funcall zerop 0; echo $?" |
| 909 | "t\n0\n") | 910 | "t\n0\n") |
| 910 | (eshell-match-command-output "zerop 1; echo $?" | 911 | (eshell-match-command-output "funcall zerop 1; echo $?" |
| 911 | "0\n") | 912 | "0\n") |
| 912 | (eshell-match-command-output "zerop foo; echo $?" | 913 | (eshell-match-command-output "funcall zerop foo; echo $?" |
| 913 | "1\n" nil t))) | 914 | "1\n" nil t))) |
| 914 | 915 | ||
| 915 | (ert-deftest esh-var-test/last-status-var-lisp-form () | 916 | (ert-deftest esh-var-test/last-status-var-lisp-form () |
| @@ -972,10 +973,10 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil." | |||
| 972 | "Test using the \"last result\" ($$) variable with split indices." | 973 | "Test using the \"last result\" ($$) variable with split indices." |
| 973 | (with-temp-eshell | 974 | (with-temp-eshell |
| 974 | (eshell-match-command-output | 975 | (eshell-match-command-output |
| 975 | "string-join (list \"01\" \"02\") :; + $$[: 1] 3" | 976 | "funcall string-join (list \"01\" \"02\") :; + $$[: 1] 3" |
| 976 | "01:02\n5\n") | 977 | "01:02\n5\n") |
| 977 | (eshell-match-command-output | 978 | (eshell-match-command-output |
| 978 | "string-join (list \"01\" \"02\") :; echo \"$$[: 1]\"" | 979 | "funcall string-join (list \"01\" \"02\") :; echo \"$$[: 1]\"" |
| 979 | "01:02\n02\n"))) | 980 | "01:02\n02\n"))) |
| 980 | 981 | ||
| 981 | (ert-deftest esh-var-test/last-arg-var () | 982 | (ert-deftest esh-var-test/last-arg-var () |
| @@ -995,9 +996,11 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil." | |||
| 995 | (ert-deftest esh-var-test/last-arg-var-split-indices () | 996 | (ert-deftest esh-var-test/last-arg-var-split-indices () |
| 996 | "Test using the \"last arg\" ($_) variable with split indices." | 997 | "Test using the \"last arg\" ($_) variable with split indices." |
| 997 | (with-temp-eshell | 998 | (with-temp-eshell |
| 998 | (eshell-match-command-output "concat 01:02 03:04; + $_[0][: 1] 5" | 999 | (eshell-match-command-output |
| 999 | "01:0203:04\n7\n") | 1000 | "funcall concat 01:02 03:04; + $_[1][: 1] 5" |
| 1000 | (eshell-match-command-output "concat 01:02 03:04; echo \"$_[0][: 1]\"" | 1001 | "01:0203:04\n7\n") |
| 1001 | "01:0203:04\n02\n"))) | 1002 | (eshell-match-command-output |
| 1003 | "funcall concat 01:02 03:04; echo \"$_[1][: 1]\"" | ||
| 1004 | "01:0203:04\n02\n"))) | ||
| 1002 | 1005 | ||
| 1003 | ;; esh-var-tests.el ends here | 1006 | ;; esh-var-tests.el ends here |