all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: "Simen Heggestøyl" <simenheg@gmail.com>
Cc: 36009@debbugs.gnu.org, Paul Eggert <eggert@cs.ucla.edu>
Subject: bug#36009: [PATCH] Use lexical-binding in textmodes/page.el and add tests
Date: Fri, 14 Jun 2019 00:02:21 +0200	[thread overview]
Message-ID: <CADwFkmm4oVUJ6C1VX9ruz5Fd0LufOUwhHDm40YFsc3Lbc5R0AA@mail.gmail.com> (raw)
In-Reply-To: <5cf3a401.1c69fb81.d8546.e65d@mx.google.com>

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

Simen Heggestøyl <simenheg@gmail.com> writes:
> Oh, sorry Stefan, what a coincidence! I chose that file at random
> yesterday. I should do a Debbugs search in advance next time.

No worries -- this fruit was clearly ripe for the taking. :)

> Regarding the tests they look almost identical, except that I left out
> tests for `count-lines-page' and `what-page', because I was unsure
> whether they would be too dependent on the format of the user messages.
>
> Maybe it would be good to factor out the meat of `count-lines-page'
> and `what-page' into two internal functions returning just the raw
> numbers, test those, and turn the interactive functions into
> interfaces for them?

Thanks for your input.

I did an experiment in your suggested direction, but it didn't come
out very successful.  In particular, I felt like I had to make this
simple and straightforward code ugly and convoluted.  I could attach
the final result of that experiment here, but I don't think it's very
helpful.

Based on this, I'm instead suggesting the attached simple patch for
installation.  It depends on the message string, but this should be
easy to update in the future if the format changes.

Thanks,
Stefan Kangas

[-- Attachment #2: 0001-Add-tests-for-count-lines-page-and-what-page.patch --]
[-- Type: text/x-patch, Size: 1461 bytes --]

From ff0fa006cae4b6220a5e765e25f3eef1f46edef0 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Thu, 13 Jun 2019 23:46:04 +0200
Subject: [PATCH] Add tests for count-lines-page and what-page

* test/lisp/textmodes/page-tests.el (page-tests-count-lines-page)
(page-tests-what-page): New test cases. (bug#36009)
---
 test/lisp/textmodes/page-tests.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/test/lisp/textmodes/page-tests.el b/test/lisp/textmodes/page-tests.el
index 0834d65433..8d2a036022 100644
--- a/test/lisp/textmodes/page-tests.el
+++ b/test/lisp/textmodes/page-tests.el
@@ -82,5 +82,24 @@ page-tests--region-string
     (narrow-to-page -1)
     (should (equal (buffer-string) "bar\n"))))
 
+(ert-deftest page-tests-count-lines-page ()
+  (with-temp-buffer
+    (insert "foo\n\f\nbar\n\f\nbaz")
+    (goto-char (point-min))
+    (should (equal (count-lines-page) "Page has 1 line (0 + 1)"))
+    (goto-char (point-max))
+    (count-lines-page)
+    (should (equal (count-lines-page) "Page has 2 lines (2 + 0)"))))
+
+(ert-deftest page-tests-what-page ()
+  (with-temp-buffer
+    (insert "foo\n\f\nbar\n\f\nbaz")
+    (goto-char (point-min))
+    (should (equal (what-page) "Page 1, line 1"))
+    (forward-page)
+    (should (equal (what-page) "Page 2, line 2"))
+    (forward-page)
+    (should (equal (what-page) "Page 3, line 4"))))
+
 (provide 'page-tests)
 ;;; page-tests.el ends here
-- 
2.11.0


  reply	other threads:[~2019-06-13 22:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30 18:31 bug#36009: [PATCH] Use lexical-binding in textmodes/page.el and add tests Stefan Kangas
2019-06-02  1:58 ` Paul Eggert
2019-06-02 10:25   ` Simen Heggestøyl
2019-06-13 22:02     ` Stefan Kangas [this message]
2019-06-22 10:55       ` Simen Heggestøyl
2019-06-22 21:32         ` Stefan Kangas
2019-06-22 23:57           ` Paul Eggert
2019-06-23  5:29             ` Simen Heggestøyl

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

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

  git send-email \
    --in-reply-to=CADwFkmm4oVUJ6C1VX9ruz5Fd0LufOUwhHDm40YFsc3Lbc5R0AA@mail.gmail.com \
    --to=stefan@marxist.se \
    --cc=36009@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=simenheg@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.