emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8558ecd: Fix string-replace error data


From: Basil L. Contovounesios
Subject: master 8558ecd: Fix string-replace error data
Date: Sun, 7 Mar 2021 09:58:08 -0500 (EST)

branch: master
commit 8558ecd65fc1c87345353f6352299df04280e729
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Fix string-replace error data
    
    * lisp/subr.el (string-replace): Signal an error with data that is a
    list, and whose contents are consistent with other uses of
    wrong-length-argument.
    * test/lisp/subr-tests.el (string-replace): Test for this.
    (subr-test-define-prefix-command): Pacify byte-compiler warnings.
---
 lisp/subr.el            | 2 +-
 test/lisp/subr-tests.el | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 0b56347..77bc7a3 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4784,7 +4784,7 @@ Unless optional argument INPLACE is non-nil, return a new 
string."
   "Replace FROMSTRING with TOSTRING in INSTRING each time it occurs."
   (declare (pure t) (side-effect-free t))
   (when (equal fromstring "")
-    (signal 'wrong-length-argument fromstring))
+    (signal 'wrong-length-argument '(0)))
   (let ((start 0)
         (result nil)
         pos)
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index fc5a1eb..7a116aa 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -78,10 +78,14 @@
 
 (ert-deftest subr-test-define-prefix-command ()
   (define-prefix-command 'foo-prefix-map)
+  (defvar foo-prefix-map)
+  (declare-function foo-prefix-map "subr-tests")
   (should (keymapp foo-prefix-map))
   (should (fboundp #'foo-prefix-map))
   ;; With optional argument.
   (define-prefix-command 'bar-prefix 'bar-prefix-map)
+  (defvar bar-prefix-map)
+  (declare-function bar-prefix "subr-tests")
   (should (keymapp bar-prefix-map))
   (should (fboundp #'bar-prefix))
   ;; Returns the symbol.
@@ -531,7 +535,8 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350.";
   (should (equal (string-replace "a" "aa" "aaa") "aaaaaa"))
   (should (equal (string-replace "abc" "defg" "abc") "defg"))
 
-  (should-error (string-replace "" "x" "abc")))
+  (should (equal (should-error (string-replace "" "x" "abc"))
+                 '(wrong-length-argument 0))))
 
 (ert-deftest subr-replace-regexp-in-string ()
   (should (equal (replace-regexp-in-string "a+" "xy" "abaabbabaaba")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]