aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJim Porter2022-09-18 17:42:09 -0700
committerJim Porter2022-11-03 11:44:41 -0700
commitd2a9dae40057ff16683d9c5f30a3b04500ebc4cf (patch)
treecd34f064081354464eeac91b4ee2aa76a2a23982 /test
parent39f5696921c1618f46358a5c189244d3993a1fca (diff)
downloademacs-d2a9dae40057ff16683d9c5f30a3b04500ebc4cf.tar.gz
emacs-d2a9dae40057ff16683d9c5f30a3b04500ebc4cf.zip
Only strip newlines when stringifying a value for Eshell
* lisp/eshell/esh-util.el (eshell-stringify): Use 'string-trim-right' instead of stripping the last character of the result of 'pp-to-string' (bug#58810). * test/lisp/eshell/esh-util-tests.el: New file.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/eshell/esh-util-tests.el57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/lisp/eshell/esh-util-tests.el b/test/lisp/eshell/esh-util-tests.el
new file mode 100644
index 00000000000..1cbd015999f
--- /dev/null
+++ b/test/lisp/eshell/esh-util-tests.el
@@ -0,0 +1,57 @@
1;;; esh-util-tests.el --- esh-util test suite -*- lexical-binding:t -*-
2
3;; Copyright (C) 2022 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Code:
21
22(require 'ert)
23(require 'esh-util)
24
25;;; Tests:
26
27(ert-deftest esh-util-test/eshell-stringify/string ()
28 "Test that `eshell-stringify' preserves the value of strings."
29 (should (equal (eshell-stringify "hello") "hello")))
30
31(ert-deftest esh-util-test/eshell-stringify/number ()
32 "Test that `eshell-stringify' converts numbers to strings."
33 (should (equal (eshell-stringify 42) "42"))
34 (should (equal (eshell-stringify 4.2) "4.2")))
35
36(ert-deftest esh-util-test/eshell-stringify/t ()
37 "Test that `eshell-stringify' treats `t' according to `eshell-stringify-t'."
38 (let ((eshell-stringify-t t))
39 (should (equal (eshell-stringify t) "t")))
40 (let ((eshell-stringify-t nil))
41 (should (equal (eshell-stringify t) nil))))
42
43(ert-deftest esh-util-test/eshell-stringify/nil ()
44 "Test that `eshell-stringify' converts nil to a string."
45 (should (equal (eshell-stringify nil) "nil")))
46
47(ert-deftest esh-util-test/eshell-stringify/list ()
48 "Test that `eshell-stringify' correctly stringifies lists."
49 (should (equal (eshell-stringify '(1 2 3)) "(1 2 3)"))
50 (should (equal (eshell-stringify '((1 2) (3 . 4)))
51 "((1 2)\n (3 . 4))")))
52
53(ert-deftest esh-util-test/eshell-stringify/complex ()
54 "Test that `eshell-stringify' correctly stringifies complex objects."
55 (should (equal (eshell-stringify (list 'quote 'hello)) "'hello")))
56
57;;; esh-util-tests.el ends here