gbranden pushed a commit to branch master
in repository groff.
commit 5a49e529fb2494bfab0cde5da044cb00383b4a4b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon May 11 03:41:10 2026 -0500
tmac/an.tmac: Add LS/LE coverage test scaffolding.
I plan to rip this out once the feature is complete.
---
ChangeLog | 7 +++
tmac/an.tmac | 41 +++++++++++--
tmac/tests/an_LS-and-LE-work.sh | 131 ++++++++++++++++++++++++++++++++++++++++
tmac/tmac.am | 1 +
4 files changed, 174 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0a1994d47..4ac9ae7e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-05-11 G. Branden Robinson <[email protected]>
+
+ [man]: Unit-test new `LS` and `LE` macros.
+
+ * tmac/tests/an_LS-and-LE-work.sh: Do it.
+ * tmac/tmac.am (tmac_TESTS): Run test.
+
2026-05-11 G. Branden Robinson <[email protected]>
[man]: Begin implementing new `LS` and `LE` macros.
diff --git a/tmac/an.tmac b/tmac/an.tmac
index ebe6901d5..e2f595195 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -103,6 +103,7 @@
.de1 an*end-document
. an*input-trap
. if '\\n[.z]'an*paragraph-tag' .an*TP-trap
+. if \\n[DEBUG] .tm GBR: mark VALID01: \\$0
. an*list-close-all
. if \\n[cR] \{\
. sp 1v
@@ -769,10 +770,16 @@ contains unsupported escape sequence
.\" The presence of an argument means "check for a compact list".
.de an*break-paragraph
. an*reset-paragraph-parameters
+. if \\n[DEBUG] .tm GBR: mark VALID02: \\$0
. nr an*want-space 1
-. if ((\\n[.$] > 0) & (\\n[an*list-depth] > 0)) \
+. if ((\\n[.$] > 0) & (\\n[an*list-depth] > 0)) \{\
. if \\n[an*list-is-compact!\\n[an*list-depth]] .nr an*want-space 0
-. if \\n[an*want-space] .sp \\n[PD]u
+. if \\n[DEBUG] .tm GBR: mark VALID03: \\$0 branch 1
+. \}
+. if \\n[an*want-space] \{\
+. if \\n[DEBUG] .tm GBR: mark VALID04: \\$0 branch 2
+. sp \\n[PD]u
+. \}
. ns
. rr an*want-space
..
@@ -781,6 +788,7 @@ contains unsupported escape sequence
.\" if none) as a section heading.
.de1 SH
. if \\n[.it] .an-warn cannot call .\\$0 while an input trap is pending
+. if \\n[DEBUG] .tm GBR: mark VALID05: \\$0
. an*list-close-all
. an*reset-section-parameters
. an*break-paragraph
@@ -811,6 +819,7 @@ contains unsupported escape sequence
.\" if none) as a subsection heading.
.de1 SS
. if \\n[.it] .an-warn cannot call .\\$0 while an input trap is pending
+. if \\n[DEBUG] .tm GBR: mark VALID06: \\$0
. an*list-close-all
. an*reset-section-parameters
. an*break-paragraph
@@ -900,6 +909,7 @@ contains unsupported escape sequence
.\" .TP [indent]
.de1 TP
. if \\n[.it] .an-warn cannot call .\\$0 while an input trap is pending
+. if \\n[DEBUG] .tm GBR: mark VALID07: \\$0
. an*break-paragraph 1
. if \\n[.$] .nr an*prevailing-indent (n;\\$1)
.\"el \{\
@@ -925,6 +935,7 @@ contains unsupported escape sequence
.de1 IP
. nr an*enforce-tag-separation 0
. ie !\\n[.$] \{\
+. if \\n[DEBUG] .tm GBR: mark VALID08: \\$0
. an*break-paragraph 1
. ne (1v + 1u)
. in (\\n[an*margin]u + \\n[an*prevailing-indent]u)
@@ -1451,6 +1462,7 @@ contains unsupported escape sequence
.\" Start (or "open") a list.
.\" .LS {definition|enumerated|itemized} [compactness] [indent]
.de1 LS
+. if \\n[DEBUG] .tm GBR: mark VALID09: \\$0
. if ((\\n[.$] < 1) : (\\n[.$] > 3)) \
. an*style-warn .\\$0 expects 1 to 3 arguments, got \\n[.$]
. ds an*list-type invalid\"
@@ -1458,6 +1470,7 @@ contains unsupported escape sequence
. if '\?\\$1\?'\?enumerated\?' .ds an*list-type \\$1\"
. if '\?\\$1\?'\?itemized\?' .ds an*list-type \\$1\"
. if '\?\\*[an*list-type]\?'\?invalid\?' \{\
+. if \\n[DEBUG] .tm GBR: mark INVALID01: \\$0 branch 1
. ds an*msg invalid .\\$0 list type '\\*[an*list-type]':
. as an*msg " assuming 'definition'
. an-warn \\*[an*msg]
@@ -1465,15 +1478,27 @@ contains unsupported escape sequence
. \}
. nr an*list-is-compact 0
. if (\\n[.$] > 1) \{\
-. ie !\B'\\$2' \
+. if \\n[DEBUG] .tm GBR: mark VALID10: \\$0 branch 2 (more than one macro
argument)
+. ie !\B'\\$2' \{\
+. if \\n[DEBUG] .tm GBR: mark INVALID02: \\$0 branch 3
. an-warn invalid .\\$0 compactness Boolean value '\\$2'; using 0
-. el .if \\$2 .nr an*list-is-compact 1
+. \}
+. el .if \\$2 \{\
+. if \\n[DEBUG] .tm GBR: mark VALID11: \\$0 branch 4 (list is compact)
+. nr an*list-is-compact 1
+. \}
. \}
. ds an*list-indent \" empty
. if (\\n[.$] > 2) \{\
-. ie !\B'\\$3' \
+. if \\n[DEBUG] .tm GBR: mark VALID12: \\$0 branch 4 (more than two macro
arguments)
+. ie !\B'\\$3' \{\
+. if \\n[DEBUG] .tm GBR: mark INVALID03: \\$0 branch 5
. an-warn invalid .\\$0 indent '\\$3'; ignoring
-. el .ds an*list-indent \\$3\"
+. \}
+. el \{\
+. if \\n[DEBUG] .tm GBR: mark VALID13: \\$0 branch 6 (assigning list
indentation)
+. ds an*list-indent \\$3\"
+. \}
. \}
. nr an*list-depth +1
. ds an*list-type!\\n[an*list-depth] \\*[an*list-type]\"
@@ -1487,6 +1512,7 @@ contains unsupported escape sequence
.
.\" End (or "close") the most recently unclosed list.
.de1 LE
+. if \\n[DEBUG] .tm GBR: mark VALID14: \\$0
. rm an*list-indent!\\n[an*list-depth]
. rr an*list-is-compact!\\n[an*list-depth]
. rm an*list-type!\\n[an*list-depth]
@@ -1715,6 +1741,9 @@ contains unsupported escape sequence
. nr D 0
. \}
.
+.if !r DEBUG \
+. nr DEBUG 0
+.
.\" footer distance
.\"
.\" Unlike most of these parameters, we do not set a default for FT; the
diff --git a/tmac/tests/an_LS-and-LE-work.sh b/tmac/tests/an_LS-and-LE-work.sh
new file mode 100755
index 000000000..7c43083b1
--- /dev/null
+++ b/tmac/tests/an_LS-and-LE-work.sh
@@ -0,0 +1,131 @@
+#!/bin/sh
+#
+# Copyright 2026 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
+}
+
+input='.
+.TH foo 1 2026-05-10 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH Description
+.LS itemized 1 4n
+.IP \(bu
+alpha
+.IP \(bu
+beta
+.IP \(bu
+gamma
+.RS 10n
+.LS definition 0 12n
+.TP
+.B charlie
+Sed ut perspiciatis.
+.TP
+.B delta
+Unde omnis iste natus error sit voluptatem.
+.IP
+Totam rem aperiam eaque ipsa,
+quae ab illo inventore veritatis
+et quasi architecto beatae vitae dicta sunt.
+.TP
+.B echo
+Accusantium doloremque laudantium.
+.LE
+.RE
+.P
+.IP \(bu
+delta
+.LE
+.SS "Assembly language"
+Several computer architectures satisfy Turing-completeness
+with a single instruction.
+.P
+.LS itemized 1
+.IP 1.
+the PDP-8:
+.B ISZ
+.IP 2.
+the PDP-11:
+.B SOB
+.IP 3.
+the Z80:
+.B DJNZ
+.IP 4.
+the 8086:
+.B LOOPZ
+.'
+
+output=$(printf "%s\n" "$input" \
+ | "$groff" -r LL=65n -m an -T ascii -P -cbou | nl -ba)
+echo "$output"
+
+# Expected output:
+# 1 foo(1) General Commands Manual foo(1)
+# 2
+# 3 Name
+# 4 foo - frobnicate a bar
+# 5
+# 6 Description
+# 7 * alpha
+# 8 * beta
+# 9 * gamma
+# 10
+# 11 charlie
+# 12 Sed ut perspiciatis.
+# 13
+# 14 delta Unde omnis iste natus error sit voluptatem.
+# 15
+# 16 Totam rem aperiam eaque ipsa, quae ab illo
+# 17 inventore veritatis et quasi architecto
+# 18 beatae vitae dicta sunt.
+# 19
+# 20 echo Accusantium doloremque laudantium.
+# 21
+# 22 * delta
+# 23
+# 24 Assembly language
+# 25 Several computer architectures satisfy Turing-completeness
+# 26 with a single instruction.
+# 27
+# 28 1. the PDP-8: ISZ
+# 29 2. the PDP-11: SOB
+# 30 3. the Z80: DJNZ
+# 31 4. the 8086: LOOPZ
+# 32
+# 33 groff test suite 2026-05-10 foo(1)
+
+echo "checking that list compactness is applied" >&2
+echo "$output" | grep -Eqx '[[:space:]]+8[[:space:]]+\* +beta' || wail
+echo "checking that nested list indentation accumulates" >&2
+echo "$output" | grep -Eqx '[[:space:]]+11[[:space:]]{16}charlie' \
+ || wail
+echo "checking that compactness not applied to continuation pararaphs" \
+ >&2
+echo "$output" | grep -Eq '[[:space:]]+16[[:space:]]+Totam' || wail
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
diff --git a/tmac/tmac.am b/tmac/tmac.am
index 6a5f5da8b..5a32a4499 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -146,6 +146,7 @@ tmac_TESTS = \
tmac/tests/an_FT-register-value-should-not-trash-titles.sh \
tmac/tests/an_HY-register-works.sh \
tmac/tests/an_LL-register-initializes-sanely.sh \
+ tmac/tests/an_LS-and-LE-work.sh \
tmac/tests/an_ME-second-argument-hyphenates.sh \
tmac/tests/an_MR-internal-hyperlinks-work-with-pdfmom.sh \
tmac/tests/an_MR-works.sh \
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit