unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: "João Távora" <joaotavora@gmail.com>
Cc: Alan Mackenzie <acm@muc.de>,
	control@debbugs.gnu.org,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	39680@debbugs.gnu.org
Subject: bug#39680: Test case
Date: Wed, 20 May 2020 00:05:18 +0200	[thread overview]
Message-ID: <87tv0bfun5.fsf_-_@gmail.com> (raw)
In-Reply-To: <877dxgtae9.fsf@gmail.com> ("Kévin Le Gouguec"'s message of "Wed, 13 May 2020 12:08:30 +0200")

[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

Finally nailed it, after finding out about ert-simulate-command.

The following patch adds a test that passes on master and emacs-27, and
"successfully fails" when reverting Stefan's fix (commit c1ce9fa7f2).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-test-for-bug-39680.patch --]
[-- Type: text/x-patch, Size: 1414 bytes --]

From c83fbd50f0f0999814f09706fc908df5c22c5a47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Tue, 19 May 2020 23:17:04 +0200
Subject: [PATCH] Add test for bug#39680

* test/lisp/electric-tests.el (electric-pair-undo-unrelated-state):
New test.
---
 test/lisp/electric-tests.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 56d1bdb110..67f474cbd5 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -546,6 +546,24 @@ js-mode-braces-with-layout-and-indent
       (electric-pair-delete-pair 1)
       (should (equal "" (buffer-string))))))
 
+\f
+;;; Undoing
+(ert-deftest electric-pair-undo-unrelated-state ()
+  "Make sure `electric-pair-mode' does not confuse `undo' (bug#39680)."
+  (with-temp-buffer
+    (buffer-enable-undo)
+    (electric-pair-local-mode)
+    (let ((last-command-event ?\())
+      (ert-simulate-command '(self-insert-command 1)))
+    (undo-boundary)
+    (let ((last-command-event ?a))
+      (ert-simulate-command '(self-insert-command 1)))
+    (undo-boundary)
+    (ert-simulate-command '(undo))
+    (let ((last-command-event ?\())
+      (ert-simulate-command '(self-insert-command 1)))
+    (should (string= (buffer-string) "(())"))))
+
 \f
 ;;; Electric newlines between pairs
 ;;; TODO: better tests
-- 
2.26.2


  parent reply	other threads:[~2020-05-19 22:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 18:34 bug#39680: 27.0.60; electric-pair-mode broken by undo Kévin Le Gouguec
2020-02-25 19:34 ` Alan Mackenzie
2020-03-09 18:26   ` Stefan Monnier
2020-03-10  6:45     ` Kévin Le Gouguec
2020-03-11 15:31       ` Stefan Monnier
2020-03-11 16:20         ` Eli Zaretskii
2020-03-12 14:04           ` Stefan Monnier
     [not found]       ` <87d078ajzs.fsf@gmail.com>
     [not found]         ` <87blmstg0v.fsf@gmail.com>
     [not found]           ` <87blms6ww9.fsf@gmail.com>
     [not found]             ` <877dxgtae9.fsf@gmail.com>
2020-05-19 22:05               ` Kévin Le Gouguec [this message]
2020-05-19 22:26                 ` bug#39680: Test case Kévin Le Gouguec
2020-05-19 23:17                 ` João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tv0bfun5.fsf_-_@gmail.com \
    --to=kevin.legouguec@gmail.com \
    --cc=39680@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=control@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).