gbranden pushed a commit to branch master
in repository groff.

commit 87ec07c322eaa767aee61123b23c1c0eaab384b8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jan 1 06:15:36 2026 -0600

    [mm]: Add tests.
    
    ...of footnote area layout and vertical margins.
    
    * contrib/mm/tests/footnote-area-layout-is-correct.sh:
    * contrib/mm/tests/vertical-margins-are-correct.sh: Do it.
    
    * contrib/mm/mm.am (mm_TESTS): Run tests.
---
 contrib/mm/ChangeLog                               |   8 +
 contrib/mm/mm.am                                   |   4 +-
 .../mm/tests/footnote-area-layout-is-correct.sh    | 137 +++++++++++++
 contrib/mm/tests/vertical-margins-are-correct.sh   | 225 +++++++++++++++++++++
 4 files changed, 373 insertions(+), 1 deletion(-)

diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index 90a7a1932..ea2bcc5be 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,11 @@
+2026-01-01  G. Branden Robinson <[email protected]>
+
+       Add tests of footnote area layout and vertical margins.
+
+       * tests/footnote-area-layout-is-correct.sh:
+       * tests/vertical-margins-are-correct.sh: Do it.
+       * mm.am (mm_TESTS): Run tests.
+
 2026-01-01  G. Branden Robinson <[email protected]>
 
        Revise page layout computations.
diff --git a/contrib/mm/mm.am b/contrib/mm/mm.am
index 08dc2b28c..222cb224e 100644
--- a/contrib/mm/mm.am
+++ b/contrib/mm/mm.am
@@ -80,6 +80,7 @@ mm_TESTS = \
   contrib/mm/tests/PH-PF-OH-OF-EH-EF-work.sh \
   contrib/mm/tests/VL-accommodates-overlong-mark.sh \
   contrib/mm/tests/date-localization-works.sh \
+  contrib/mm/tests/footnote-area-layout-is-correct.sh \
   contrib/mm/tests/flush-long-displays-at-end-of-input.sh \
   contrib/mm/tests/indexing-works.sh \
   contrib/mm/tests/letter-with-bottom-block-works.sh \
@@ -91,7 +92,8 @@ mm_TESTS = \
   contrib/mm/tests/nP-works.sh \
   contrib/mm/tests/place-equation-labels-correctly-in-displays.sh \
   contrib/mm/tests/remove-stale-bib-entry-data.sh \
-  contrib/mm/tests/short-pages-do-not-overflow-stack.sh
+  contrib/mm/tests/short-pages-do-not-overflow-stack.sh \
+  contrib/mm/tests/vertical-margins-are-correct.sh
 TESTS += $(mm_TESTS)
 EXTRA_DIST += \
   $(mm_TESTS) \
diff --git a/contrib/mm/tests/footnote-area-layout-is-correct.sh 
b/contrib/mm/tests/footnote-area-layout-is-correct.sh
new file mode 100755
index 000000000..9c6ebe668
--- /dev/null
+++ b/contrib/mm/tests/footnote-area-layout-is-correct.sh
@@ -0,0 +1,137 @@
+#!/bin/sh
+#
+# Copyright 2025 G. Branden Robinson
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+    echo "...FAILED" >&2
+    fail=YES
+}
+
+# Test placement of footnote area and recovery of page bottom margin.
+
+input='.
+.PH @Alpha@Bravo@Charlie@
+.PF @Delta@Echo@Foxtrot@
+.OH @Golf@Hotel@Indigo@
+.OF @Juliett@Kilo@Lima@
+.EH @Mike@November@Oscar@
+.EF @Papa@Romeo@Quebec@
+.de pp
+.P
+Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
+accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab
+illo inventore veritatis et quasi architecto beatae vitae dicta sunt,
+explicabo.  Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur
+aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione
+voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum,
+quia dolor sit amet consectetur adipiscivelit, sed quia non-numquam eius
+modi tempora incidunt, ut labore et dolore magnam aliquam quaerat
+voluptatem.  Ut enim ad minima veniam, quis nostrum exercitationem ullam
+corporis suscipitlaboriosam, nisi ut aliquid ex ea commodi consequatur?
+Quis autem vel eum iure reprehenderit, qui inea voluptate velit esse,
+quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo
+voluptas nulla pariatur?  At vero eos et accusamus et iusto odio
+dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti
+atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati
+cupiditate non-provident, similique sunt in culpa, qui officia deserunt
+mollitia animi, id est laborum et dolorum fuga.  Et harum quidem rerum
+facilis est et expedita distinctio.  Nam libero tempore, cum soluta
+nobis est eligendi optio, cumque nihil impedit, quo minus id, quod
+maxime placeat, facere possimus, omnis voluptas assumenda est, omnis
+dolor repellendus.  Temporibus autem quibusdam et aut officiis debitis
+aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae
+sint et molestiae non-recusandae.
+..
+.pp
+.pp
+Footnote mark here.\*F
+.FS
+Ne forte ex homine et veterino semine equorum
+confieri credas Centauros posse neque esse,
+aut rabidis canibus succinctas semimarinis
+corporibus Scyllas et cetera de genere horum.
+.FE
+.\" Repeat the paragraph enough times that we can see if the bottom of
+.\" the text area on a subsequent page returns to where it should be
+.\" when footnotes are eabsent.
+.pp
+.pp
+.pp
+.pp
+.'
+
+# GNU coreutils's `nl` command adds trailing tabs to empty lines.
+output=$(printf '%s\n' "$input" | "$groff" -m m -T ascii -P -cbou \
+    | nl -ba | sed 's/[         ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking that body text ends at correct line" \
+    "when footnote absent (page 1)" >&2
+echo "$output" | grep -q ' *59[         ]*tempore,  *cum  *soluta' || wail
+
+echo "checking that secondary footer is on correct line" \
+    "when footnote absent (page 1)" >&2
+echo "$output" | grep -q ' *62[         ]*Juliett' || wail
+
+echo "checking that primary footer is on correct line" \
+    "when footnote absent (page 1)" >&2
+echo "$output" | grep -q ' *63[         ]*Delta' || wail
+
+echo "checking that body text ends at correct line" \
+    "when footnote present (page 2)" >&2
+echo "$output" | grep -q ' *118[        ]*incidunt,  *ut  *labore' || wail
+
+echo "checking that footnote area separator is on correct line" \
+    "when footnote present (page 2)" >&2
+echo "$output" | grep -q ' *120[        ]*---' || wail
+
+echo "checking that footnote starts on correct line" \
+    "(page 2)" >&2
+echo "$output" | grep -q ' *122[        ]*1\. Ne  *forte  *ex' || wail
+
+echo "checking that footnote ends on correct line" \
+    "(page 2)" >&2
+echo "$output" | grep -q ' *125[        ]*genere  *horum\.' || wail
+
+echo "checking that secondary footer is on correct line" \
+    "when footnote present (page 2)" >&2
+echo "$output" | grep -q ' *128[        ]*Papa' || wail
+
+echo "checking that primary footer is on correct line" \
+    "when footnote present (page 2)" >&2
+echo "$output" | grep -q ' *129[        ]*Delta' || wail
+
+echo "checking that body text ends at correct line" \
+    "when footnote absent (page 3)" >&2
+echo "$output" | grep -q ' *191[        ]*quasi  *architecto' || wail
+
+echo "checking that secondary footer is on correct line" \
+    "when footnote absent (page 3)" >&2
+echo "$output" | grep -q ' *194[        ]*Juliett' || wail
+
+echo "checking that primary footer is on correct line" \
+    "when footnote absent (page 3)" >&2
+echo "$output" | grep -q ' *195[        ]*Delta' || wail
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
diff --git a/contrib/mm/tests/vertical-margins-are-correct.sh 
b/contrib/mm/tests/vertical-margins-are-correct.sh
new file mode 100755
index 000000000..88d16d749
--- /dev/null
+++ b/contrib/mm/tests/vertical-margins-are-correct.sh
@@ -0,0 +1,225 @@
+#!/bin/sh
+#
+# Copyright 2025 G. Branden Robinson
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+    echo "...FAILED" >&2
+    fail=YES
+}
+
+# Unit-test the vertical page margins (before and after titles).
+
+input='.
+.PH @@@@ \" empty
+.PF @@@@ \" empty
+.if \nZ .PH @Alpha@Bravo@Charlie@
+.if \nZ .PF @Delta@Echo@Foxtrot@
+.if \nZ=2 \{\
+.  OH @Golf@Hotel@Indigo@
+.  OF @Juliett@Kilo@Lima@
+.  EH @Mike@November@Oscar@
+.  EF @Papa@Romeo@Quebec@
+.\}
+.de pp
+.P
+Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
+accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab
+illo inventore veritatis et quasi architecto beatae vitae dicta sunt,
+explicabo.  Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur
+aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione
+voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum,
+quia dolor sit amet consectetur adipiscivelit, sed quia non-numquam eius
+modi tempora incidunt, ut labore et dolore magnam aliquam quaerat
+voluptatem.  Ut enim ad minima veniam, quis nostrum exercitationem ullam
+corporis suscipitlaboriosam, nisi ut aliquid ex ea commodi consequatur?
+Quis autem vel eum iure reprehenderit, qui inea voluptate velit esse,
+quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo
+voluptas nulla pariatur?  At vero eos et accusamus et iusto odio
+dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti
+atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati
+cupiditate non-provident, similique sunt in culpa, qui officia deserunt
+mollitia animi, id est laborum et dolorum fuga.  Et harum quidem rerum
+facilis est et expedita distinctio.  Nam libero tempore, cum soluta
+nobis est eligendi optio, cumque nihil impedit, quo minus id, quod
+maxime placeat, facere possimus, omnis voluptas assumenda est, omnis
+dolor repellendus.  Temporibus autem quibusdam et aut officiis debitis
+aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae
+sint et molestiae non-recusandae.
+..
+.pp
+.if \nF \{\
+See below.\*F
+.  FS
+.  if \nF=1 This is a short footnote.
+.  if \nF=2 \{\
+This is a longer footnote.
+Ne forte ex homine et veterino semine equorum
+confieri credas Centauros posse neque esse,
+aut rabidis canibus succinctas semimarinis
+corporibus Scyllas et cetera de genere horum.
+.  \}
+.  FE
+.\}
+.pp
+.'
+
+# Check that body text stops and starts in the correct places even
+# without titles.
+
+echo "test case 1: -rF0 -rZ0" #>&2
+# GNU coreutils's `nl` command adds trailing tabs to empty lines.
+output=$(printf '%s\n' "$input" | "$groff" -m m -T ascii -P -cbou \
+    | nl -ba | sed 's/[         ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *8[         ]*Sed  *ut  *perspiciatis' || wail
+
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *59[        ]*tempore,  *cum  *soluta' || wail
+
+# Now check _with_ (primary) titles...
+
+echo "test case 2: -rF0 -rZ1" #>&2
+output=$(printf '%s\n' "$input" | "$groff" -rZ1 -m m -T ascii -P -cbou \
+    | nl -ba | sed 's/[         ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking for header on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *4[         ]*Alpha' || wail
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *8[         ]*Sed  *ut  *perspiciatis' || wail
+
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *59[        ]*tempore,  *cum  *soluta' || wail
+
+echo "checking for footer on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *63[        ]*Delta' || wail
+
+# ...with (primary) titles and a short footnote...
+
+echo "test case 3: -rF1 -rZ1" #>&2
+output=$(printf '%s\n' "$input" | "$groff" -rZ1 -rF1 -m m -T ascii \
+    -P -cbou | nl -ba | sed 's/[        ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking for header on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *4[         ]*Alpha' || wail
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *8[         ]*Sed  *ut  *perspiciatis' || wail
+
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *55[        ]*molestias  *excepturi' || wail
+
+echo "checking for footnote separator rule on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *57[        ]*---' || wail
+
+echo "checking for footnote text on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *59[        ]*.*This is a short footnote\.' \
+    || wail
+
+echo "checking for footer on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *63[        ]*Delta' || wail
+
+# ...with primary titles and a longer footnote...
+
+echo "test case 4: -rF2 -rZ1" #>&2
+output=$(printf '%s\n' "$input" | "$groff" -rZ1 -rF2 -m m -T ascii \
+    -P -cbou | nl -ba | sed 's/[        ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking for header on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *4[         ]*Alpha' || wail
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *8[         ]*Sed  *ut  *perspiciatis' || wail
+
+# The long footnote causes the footnote area to retreat up the page,
+# spilling body text that formerly fit on one page to a second.
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *52[        ]*quo  *voluptas  *nulla' || wail
+
+echo "checking for footnote separator rule on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *54[        ]*---' || wail
+
+echo "checking for footnote text on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *56[        ]*.*longer  *footnote' || wail
+
+echo "checking for footer on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *63[        ]*Delta' || wail
+
+# ...and with primary _and_ secondary titles and a longer footnote.
+
+echo "test case 5: -rF2 -rZ2" #>&2
+output=$(printf '%s\n' "$input" | "$groff" -rZ2 -rF2 -m m -T ascii \
+    -P -cbou | nl -ba | sed 's/[        ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking for header on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *4[         ]*Alpha' || wail
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *8[         ]*Sed  *ut  *perspiciatis' || wail
+
+# The long footnote causes the footnote area to retreat up the page,
+# spilling body text that formerly fit on one page to a second.
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *52[        ]*quo  *voluptas  *nulla' || wail
+
+echo "checking for footnote separator rule on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *54[        ]*---' || wail
+
+echo "checking for footnote text on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *56[        ]*.*longer  *footnote' || wail
+
+echo "checking for footer on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *63[        ]*Delta' || wail
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to