aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJim Porter2024-11-03 11:56:15 -0800
committerJim Porter2024-11-03 20:18:14 -0800
commitee87af4f1603d2042afa641e74df0403a49af1c5 (patch)
tree1035df93e5f928364563783d01af1a3aeaf66568 /test
parented9ea57e57a915e743100591d7a71d44a4b4c0e9 (diff)
downloademacs-ee87af4f1603d2042afa641e74df0403a49af1c5.tar.gz
emacs-ee87af4f1603d2042afa641e74df0403a49af1c5.zip
Add support for range objects in Eshell "for" loops
* lisp/eshell/esh-cmd.el (eshell-for-iterate): Add support for 'eshell-range' objects. * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/for-loop-range): New test. * doc/misc/eshell.texi (Control Flow): Update documentation. * etc/NEWS: Announce this change.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/eshell/esh-cmd-tests.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el
index ae1aed59b45..64ac3a8c2f6 100644
--- a/test/lisp/eshell/esh-cmd-tests.el
+++ b/test/lisp/eshell/esh-cmd-tests.el
@@ -341,6 +341,21 @@ processes correctly."
341 (eshell-match-command-output "for i in `[1 2 3] { echo $i }" 341 (eshell-match-command-output "for i in `[1 2 3] { echo $i }"
342 "1\n2\n3\n"))) 342 "1\n2\n3\n")))
343 343
344(ert-deftest esh-cmd-test/for-loop-range ()
345 "Test invocation of a for loop iterating over a range."
346 (with-temp-eshell
347 (eshell-match-command-output "for i in 1..5 { echo $i }"
348 "1\n2\n3\n4\n")
349 (let ((eshell-test-value 2))
350 (eshell-match-command-output "for i in $eshell-test-value..5 { echo $i }"
351 "2\n3\n4\n"))
352 ;; Make sure range syntax only work when it's part of the literal
353 ;; syntax; a variable expanding to something that looks like a range
354 ;; doesn't count.
355 (let ((eshell-test-value "1..5"))
356 (eshell-match-command-output "for i in $eshell-test-value { echo $i }"
357 "1..5\n")))))
358
344(ert-deftest esh-cmd-test/for-loop-mixed-args () 359(ert-deftest esh-cmd-test/for-loop-mixed-args ()
345 "Test invocation of a for loop iterating over multiple arguments." 360 "Test invocation of a for loop iterating over multiple arguments."
346 (with-temp-eshell 361 (with-temp-eshell