gbranden pushed a commit to branch master
in repository groff.
commit 5050eecc1060854fa2f291bcac956c212f082a81
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Apr 16 07:47:25 2026 -0500
[groff]: Unit-test Roman register format support.
* src/roff/groff/tests/roman-format-register-interpolation-works.sh: Do
it.
* src/roff/groff/groff.am (groff_TESTS): Run test.
See <https://savannah.gnu.org/bugs/?61999>.
---
ChangeLog | 10 ++
src/roff/groff/groff.am | 1 +
.../roman-format-register-interpolation-works.sh | 106 +++++++++++++++++++++
3 files changed, 117 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 2f131602e..31d355709 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-04-16 G. Branden Robinson <[email protected]>
+
+ [groff]: Unit-test support for Roman numeral register formats.
+
+ * src/roff/groff/tests/\
+ roman-format-register-interpolation-works.sh: Do it.
+ * src/roff/groff/groff.am (groff_TESTS): Run test.
+
+ See <https://savannah.gnu.org/bugs/?61999>.
+
2026-04-15 G. Branden Robinson <[email protected]>
[groff]: Unit-test `sv` and `os` requests.
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index 52e19f9ab..fdd8292eb 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -130,6 +130,7 @@ groff_TESTS = \
src/roff/groff/tests/regression_savannah_58337.sh \
src/roff/groff/tests/regression_savannah_59202.sh \
src/roff/groff/tests/rhw-request-works.sh \
+ src/roff/groff/tests/roman-format-register-interpolation-works.sh \
src/roff/groff/tests/safer-mode-works.sh \
src/roff/groff/tests/set-stroke-thickness.sh \
src/roff/groff/tests/sizes-request-works.sh \
diff --git a/src/roff/groff/tests/roman-format-register-interpolation-works.sh
b/src/roff/groff/tests/roman-format-register-interpolation-works.sh
new file mode 100755
index 000000000..ba77252ff
--- /dev/null
+++ b/src/roff/groff/tests/roman-format-register-interpolation-works.sh
@@ -0,0 +1,106 @@
+#!/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"
+ fail=yes
+}
+
+# Unit-test roman numeral-based register interpolation.
+#
+# There are two cases: normal/GNU style, representing values up to 3,999
+# ("input1"); and AT&T style, using unorthodox 'W' and 'Z' numerals to
+# represent values up to 39,999 ("input2").
+
+input1='.
+.nf
+.nr r 0 +1
+.while \nr<3999 \{\
+.ie \nU .af r I
+.el .af r i
+\n+r
+.af r 0
+.\}
+.'
+
+output1a=$(printf '%s\n' "$input1" | "$groff" -T ascii | nl -ba)
+
+echo "checking that normal lowercase roman numeral register" \
+ "interpolation works" >&2
+echo "$output1a" | grep -Eq "3999[[:space:]]+mmmcmxcix" || wail
+
+output1b=$(printf '%s\n' "$input1" | "$groff" -rU1 -T ascii | nl -ba)
+
+echo "checking that normal uppercase roman numeral register" \
+ "interpolation works" >&2
+echo "$output1b" | grep -Eq "3999[[:space:]]+MMMCMXCIX" || wail
+
+# There is no looping construct in AT&T troff. Its alternative idiom
+# is macro call recursion, but that can be a problem when it demands
+# ~40k nested stack frames ("interpolation depths" in groff parlance),
+# never mind whatever that does to the stack in the C/C++ runtime.
+#
+# So we just lazily (and speedily) check a few values of interest.
+input2='.
+.ec @
+.de PR
+.nr r @@$1
+.af r 0
+@@nr
+.ie @nU .af r I
+.el .af r i
+@@nr
+.br
+..
+.PR 4000
+.PR 9000
+.PR 39999
+.'
+
+output2a=$(printf '%s\n' "$input2" | "$groff" -C -T ascii)
+output2a=$(echo $output2a) # condense onto one line
+
+echo "checking that AT&T-style lowercase roman numeral register" \
+ "interpolation works" >&2
+echo "$output2a" | grep -qx "4000 mw 9000 mz 39999 zzzmzcmxcix" || wail
+
+output2b=$(printf '%s\n' "$input2" | "$groff" -C -rU1 -T ascii)
+output2b=$(echo $output2b) # condense onto one line
+
+echo "checking that AT&T-style uppercase roman numeral register" \
+ "interpolation works" >&2
+echo "$output2b" | grep -qx "4000 MW 9000 MZ 39999 ZZZMZCMXCIX" || wail
+
+echo "checking that lowercase roman numeral register interpolation" \
+ "format works with nonpositive values" >&2
+printf '.nr r0\n.nr r1 -1\n\n.af r0 i\n.af r1 i\n\\nr0 \\nr1\n' \
+ | "$groff" -T ascii | grep -qx -- '0 -i'
+
+echo "checking that uppercase roman numeral register interpolation" \
+ "format works with nonpositive values" >&2
+printf '.nr r0\n.nr r1 -1\n\n.af r0 I\n.af r1 I\n\\nr0 \\nr1\n' \
+ | "$groff" -T ascii | grep -qx -- '0 -I'
+
+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