[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Learning something more about Emacs tests
From: |
Lele Gaifax |
Subject: |
Learning something more about Emacs tests |
Date: |
Fri, 18 Dec 2015 18:34:45 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Hi all,
I tried to extend test/automated/tabulated-list-test.el to cover Bug#22194
(that Eli quickly fixed in fb2eaf0ffc213fac170cff4814b7c93bd0c44c20, thanks!).
I understand that I'm probably wasting my time since the issue is closed, but
just for the sake of learning something more about Emacs testing, I persevered
another bit, trying to understand what I'm missing. I'm sorry for the length
of this post, but hopefully some of you can shed some light on me... :-)
I basically installed the following patch:
diff --git a/test/automated/tabulated-list-test.el
b/test/automated/tabulated-list-test.el
index 9aa62ee..49353a7 100644
--- a/test/automated/tabulated-list-test.el
+++ b/test/automated/tabulated-list-test.el
@@ -28,7 +28,8 @@ tabulated-list--test-entries
'(("zzzz-game" ["zzzz-game" "zzzz-game" "2113" "installed" " play zzzz in
Emacs"])
("4clojure" ["4clojure" "4clojure" "1507" "obsolete" " Open and
evaluate 4clojure.com questions"])
("abc-mode" ["abc-mode" "abc-mode" "944" "available" " Major mode for
editing abc music files"])
- ("mode" ["mode" "mode" "1128" "installed" " A simple mode for
editing Actionscript 3 files"])))
+ ("mode" ["mode" "mode" "1128" "installed" " A simple mode for
editing Actionscript 3 files"])
+ ("foo-mode" ["foo-mode" "foo-mode" "1234" "installed" " A simple mode
for editing Foo files"])))
(defun tabulated-list--test-sort-car (a b)
(string< (car a) (car b)))
@@ -59,7 +60,8 @@ tabulated-list--test-with-buffer
" zzzz-game zzzz-game 2113 installed play
zzzz in Emacs
4clojure 4clojure 1507 obsolete Open and evaluate
4clojure.com questions
abc-mode abc-mode 944 available Major mode for editing
abc music files
- mode mode 1128 installed A simple mode for editing
Actionscript 3 files\n"))
+ mode mode 1128 installed A simple mode for editing
Actionscript 3 files
+ foo-mode foo-mode 1234 installed A simple mode for editing
Foo files\n"))
;; Preserve position.
(forward-line 3)
(let ((pos (thing-at-point 'line)))
@@ -69,14 +71,16 @@ tabulated-list--test-with-buffer
(should (string= (buffer-substring-no-properties (point-min)
(point-max))
" 4clojure 4clojure 1507 obsolete
Open and evaluate 4clojure.com questions
abc-mode abc-mode 944 available Major mode for editing
abc music files
- mode mode 1128 installed A simple mode for editing
Actionscript 3 files\n"))
+ mode mode 1128 installed A simple mode for editing
Actionscript 3 files
+ foo-mode foo-mode 1234 installed A simple mode for editing
Foo files\n"))
;; Check the UPDATE argument
(pop tabulated-list-entries)
(setf (cdr (car tabulated-list-entries)) (list ["x" "x" "944"
"available" " XX"]))
(tabulated-list-print t t)
(should (string= (buffer-substring-no-properties (point-min)
(point-max))
" x x 944 available XX
- mode mode 1128 installed A simple mode for editing
Actionscript 3 files\n"))
+ mode mode 1128 installed A simple mode for editing
Actionscript 3 files
+ foo-mode foo-mode 1234 installed A simple mode for editing
Foo files\n"))
(should (equal (thing-at-point 'line) pos)))))
(ert-deftest tabulated-list-sort ()
@@ -88,6 +92,7 @@ tabulated-list--test-with-buffer
(let ((text (buffer-substring-no-properties (point-min) (point-max))))
(should (string= text " 4clojure 4clojure 1507 obsolete
Open and evaluate 4clojure.com questions
abc-mode abc-mode 944 available Major mode for editing
abc music files
+ foo-mode foo-mode 1234 installed A simple mode for editing
Foo files
mode mode 1128 installed A simple mode for editing
Actionscript 3 files
zzzz-game zzzz-game 2113 installed play zzzz in Emacs\n"))
@@ -103,6 +108,7 @@ tabulated-list--test-with-buffer
(should (string= (buffer-substring-no-properties (point-min)
(point-max))
" zzzz-game zzzz-game 2113 installed
play zzzz in Emacs
mode mode 1128 installed A simple mode for editing
Actionscript 3 files
+ foo-mode foo-mode 1234 installed A simple mode for editing
Foo files
abc-mode abc-mode 944 available Major mode for editing
abc music files
4clojure 4clojure 1507 obsolete Open and evaluate
4clojure.com questions\n"))
;; Again
that recreates the conditions I met (without breaking existing tests :-)
Then I added the following new test:
(ert-deftest tabulated-list-visual-move ()
;; See Bug#22194
(tabulated-list--test-with-buffer
(goto-char (point-min))
(skip-chars-forward "[:blank:]")
(skip-chars-forward "[:word:]-")
(backward-char)
;; now the cursor is on the ending “e” of “zzzz-game”
(funcall-interactively 'next-line 3)
(funcall-interactively 'next-line)
(should (equal (line-number-at-pos (point)) 5))))
To my surprise, this test passes, either before or after Eli's fix. I tried
several variants in the way I call the next-line function, but either moving
one line at at time or in two steps like I did above, I was not able to
reproduce the initial bug case.
Even executing it interactively, there is some "subtle" difference in hitting
the “n” key (bound to next-line) and doing that with “M-:
(funcall-interactively 'next-line)”.
*Before* Eli's fix, in the latter case after the second evaluation the cursor
ends at column 1 (ie just before the package name) and stays there in the
succeeding evaluations. *After* the fix, it goes at column 7 (that is, one
space after the name “mode”) and stays there.
On the other hand, using the “n” key to invoke it, before the fix it exhibit
the behaviour described in the bug report, while now it honors the goal-column
(or something similar): if the package name on the current line is longer than
the first one, the cursor stays at the initial column.
What am I doing wrong? How can I programmatically exercise the next-line
function retaining the interactive behaviour?
Thank you for any hint,
bye, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
address@hidden | -- Fortunato Depero, 1929.
- Learning something more about Emacs tests,
Lele Gaifax <=