aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJim Porter2022-09-13 16:14:00 -0700
committerJim Porter2022-09-14 17:27:21 -0700
commitb8e9239b47391c6628d94a4e2e91320c5366d27b (patch)
tree9c36827e8763f35d18984ee41c00dd02715729c0 /test
parent30ca49c8f64b73f991d94b10afcfc0e2d592fe6a (diff)
downloademacs-b8e9239b47391c6628d94a4e2e91320c5366d27b.tar.gz
emacs-b8e9239b47391c6628d94a4e2e91320c5366d27b.zip
Allow using a symbol as an index into an alist in Eshell
* lisp/eshell/esh-var.el (eshell-index-value): If INDEX is a symbol, use 'assoc' for indexing. * test/lisp/eshell/esh-var-tests.el (esh-var-test/interp-var-assoc) (esh-var-test/quoted-interp-var-assoc): Add checks for indexing via symbol (bug#57787).
Diffstat (limited to 'test')
-rw-r--r--test/lisp/eshell/esh-var-tests.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el
index bebc57d3592..cb5b1766bb5 100644
--- a/test/lisp/eshell/esh-var-tests.el
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -105,9 +105,11 @@
105 105
106(ert-deftest esh-var-test/interp-var-assoc () 106(ert-deftest esh-var-test/interp-var-assoc ()
107 "Interpolate alist variable with index" 107 "Interpolate alist variable with index"
108 (let ((eshell-test-value '(("foo" . 1)))) 108 (let ((eshell-test-value '(("foo" . 1) (bar . 2))))
109 (eshell-command-result-equal "echo $eshell-test-value[foo]" 109 (eshell-command-result-equal "echo $eshell-test-value[foo]"
110 1))) 110 1)
111 (eshell-command-result-equal "echo $eshell-test-value[#'bar]"
112 2)))
111 113
112(ert-deftest esh-var-test/interp-var-length-list () 114(ert-deftest esh-var-test/interp-var-length-list ()
113 "Interpolate length of list variable" 115 "Interpolate length of list variable"
@@ -257,9 +259,11 @@ inside double-quotes"
257 259
258(ert-deftest esh-var-test/quoted-interp-var-assoc () 260(ert-deftest esh-var-test/quoted-interp-var-assoc ()
259 "Interpolate alist variable with index inside double-quotes" 261 "Interpolate alist variable with index inside double-quotes"
260 (let ((eshell-test-value '(("foo" . 1)))) 262 (let ((eshell-test-value '(("foo" . 1) (bar . 2))))
261 (eshell-command-result-equal "echo \"$eshell-test-value[foo]\"" 263 (eshell-command-result-equal "echo \"$eshell-test-value[foo]\""
262 "1"))) 264 "1")
265 (eshell-command-result-equal "echo \"$eshell-test-value[#'bar]\""
266 "2")))
263 267
264(ert-deftest esh-var-test/quoted-interp-var-length-list () 268(ert-deftest esh-var-test/quoted-interp-var-length-list ()
265 "Interpolate length of list variable inside double-quotes" 269 "Interpolate length of list variable inside double-quotes"