summaryrefslogtreecommitdiffstats
path: root/tmac/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:44:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:44:05 +0000
commitd318611dd6f23fcfedd50e9b9e24620b102ba96a (patch)
tree8b9eef82ca40fdd5a8deeabf07572074c236095d /tmac/tests
parentInitial commit. (diff)
downloadgroff-d318611dd6f23fcfedd50e9b9e24620b102ba96a.tar.xz
groff-d318611dd6f23fcfedd50e9b9e24620b102ba96a.zip
Adding upstream version 1.23.0.upstream/1.23.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tmac/tests')
-rwxr-xr-xtmac/tests/an-ext_MR-works.sh61
-rwxr-xr-xtmac/tests/an-ext_MT-works.sh55
-rwxr-xr-xtmac/tests/an-ext_UR-works.sh56
-rwxr-xr-xtmac/tests/an_AT-and-UC-footer-saved-and-restored.sh106
-rwxr-xr-xtmac/tests/an_CS-register-off.sh27
-rwxr-xr-xtmac/tests/an_CS-register-on.sh27
-rwxr-xr-xtmac/tests/an_CS-register-unspecified.sh27
-rwxr-xr-xtmac/tests/an_CT-register-off.sh27
-rwxr-xr-xtmac/tests/an_CT-register-on.sh27
-rwxr-xr-xtmac/tests/an_CT-register-unspecified.sh27
-rwxr-xr-xtmac/tests/an_FT-bad-value-should-not-trash-titles.sh93
-rwxr-xr-xtmac/tests/an_HY-register-works.sh78
-rwxr-xr-xtmac/tests/an_LL-init-sanely.sh48
-rwxr-xr-xtmac/tests/an_ME-punct-hyphenates.sh55
-rwxr-xr-xtmac/tests/an_MR-works.sh75
-rwxr-xr-xtmac/tests/an_MT-body-hyphenates.sh37
-rwxr-xr-xtmac/tests/an_MT-works.sh86
-rwxr-xr-xtmac/tests/an_P-register-works.sh51
-rwxr-xr-xtmac/tests/an_TH-repairs-ad-damage.sh41
-rwxr-xr-xtmac/tests/an_TH-repairs-hy-damage.sh41
-rwxr-xr-xtmac/tests/an_TS-adds-no-vertical-space.sh47
-rwxr-xr-xtmac/tests/an_TS-do-not-keep-tables-when-cR-set.sh51
-rwxr-xr-xtmac/tests/an_UE-breaks-before-long-URIs.sh68
-rwxr-xr-xtmac/tests/an_UE-punct-hyphenates.sh53
-rwxr-xr-xtmac/tests/an_UR-body-hyphenates.sh37
-rwxr-xr-xtmac/tests/an_UR-works.sh86
-rwxr-xr-xtmac/tests/an_X-register-works.sh62
-rwxr-xr-xtmac/tests/an_adjust-link-text-correctly.sh40
-rwxr-xr-xtmac/tests/an_avoid-two-font-denial-of-service.sh36
-rwxr-xr-xtmac/tests/an_do-not-abbreviate-escape-using-TH-arguments.sh51
-rwxr-xr-xtmac/tests/an_font-remapping-does-not-affect-titles.sh60
-rwxr-xr-xtmac/tests/an_handle-degenerate-input-quietly.sh29
-rwxr-xr-xtmac/tests/an_inner-footer-abbreviation-works.sh70
-rwxr-xr-xtmac/tests/an_link-macros-work-in-paragraph-tags.sh88
-rwxr-xr-xtmac/tests/an_link-trailing-text-hugs-previous.sh52
-rwxr-xr-xtmac/tests/an_no-break-after-short-paragraph-tags.sh43
-rwxr-xr-xtmac/tests/an_output-footer-when-continuously-rendering.sh41
-rwxr-xr-xtmac/tests/an_page-footers-present.sh68
-rwxr-xr-xtmac/tests/an_page-header-has-current-data.sh70
-rwxr-xr-xtmac/tests/an_reset-hyphenation-correctly.sh63
-rwxr-xr-xtmac/tests/an_title-abbreviation-works.sh61
-rwxr-xr-xtmac/tests/an_use-input-traps-correctly.sh113
-rwxr-xr-xtmac/tests/an_works-with-ec.sh40
-rwxr-xr-xtmac/tests/andoc_P-register-works.sh117
-rwxr-xr-xtmac/tests/andoc_check-an-to-doc-transition.sh68
-rwxr-xr-xtmac/tests/andoc_clear-doc-traps.sh47
-rwxr-xr-xtmac/tests/andoc_flush-between-packages.sh77
-rwxr-xr-xtmac/tests/doc_CS-works.sh42
-rwxr-xr-xtmac/tests/doc_CT-works.sh42
-rwxr-xr-xtmac/tests/doc_D-places-page-numbers-correctly.sh45
-rwxr-xr-xtmac/tests/doc_Lk-respect-sentence-ending-punctuation.sh40
-rwxr-xr-xtmac/tests/doc_Mt-works.sh48
-rwxr-xr-xtmac/tests/doc_Nm-works.sh74
-rwxr-xr-xtmac/tests/doc_P-register-works.sh54
-rwxr-xr-xtmac/tests/doc_X-register-works.sh70
-rwxr-xr-xtmac/tests/doc_accept-mixed-case-section-headings.sh76
-rwxr-xr-xtmac/tests/doc_do-not-loop-infinitely-when-shortening-headers.sh37
-rwxr-xr-xtmac/tests/doc_heading-font-remapping-works.sh58
-rwxr-xr-xtmac/tests/doc_indents-correctly.sh89
-rwxr-xr-xtmac/tests/doc_output-footer-when-continuously-rendering.sh43
-rwxr-xr-xtmac/tests/doc_smoke-test.sh66
-rwxr-xr-xtmac/tests/e_chapter-titles-work.sh68
-rwxr-xr-xtmac/tests/e_columns-work-on-long-pages.sh38
-rwxr-xr-xtmac/tests/e_delayed-text-marks-work.sh55
-rwxr-xr-xtmac/tests/e_footnote-marks-work.sh74
-rwxr-xr-xtmac/tests/e_footnotes-work-with-columns.sh43
-rwxr-xr-xtmac/tests/e_ld-works.sh131
-rwxr-xr-xtmac/tests/e_line-numbering-works.sh141
-rwxr-xr-xtmac/tests/e_rejects-too-short-page-lengths.sh61
-rwxr-xr-xtmac/tests/ec_works.sh45
-rwxr-xr-xtmac/tests/latin2_works.sh76
-rwxr-xr-xtmac/tests/latin5_works.sh30
-rwxr-xr-xtmac/tests/latin9_works.sh30
-rwxr-xr-xtmac/tests/localization-works.sh189
-rwxr-xr-xtmac/tests/pdfpic_does-not-choke-on-bad-pdfinfo-output.sh83
-rwxr-xr-xtmac/tests/pdfpic_falls-back-to-PSPIC.sh77
-rwxr-xr-xtmac/tests/s_IP-indents-using-paragraph-type-size.sh50
-rwxr-xr-xtmac/tests/s_IP-respects-inter-sentence-space-in-tags.sh40
-rwxr-xr-xtmac/tests/s_PN-works.sh37
-rwxr-xr-xtmac/tests/s_R-handles-its-arguments.sh41
-rwxr-xr-xtmac/tests/s_SH-resets-IP-indentation-amount.sh40
-rwxr-xr-xtmac/tests/s_TC-works-with-percent-in-custom-titles.sh52
-rwxr-xr-xtmac/tests/s_XA-literal-no-argument-suppresses-leader.sh59
-rwxr-xr-xtmac/tests/s_honor-MINGW-when-two-columns.sh37
-rwxr-xr-xtmac/tests/s_mark-column-start-correctly.sh38
-rwxr-xr-xtmac/tests/s_no-excess-space-around-displays.sh39
-rwxr-xr-xtmac/tests/s_rejects-too-short-page-lengths.sh61
87 files changed, 5102 insertions, 0 deletions
diff --git a/tmac/tests/an-ext_MR-works.sh b/tmac/tests/an-ext_MR-works.sh
new file mode 100755
index 0000000..c922ba2
--- /dev/null
+++ b/tmac/tests/an-ext_MR-works.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Keep preconv from being run.
+unset GROFF_ENCODING
+
+fail=
+
+wail () {
+ echo ...FAILED >&2
+ fail=YES
+}
+
+input='.TH foo 1 2021-10-06 "groff test suite"
+.SH Name
+.ec @
+foo @- a command with a very short name
+.ec
+.SH Description
+The real work is done by
+.MR bar 1 .'
+
+output=$(echo "$input" | "$groff" -rmG=0 -Tascii -man -Z | nl)
+echo "$output"
+
+# Expected:
+# 88 wf2
+# 89 h24
+# 90 tbar
+# 91 f1
+# 92 t(1).
+
+echo "checking for correct man page topic font style" >&2
+echo "$output" | grep -Eq '88[[:space:]]+wf2' || wail
+echo "$output" | grep -Eq '90[[:space:]]+tbar' || wail
+echo "checking for correct man page section font style" >&2
+echo "$output" | grep -Eq '91[[:space:]]+f1' || wail
+echo "$output" | grep -Eq '92[[:space:]]+t\(1\)' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an-ext_MT-works.sh b/tmac/tests/an-ext_MT-works.sh
new file mode 100755
index 0000000..1bb7699
--- /dev/null
+++ b/tmac/tests/an-ext_MT-works.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 2022-11-22 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH Description
+Mail
+.MT modok@\:example\:.com
+the boss
+.ME .
+.
+Complaints to
+.MT nobody@\:example\:.com
+.ME .'
+
+output=$(printf "%s\n" "$input" \
+ | "$groff" -rmG=0 -Tascii -P-cbou -man -rU0)
+echo "$output"
+
+echo "checking formatting of mail URI with link text" >&2
+echo "$output" | grep -Fq 'Mail the boss <modok@example.com>.' || wail
+
+echo "checking formatting of mail URI with no link text" >&2
+echo "$output" | grep -Fq 'Complaints to <nobody@example.com>.' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an-ext_UR-works.sh b/tmac/tests/an-ext_UR-works.sh
new file mode 100755
index 0000000..bf5a1ab
--- /dev/null
+++ b/tmac/tests/an-ext_UR-works.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 2022-11-22 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH Description
+See
+.UR http://\:foo\:.example\:.com
+figure 1
+.UE .
+.
+Or
+.UR http://\:bar\:.example\:.com
+.UE .'
+
+output=$(printf "%s\n" "$input" \
+ | "$groff" -rmG=0 -Tascii -P-cbou -man -rU0)
+echo "$output"
+
+echo "checking formatting of web URI with link text" >&2
+echo "$output" | grep -Fq 'See figure 1 <http://foo.example.com>.' \
+ || wail
+
+echo "checking formatting of web URI with no link text" >&2
+echo "$output" | grep -Fq 'Or <http://bar.example.com>.' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_AT-and-UC-footer-saved-and-restored.sh b/tmac/tests/an_AT-and-UC-footer-saved-and-restored.sh
new file mode 100755
index 0000000..fd3164f
--- /dev/null
+++ b/tmac/tests/an_AT-and-UC-footer-saved-and-restored.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #57416.
+#
+# The (deprecated) macros .AT and .UC, intended only for rendering of
+# legacy man pages, alter strings used in man page footers. Verify that
+# they modify and restore these strings correctly.
+
+EXAMPLE_ATT_PAGE='.TH att 1 2020-01-16 "groff test suite"
+.AT
+.SH Name
+att \- aim Death Star at planet'
+
+EXAMPLE_FSF_PAGE='.TH fsf 1 2020-01-16 "groff test suite"
+.SH Name
+fsf \- liberate laser printer firmware'
+
+EXAMPLE_WFJ_PAGE='.TH wfj 1 2020-01-16 "groff test suite"
+.UC
+.SH Name
+wfj \- call 1-800-ITS-UNIX'
+
+EXAMPLE_GNU_PAGE='.TH gnu 1 2020-01-16 "groff test suite"
+.SH Name
+gnu \- join us now and share the software'
+
+EXAMPLE_UCB_PAGE='.TH ucb 1 2020-01-16 "groff test suite"
+.UC 7
+.SH Name
+ucb \- blow up Death Star'
+
+# We turn off continuous rendering (-rcR=0) so that the page footers are
+# numbered. We turn on continuous page numbering (-rC1) so we can tell
+# that the footers are on the expected pages.
+INPUT=$(printf "%s\n" \
+ "$EXAMPLE_ATT_PAGE" \
+ "$EXAMPLE_FSF_PAGE" \
+ "$EXAMPLE_WFJ_PAGE" \
+ "$EXAMPLE_GNU_PAGE" \
+ "$EXAMPLE_UCB_PAGE" \
+ "$EXAMPLE_GNU_PAGE" \
+)
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man -rcR=0 -rC1)
+
+FAIL=
+
+if ! echo "$OUTPUT" | grep -qE '7th Edition +2020-01-16 +1'
+then
+ FAIL=yes
+ echo "AT&T (.AT) footer test failed" >&2
+fi
+
+if ! echo "$OUTPUT" | grep -qE 'groff test suite +2020-01-16 +2'
+then
+ FAIL=yes
+ echo "FSF test footer failed" >&2
+fi
+
+if ! echo "$OUTPUT" | grep -qE '3rd Berkeley Distribution +2020-01-16 +3'
+then
+ FAIL=yes
+ echo "WFJ (.UC) footer test failed" >&2
+fi
+
+if ! echo "$OUTPUT" | grep -qE 'groff test suite +2020-01-16 +4'
+then
+ FAIL=yes
+ echo "1st GNU footer test failed" >&2
+fi
+
+if ! echo "$OUTPUT" | grep -qE '4.4 Berkeley Distribution +2020-01-16 +5'
+then
+ FAIL=yes
+ echo "UCB (.UC) footer test failed" >&2
+fi
+
+if ! echo "$OUTPUT" | grep -qE 'groff test suite +2020-01-16 +6'
+then
+ FAIL=yes
+ echo "2nd GNU footer test failed" >&2
+fi
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=80:
diff --git a/tmac/tests/an_CS-register-off.sh b/tmac/tests/an_CS-register-off.sh
new file mode 100755
index 0000000..0b615da
--- /dev/null
+++ b/tmac/tests/an_CS-register-off.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (C) 2019-2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+"$groff" -rCS=0 -Tascii -P-cbou -man <<EOF | grep -q Name
+.TH sample 1 2019-09-09 "groff test suite"
+.SH Name
+sample \- test subject for groff
+EOF
diff --git a/tmac/tests/an_CS-register-on.sh b/tmac/tests/an_CS-register-on.sh
new file mode 100755
index 0000000..34628a4
--- /dev/null
+++ b/tmac/tests/an_CS-register-on.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (C) 2019-2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+"$groff" -rCS=1 -Tascii -P-cbou -man <<EOF | grep -q NAME
+.TH sample 1 2019-09-09 "groff test suite"
+.SH Name
+sample \- test subject for groff
+EOF
diff --git a/tmac/tests/an_CS-register-unspecified.sh b/tmac/tests/an_CS-register-unspecified.sh
new file mode 100755
index 0000000..71b27b9
--- /dev/null
+++ b/tmac/tests/an_CS-register-unspecified.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (C) 2019-2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+"$groff" -Tascii -P-cbou -man <<EOF | grep -q Name
+.TH sample 1 2019-09-09 "groff test suite"
+.SH Name
+sample \- test subject for groff
+EOF
diff --git a/tmac/tests/an_CT-register-off.sh b/tmac/tests/an_CT-register-off.sh
new file mode 100755
index 0000000..9920543
--- /dev/null
+++ b/tmac/tests/an_CT-register-off.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (C) 2019-2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+"$groff" -rCT=0 -Tascii -P-cbou -man <<EOF | grep -q 'sample(1)'
+.TH sample 1 2019-09-09 "groff test suite"
+.SH Name
+sample \- test subject for groff
+EOF
diff --git a/tmac/tests/an_CT-register-on.sh b/tmac/tests/an_CT-register-on.sh
new file mode 100755
index 0000000..33861ab
--- /dev/null
+++ b/tmac/tests/an_CT-register-on.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (C) 2019-2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+"$groff" -rCT=1 -Tascii -P-cbou -man <<EOF | grep -q 'SAMPLE(1)'
+.TH sample 1 2019-09-09 "groff test suite"
+.SH Name
+sample \- test subject for groff
+EOF
diff --git a/tmac/tests/an_CT-register-unspecified.sh b/tmac/tests/an_CT-register-unspecified.sh
new file mode 100755
index 0000000..cc94b3f
--- /dev/null
+++ b/tmac/tests/an_CT-register-unspecified.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (C) 2019-2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+"$groff" -Tascii -P-cbou -man <<EOF | grep -q 'sample(1)'
+.TH sample 1 2019-09-09 "groff test suite"
+.SH Name
+sample \- test subject for groff
+EOF
diff --git a/tmac/tests/an_FT-bad-value-should-not-trash-titles.sh b/tmac/tests/an_FT-bad-value-should-not-trash-titles.sh
new file mode 100755
index 0000000..e14109f
--- /dev/null
+++ b/tmac/tests/an_FT-bad-value-should-not-trash-titles.sh
@@ -0,0 +1,93 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #60612.
+#
+# Bad values of FT should not trash headers and footers.
+EXAMPLE_PAGE_1='.TH foo 1 2021-05-17 "groff foo test"
+.SH Name
+foo \- frobnicate bits'
+
+EXAMPLE_PAGE_2='.TH bar 1 2021-05-17 "groff bar test"
+.SH Name
+bar \- what they say north of Macedonia'
+
+# We turn off continuous rendering (-rcR=0) so that FT influences where the page
+# footer is output.
+INPUT=$(printf "%s\n" \
+ "$EXAMPLE_PAGE_1" \
+ "$EXAMPLE_PAGE_2" \
+)
+
+# FT tells our man(7) where to write the page footer.
+#
+# -0.5i is the default and should always work.
+#
+# 0 (in any units) is not sane. It would step on ("hide") the header trap among
+# other problems.
+#
+# 0.5i (positive) is a likely input from a confused user (I've done it).
+#
+# "Reasonable" positive values are conceivable but there may not be any user
+# demand for them. ("Always break for the footer at 3i [or 3c] regardless of
+# the page length"?)
+#
+# Somewhere between -0.51v (bad) and -0.55v (okay) a problem gets caused.
+#
+# Traps that aren't in the page area (-20i, 500c for conventional paper sizes)
+# don't get sprung.
+
+for FT in -0.5i -1i 0i 0.5i -0.51v -0.55v 10i -20i
+do
+ OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man -rcR=0 -rFT=$FT)
+ FAIL=
+
+ if ! echo "$OUTPUT" | grep -qE 'foo\(1\) +General Commands Manual +foo\(1\)'
+ then
+ FAIL=yes
+ echo "first page header test failed (FT=$FT)" >&2
+ fi
+
+ if ! echo "$OUTPUT" | grep -qE 'groff foo test +2021-05-17 +1'
+ then
+ FAIL=yes
+ echo "first page footer test failed (FT=$FT)" >&2
+ fi
+
+ if ! echo "$OUTPUT" | grep -qE 'bar\(1\) +General Commands Manual +bar\(1\)'
+ then
+ FAIL=yes
+ echo "second page header test failed (FT=$FT)" >&2
+ fi
+
+ test -z "$FAIL"
+
+ if ! echo "$OUTPUT" | grep -qE 'groff bar test +2021-05-17 +1'
+ then
+ FAIL=yes
+ echo "second page footer test failed (FT=$FT)" >&2
+ fi
+done
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=80:
diff --git a/tmac/tests/an_HY-register-works.sh b/tmac/tests/an_HY-register-works.sh
new file mode 100755
index 0000000..2e8ddc0
--- /dev/null
+++ b/tmac/tests/an_HY-register-works.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# Copyright (C) 2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 2023-01-08 "groff test suite"
+.SH Name
+foo \- frobinicate a bar
+.SH Synopsis
+.SY foo
+.YS
+.SH Description
+Now is the time for all good citizens to disestablish
+antidisestablishmentarianism.'
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Tascii -P-cbou)
+echo "$output"
+
+echo "checking hyphenation when HY is default" >&2
+echo "$output" | grep -q "antidisestablish-$" || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -rHY=0 -man -Tascii -P-cbou)
+echo "$output"
+
+echo "checking hyphenation when HY is 0" >&2
+echo "$output" | grep -Eq "to +disestablish$" || wail
+
+input='.TH foo 1 2023-01-08 "groff test suite"
+.SH Name
+foo \- frobinicate a bar
+.SH Synopsis
+.SY foo
+.SY foo
+.I arbitrary-argument
+.YS
+.SH Description
+Now is the time for all good citizens to disestablish
+antidisestablishmentarianism.'
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Tascii -P-cbou)
+echo "$output"
+
+echo "checking hyphenation when HY is default and .SY nested" >&2
+echo "$output" | grep -q "antidisestablish-$" || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -rHY=0 -man -Tascii -P-cbou)
+echo "$output"
+
+echo "checking hyphenation when HY is 0 and .SY nested" >&2
+echo "$output" | grep -Eq "to +disestablish$" || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_LL-init-sanely.sh b/tmac/tests/an_LL-init-sanely.sh
new file mode 100755
index 0000000..12b24b1
--- /dev/null
+++ b/tmac/tests/an_LL-init-sanely.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #58992.
+#
+# Our man macros should no longer attempt to read the .l register on
+# nroff devices to set the line length. That register may or may not
+# have been set by a user .ll request; we can't tell whether a value of
+# 65n came from nroff or the user.
+#
+# Instead, the LL register must be used to set the line length.
+#
+# In this test we _expect_ the .ll request to be ignored and overridden.
+# We choose a value that is not nroff's default nor man's default.
+
+EXAMPLE='
+.ll 70n
+.TH ll\-hell 1 2020-08-22 "groff test suite"
+.SH Name
+ll\-hell \- see how long the lines are
+.SH Description
+LL=\n[LL]u
+.PP
+\&.l=\n[.l]u'
+
+printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -man \
+ | grep -q 'LL=1872u'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_ME-punct-hyphenates.sh b/tmac/tests/an_ME-punct-hyphenates.sh
new file mode 100755
index 0000000..1274c46
--- /dev/null
+++ b/tmac/tests/an_ME-punct-hyphenates.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Copyright (C) 2020, 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 me\-punct 1 2020-08-15 "groff test suite"
+.SH Name
+me\-punct \- mailto: trailing material is subject to hyphenation
+.SH Description
+Do not try to
+.MT groff+morestuff@gnu.org
+hyphenate a ridiculous word* without machine assistance
+.ME (*pneumonoultramicroscopicsilicovolcanoconiosis).'
+
+# Turn off break warnings; we expect an adjustment problem.
+# I kind of wish adjustment warnings were a different category from
+# break warnings.
+echo "testing hyphenation of trailing text by an.tmac's ME macro"
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -Wbreak -P-cbou -man)
+echo "$output"
+echo "$output" | grep -qE 'pn.*-'
+
+echo "testing hyphenation of trailing text by an-ext.tmac's ME macro"
+output=$(printf "%s\n" "$input" \
+ | "$groff" -rmG=0 -Tascii -Wbreak -P-cbou -man)
+echo "$output"
+echo "$output" | grep -qE 'pn.*-'
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_MR-works.sh b/tmac/tests/an_MR-works.sh
new file mode 100755
index 0000000..3a84e62
--- /dev/null
+++ b/tmac/tests/an_MR-works.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Keep preconv from being run.
+unset GROFF_ENCODING
+
+INPUT='.TH foo 1 2021-10-06 "groff test suite"
+.SH Name
+foo \\- a command with a very short name
+.SH Description
+The real work is done by
+.MR bar 1 .'
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -rU1 -man -Z | nl)
+echo "$OUTPUT"
+
+# Expected:
+# 91 x X tty: link man:bar(1)
+# 92 f2
+# 93 tbar
+# 94 f1
+# 95 t(1)
+# 96 V280
+# 97 H912
+# 98 x X tty: link
+
+set -e
+echo "checking for opening 'link' device control command" >&2
+echo "$OUTPUT" | grep -Eq '91[[:space:]]+x X tty: link man:bar\(1\)$'
+echo "checking for correct man page title font style" >&2
+echo "$OUTPUT" | grep -Eq '92[[:space:]]+f2'
+echo "$OUTPUT" | grep -Eq '93[[:space:]]+tbar'
+echo "checking for correct man page section font style" >&2
+echo "$OUTPUT" | grep -Eq '94[[:space:]]+f1'
+echo "$OUTPUT" | grep -Eq '95[[:space:]]+t\(1\)'
+echo "checking for closing 'link' device control command" >&2
+echo "$OUTPUT" | grep -Eq '98[[:space:]]+x X tty: link$'
+
+set +e
+
+fail=
+
+wail () {
+ echo ...FAILED >&2
+ fail=yes
+}
+
+output=$(echo "$INPUT" | "$groff" -man -Thtml)
+echo "$output"
+
+echo "checking for correctly formatted man URI in HTML output" >&2
+echo "$output" | grep -Fq '<a href="man:bar(1)"><i>bar</i>(1)</a>.'
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_MT-body-hyphenates.sh b/tmac/tests/an_MT-body-hyphenates.sh
new file mode 100755
index 0000000..3ccbf59
--- /dev/null
+++ b/tmac/tests/an_MT-body-hyphenates.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+EXAMPLE='.TH mt\-body 1 2020-08-15 "groff test suite"
+.SH Name
+mt\-body \- mailto: link text is subject to hyphenation
+.SH Description
+Do not try to
+.MT groff@gnu.org
+hyphenate the word
+pneumonoultramicroscopicsilicovolcanoconiosis
+without machine assistance
+.ME .'
+
+printf "%s\n" "$EXAMPLE" | "$groff" -rmG=0 -Tascii -P-cbou -man \
+ | grep -qE 'pn.*-'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_MT-works.sh b/tmac/tests/an_MT-works.sh
new file mode 100755
index 0000000..d4ebf60
--- /dev/null
+++ b/tmac/tests/an_MT-works.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 2022-11-22 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH Description
+Mail
+.MT modok@\:example\:.com
+the boss
+.ME .
+.
+Complaints to
+.MT nobody@\:example\:.com
+.ME .'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man -rU0)
+echo "$output"
+
+echo "checking formatting of mail URI with link text" \
+ "(hyperlinks disabled)" >&2
+echo "$output" | grep -Fq 'Mail the boss <modok@example.com>.' || wail
+
+echo "checking formatting of mail URI with no link text" \
+ "(hyperlinks disabled)" >&2
+echo "$output" | grep -Fq 'Complaints to <nobody@example.com>.' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man -rU1)
+echo "$output"
+
+echo "checking formatting of mail URI with link text" \
+ "(hyperlinks enabled)" >&2
+echo "$output" | grep -Fq 'Mail the boss.' || wail
+
+echo "checking formatting of mail URI with no link text" \
+ "(hyperlinks enabled)" >&2
+echo "$output" | grep -Fq 'Complaints to nobody@example.com.' || wail
+
+input='.TH foo 1 2022-12-04 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH Authors
+The GNU version of
+.I foo
+was written by
+.MT q@\:example\:.com
+Quiller
+.ME .'
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Thtml)
+echo "$output"
+
+echo "checking HTML output of mail URI" >&2
+echo "$output" \
+ | grep -Fqx '<a href="mailto:q@example.com">Quiller</a>.</p>' \
+ || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_P-register-works.sh b/tmac/tests/an_P-register-works.sh
new file mode 100755
index 0000000..12f5341
--- /dev/null
+++ b/tmac/tests/an_P-register-works.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 2022-12-11 "groff test suite"
+.SH Name
+foo \- frobinicate a bar
+.bp
+.SH Description
+It took a while to get here.'
+
+output=$(printf "%s\n" "$input" | "$groff" -rcR=0 -rP13 -man -Tascii \
+ -P-cbou)
+echo "$output"
+
+echo "checking first page footer" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +13$" \
+ | grep '^64:' || wail
+
+echo "checking second page footer" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +14$" \
+ | grep '^130:' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_TH-repairs-ad-damage.sh b/tmac/tests/an_TH-repairs-ad-damage.sh
new file mode 100755
index 0000000..7b2c849
--- /dev/null
+++ b/tmac/tests/an_TH-repairs-ad-damage.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+EXAMPLE='.TH mal 1 2020-08-21 "groff test suite"
+.SH Name
+mal \- malevolent man page
+.SH Description
+.ad l
+Wicked page changes adjustment.
+Wicked page changes adjustment.
+Wicked page changes adjustment.
+.TH ino 1 2020-08-21 "groff test suite"
+.SH Name
+ino \- innocent man page
+.SH Description
+Innocent, unoffending man page enjoys adjustment to both margins.
+Innocent, unoffending man page enjoys adjustment to both margins.'
+
+OUTPUT=$(printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -man)
+echo "$OUTPUT" | grep -qE 'margins\. In' # two spaces
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_TH-repairs-hy-damage.sh b/tmac/tests/an_TH-repairs-hy-damage.sh
new file mode 100755
index 0000000..43f3471
--- /dev/null
+++ b/tmac/tests/an_TH-repairs-hy-damage.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+EXAMPLE='.TH mal 1 2020-08-21 "groff test suite"
+.SH Name
+mal \- malevolent man page
+.SH Description
+.nh
+Wicked page disables hyphenation.
+Wicked page disables hyphenation.
+Wicked page disables hyphenation.
+.TH ino 1 2020-08-21 "groff test suite"
+.SH Name
+ino \- innocent man page
+.SH Description
+Innocent, unoffending man page enjoys hyphenation.
+Innocent, unoffending man page enjoys hyphenation.'
+
+printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -man \
+ | grep -qE 'unoffend-'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_TS-adds-no-vertical-space.sh b/tmac/tests/an_TS-adds-no-vertical-space.sh
new file mode 100755
index 0000000..d6e790a
--- /dev/null
+++ b/tmac/tests/an_TS-adds-no-vertical-space.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+input='.TH foo 1 2022-07-30 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH Description
+Foo.
+.TS
+L.
+bar
+.TE
+'
+
+# Bash strips out an empty line, but that's what we're looking for.
+output=$(printf "%s" "$input" | "$groff" -t -man -Tascii \
+ | sed -n \
+ -e '/Foo\./{n;s/^$/FAILURE/;tA;' \
+ -e 's/.*/SUCCESS/;:A;' \
+ -e 'p;}')
+ # Here's a tidier version accepted by GNU sed but rejected
+ # contemptuously by macOS sed. (POSIX doesn't say you _have_ to
+ # accept semicolons after label ':' and branch 't' commands, so it
+ # doesn't.)
+ # sed -n '/Foo\./{n;s/^$/FAILURE/;tA;s/.*/SUCCESS/;:A;p}'
+test "$output" = SUCCESS
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_TS-do-not-keep-tables-when-cR-set.sh b/tmac/tests/an_TS-do-not-keep-tables-when-cR-set.sh
new file mode 100755
index 0000000..3c30cd4
--- /dev/null
+++ b/tmac/tests/an_TS-do-not-keep-tables-when-cR-set.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Copyright (C) 2020-2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #57665.
+#
+# The interior of this text is fragile with respect to line count.
+
+EXAMPLE='
+.TH ts\-hell 1 2020-10-09 "groff test suite"
+.SH Name
+ts\-hell \- turn off tbl keeps when continuous rendering
+.SH Description
+A long table should not get spurious blank lines inserted into it when
+continuously rendering.
+.
+This arises from
+.IR tbl (1)
+using \[lq]keeps\[rq].
+.
+We do not need those when
+.B cR
+is set.
+.
+.TS
+l.
+'$(n=1; while [ $n -le 53 ]; do echo $n; n=$(( n + 1 )); done)'
+.TE'
+
+OUTPUT=$(printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -t -man)
+test -n "$(echo "$OUTPUT" | sed -n '/52/{N;/53/p;}')"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_UE-breaks-before-long-URIs.sh b/tmac/tests/an_UE-breaks-before-long-URIs.sh
new file mode 100755
index 0000000..0b151fd
--- /dev/null
+++ b/tmac/tests/an_UE-breaks-before-long-URIs.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+input=$(cat <<EOF
+.TH ridonk 1 2021-10-31 "groff test suite"
+.SH Name
+ridonk \- check the typesetting of absurdly long URIs
+.SH Description
+.UR https://\:www\:.adobe\:.com/\:content/\:dam/\:acom/\:en/\:devnet/\:\
+actionscript/\:articles/\:5001\:.DSC_Spec\:.pdf
+Commerce
+.UE ,
+n.:
+A kind of transaction in which A plunders from B the goods of C,
+and for compensation B picks the pocket of D of money belonging to E.
+.P
+.UR https://1\:2\:3\:4\:5\:6\:7\:8\:9\:1\:1\:2\:3\:4\:5\:6\:7\:8\:9\:\
+2\:1\:2\:3\:4\:5\:6\:7\:8\:9\:3\:1\:2\:3\:4\:5\:6\:7\:8\:9\:4\:1\:2\:\
+3\:4\:5\:6\:7\:8\:9\:5\:1\:2\:3\:4\:5\:6\:7\:8\:9\:6\:1\:2\:3\:4\:5\:\
+6\:7\:8\:9\:7\:1\:2\:3\:4\:5\:6\:7\:8\:9\:8\:1\:2\:3\:4\:5\:6\:7\:8\:\
+9\:9\:1\:2\:3\:4\:5\:6\:7\:8\:9\:0
+.UE
+EOF
+)
+
+fail=
+
+wail () {
+ echo "...$* FAILED" >&2
+ fail=yes
+}
+
+output=$(printf "%s" "$input" | "$groff" -Tascii -P-cbou -man)
+echo "$output"
+error=$(printf "%s" "$input" \
+ | "$groff" -Tascii -P-cbou -man -ww -z 2>&1)
+
+echo "testing that no diagnostic messages are produced" >&2
+test -z "$error" || wail
+echo "testing that lines break where expected" >&2
+break1=$(echo "$output" | grep -x " *Commerce *<https.*devnet/")
+break2=$(echo "$output" | grep -x " *actionscript/.* transaction *in")
+break3=$(echo "$output" | grep -x " *<https.*612")
+test -n "$break1" || wail "first break"
+test -n "$break2" || wail "second break"
+test -n "$break3" || wail "third break"
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_UE-punct-hyphenates.sh b/tmac/tests/an_UE-punct-hyphenates.sh
new file mode 100755
index 0000000..e438078
--- /dev/null
+++ b/tmac/tests/an_UE-punct-hyphenates.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Copyright (C) 2020, 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 ue\-punct 1 2020-08-15 "groff test suite"
+.SH Name
+ue\-punct \- URL trailing material is subject to hyphenation
+.SH Description
+Do not try to
+.UR https://www.gnu.org/software/groff/
+hyphenate a ridiculous word* without machine assistance
+.UE (*pneumonoultramicroscopicsilicovolcanoconiosis).'
+
+# Turn off break warnings; we expect an adjustment problem.
+echo "testing hyphenation of trailing text by an.tmac's UE macro"
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -Wbreak -P-cbou -man)
+echo "$output"
+echo "$output" | grep -qE 'pn.*-'
+
+echo "testing hyphenation of trailing text by an-ext.tmac's UE macro"
+output=$(printf "%s\n" "$input" \
+ | "$groff" -rmG=0 -Tascii -Wbreak -P-cbou -man)
+echo "$output"
+echo "$output" | grep -qE 'pn.*-'
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_UR-body-hyphenates.sh b/tmac/tests/an_UR-body-hyphenates.sh
new file mode 100755
index 0000000..ecc57b6
--- /dev/null
+++ b/tmac/tests/an_UR-body-hyphenates.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+EXAMPLE='.TH ur\-body 1 2020-08-15 "groff test suite"
+.SH Name
+ur\-body \- URL link text is subject to hyphenation
+.SH Description
+Do not try to
+.UR https://www.gnu.org/software/groff/
+hyphenate the word
+pneumonoultramicroscopicsilicovolcanoconiosis
+without machine assistance
+.UE .'
+
+printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -man \
+ | grep -qE 'pn.*-'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_UR-works.sh b/tmac/tests/an_UR-works.sh
new file mode 100755
index 0000000..6100e62
--- /dev/null
+++ b/tmac/tests/an_UR-works.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 2022-11-22 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH Description
+See
+.UR http://\:foo\:.example\:.com
+figure 1
+.UE .
+.
+Or
+.UR http://\:bar\:.example\:.com
+.UE .'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man -rU0)
+echo "$output"
+
+echo "checking formatting of web URI with link text" \
+ "(hyperlinks disabled)" >&2
+echo "$output" | grep -Fq 'See figure 1 <http://foo.example.com>.' \
+ || wail
+
+echo "checking formatting of web URI with no link text" \
+ "(hyperlinks disabled)" >&2
+echo "$output" | grep -Fq 'Or <http://bar.example.com>.' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man -rU1)
+echo "$output"
+
+echo "checking formatting of web URI with link text" \
+ "(hyperlinks enabled)" >&2
+echo "$output" | grep -Fq 'See figure 1.' || wail
+
+echo "checking formatting of web URI with no link text" \
+ "(hyperlinks enabled)" >&2
+echo "$output" | grep -Fq 'Or http://bar.example.com.' || wail
+
+input='.TH foo 1 2022-12-04 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH "See also"
+For our SOSP presentation,
+check our
+.UR https://\:example\:.com
+website
+.UE .'
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Thtml)
+echo "$output"
+
+echo "checking HTML output of web URI" >&2
+echo "$output" \
+ | grep -Fqx '<a href="https://example.com">website</a>.</p>' \
+ || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_X-register-works.sh b/tmac/tests/an_X-register-works.sh
new file mode 100755
index 0000000..9db3272
--- /dev/null
+++ b/tmac/tests/an_X-register-works.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# Copyright (C) 2020-2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Ensure the X register takes effect on the right page and looks right.
+
+INPUT='.TH foo 1 2021-05-19 "groff foo test suite"
+.TH bar 1 2021-05-19 "groff bar test suite"'
+
+FAIL=
+
+OUTPUT=$(printf "%s\n" "$INPUT" \
+ | "$groff" -Tascii -P-cbou -rcR=0 -rC1 -rX1 -man)
+
+if ! echo "$OUTPUT" | grep -Eqx 'groff foo test suite +2021-05-19 +1'
+then
+ FAIL=yes
+ echo "first page footer test failed" >&2
+fi
+
+if ! echo "$OUTPUT" | grep -Eqx 'groff bar test suite +2021-05-19 +1a'
+then
+ FAIL=yes
+ echo "second page footer test failed" >&2
+fi
+
+INPUT='.TH baz 1 2021-05-19 "groff baz test suite"
+.SH Name
+baz \- neglect third stepchild
+.SH Description
+This program is the lowly third in line.'
+
+OUTPUT=$(printf "%s\n" "$INPUT" \
+ | "$groff" -Thtml -rcR=0 -rC1 -rX1 -man)
+
+if echo "$OUTPUT" | grep -q 'groff baz test suite'
+then
+ FAIL=yes
+ echo "HTML output unexpectedly contains footer text" >&2
+fi
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_adjust-link-text-correctly.sh b/tmac/tests/an_adjust-link-text-correctly.sh
new file mode 100755
index 0000000..da3359d
--- /dev/null
+++ b/tmac/tests/an_adjust-link-text-correctly.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Ensure that link text (when the hyperlink itself is not formatted
+# because the device supports hyperlinking) uses the correct line length
+# and is adjusted.
+
+input='.TH foo 1 2022-11-08 "groff test suite"
+.SH "See also"
+.
+.UR http://\:www\:.hp\:.com/\:ctg/\:Manual/\:bpl13210\:.pdf
+.I HP PCL/PJL Reference:
+.I PCL\~5 Printer Language Technical Reference Manual,
+.I Part I
+.UE'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man -rU1)
+echo "$output"
+echo "$output" | grep -q 'HP PCL/PJL Reference:.*Reference Manu-'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_avoid-two-font-denial-of-service.sh b/tmac/tests/an_avoid-two-font-denial-of-service.sh
new file mode 100755
index 0000000..2ba1822
--- /dev/null
+++ b/tmac/tests/an_avoid-two-font-denial-of-service.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# That's six pairs of parentheses below.
+"$groff" -Tascii -P-cbou -man <<EOF | grep -q '( ) ( ) ( ) ( ) ( ) ( )'
+.TH sample 1 2020-09-16 "groff test suite"
+.SH Name
+sample \- test subject for groff
+.PP
+Don't DoS me, bro!
+.BI ( \\ )
+.BR ( \\ )
+.IB ( \\ )
+.IR ( \\ )
+.RB ( \\ )
+.RI ( \\ )
+EOF
diff --git a/tmac/tests/an_do-not-abbreviate-escape-using-TH-arguments.sh b/tmac/tests/an_do-not-abbreviate-escape-using-TH-arguments.sh
new file mode 100755
index 0000000..fd50211
--- /dev/null
+++ b/tmac/tests/an_do-not-abbreviate-escape-using-TH-arguments.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savanah #62257.
+#
+# Do not attempt to abbreviate page titles or inner footers (the 4th
+# argument to `TH` that contain non-trivial escape sequences. See
+# Savannah #62264 for why doing so is difficult.
+
+fail=
+
+wail () {
+ echo "...FAILED" >&2
+ fail=yes
+}
+
+input='.TH f\-b 1 2022-04-08 "Bletcherous Glorfinking Dungr'\
+'\[u ad]ndel Hoppabotch Greebstank 2.21"'
+
+# The u with dieresis will not be output on the 'ascii' device.
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man)
+
+echo "checking that title with escaped hyphen-minus is preserved" >&2
+echo "$output" | grep -q '^f-b(1)' || wail
+
+pattern='Bletcherous Glorfinking Dungrndel 2022-04-08 Greebstank 2.21'
+pattern="$pattern f-b(1)" # 12 spaces
+echo "checking for insanely long 4th TH argument" >&2
+echo "$output" | grep -Fqx "$pattern" || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_font-remapping-does-not-affect-titles.sh b/tmac/tests/an_font-remapping-does-not-affect-titles.sh
new file mode 100755
index 0000000..3332cc1
--- /dev/null
+++ b/tmac/tests/an_font-remapping-does-not-affect-titles.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #61279.
+#
+# If a SH or SS (sub)section heading was about to be output at the
+# bottom of a page but wasn't because of the vertical space .ne-eded,
+# we want to ensure that font remapping for the headings doesn't affect
+# page footers and headers.
+
+# Keep preconv from being run.
+unset GROFF_ENCODING
+
+input='.TH \\fIfoo\\fP 1 2021-10-04 "groff test suite"
+.SH Name
+foo \\- a command with a very short name
+.sp 50v
+.SH "\\fIgroff\\fP integration"
+A complicated situation.'
+
+output=$(echo "$input" | "$groff" -Tascii -man -rcR=0)
+echo "$output"
+output=$(echo "$input" | "$groff" -Tascii -man -rcR=0 -Z | nl)
+echo "$output"
+
+# Expected:
+# 74 V2640
+# 75 p2
+# 76 x font 2 I
+# 77 f2
+# 78 s10
+# 79 V160
+# 80 H0
+# 81 tfoo
+# 82 x font 1 R
+# 83 f1
+# 84 t(1)
+
+echo "$output" | grep -E '77[[:space:]]+f2'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_handle-degenerate-input-quietly.sh b/tmac/tests/an_handle-degenerate-input-quietly.sh
new file mode 100755
index 0000000..a8df013
--- /dev/null
+++ b/tmac/tests/an_handle-degenerate-input-quietly.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #61402.
+#
+# Don't spew a lot of diagnostics if we have only empty lines as input.
+
+test -z "$(echo | "$groff" -man -ww -Tascii -P-cbou 2>&1 > /dev/null)"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_inner-footer-abbreviation-works.sh b/tmac/tests/an_inner-footer-abbreviation-works.sh
new file mode 100755
index 0000000..2d16b7d
--- /dev/null
+++ b/tmac/tests/an_inner-footer-abbreviation-works.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #61386.
+#
+# Excessively long "extra2" arguments to 'TH' (we recommend using this
+# for project name and version information) can overrun other parts of
+# the titles, such as a date in the center footer.
+
+FAIL=
+
+INPUT='.TH foo 1 2021-10-26 "groff 1.23.0.rc1.1449-84949"
+.SH Name
+foo \- a command with a very short name'
+
+echo 'testing long inner footer with sufficient space to set it' >&2
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man)
+PATTERN='groff 1\.23\.0\.rc1\.1449-84949 +2021-10-26 +foo\(1\)'
+
+if ! echo "$OUTPUT" | grep -Eq "$PATTERN"
+then
+ FAIL=yes
+ echo "...FAILED" >&2
+fi
+
+echo 'testing long inner footer with insufficient space to set it' >&2
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man -rLL=60n)
+PATTERN='groff 1\.23\.0\.rc1\.1449\.\.\. +2021-10-26 +foo\(1\)'
+
+if ! echo "$OUTPUT" | grep -Eq "$PATTERN"
+then
+ FAIL=yes
+ echo "...FAILED" >&2
+fi
+
+# Regression-test Savannah #61408.
+#
+# Don't spew diagnostics if the page doesn't supply a 3rd .TH argument.
+echo 'testing for graceful behavior when TH has no 3rd argument' >&2
+INPUT='.TH patch 1 "" GNU'
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man -ww -z 2>&1)
+
+if [ -n "$OUTPUT" ]
+then
+ FAIL=yes
+ echo "...FAILED" >&2
+fi
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_link-macros-work-in-paragraph-tags.sh b/tmac/tests/an_link-macros-work-in-paragraph-tags.sh
new file mode 100755
index 0000000..c5aee64
--- /dev/null
+++ b/tmac/tests/an_link-macros-work-in-paragraph-tags.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+input=$(cat <<EOF
+.TH foo 1 2021-11-05 "groff test suite"
+.TP
+.UR https://\:github.com/\:Alhadis/\:Roff\:.js/
+.I Roff.js
+.UE
+is a viewer for intermediate output written in JavaScript.
+EOF
+)
+
+fail=
+
+wail () {
+ echo "...FAILED" >&2
+ fail=YES
+}
+
+# Check for regressions when OSC 8 disabled
+uflag=-rU0
+
+output=$(printf "%s" "$input" \
+ | "$groff" -bww -Tascii -P-cbou $uflag -man)
+
+echo "checking for paragraph tag on line by itself ($uflag)" >&2
+echo "$output" | grep -qx ' Roff\.js' || wail # 7 spaces
+
+echo "checking for presence of typeset URI ($uflag)" >&2
+echo "$output" \
+ | grep -q '^ <https://github\.com/Alhadis/Roff\.js/>' \
+ || wail # 14 spaces
+
+output=$(printf "%s" "$input" \
+ | "$groff" -bww -Tascii -P-cbou -rU0 -rLL=130n -man)
+
+# Sloppy handling of UE, ME macro arguments can cause unwanted space.
+echo "checking for normative (no extra) spacing after URI ($uflag)" >&2
+echo "$output" | grep -q '> is a viewer for intermediate' || wail
+
+# Now check for good formatting when URIs are hyperlinked.
+uflag=-rU1
+
+output=$(printf "%s" "$input" \
+ | "$groff" -bww -Tutf8 -P-cbou $uflag -man)
+
+echo "checking for paragraph tag on line by itself ($uflag)" >&2
+echo "$output" | grep -qx ' Roff\.js' || wail # 7 spaces
+
+# Hyperlinking paragraph tags was not supported in groff 1.22.4 and
+# still isn't.
+#echo "checking for absence of typeset URI" >&2
+#! echo "$output" | grep -q https || wail
+
+output=$(printf "%s" "$input" \
+ | "$groff" -bww -Tascii -P-cbou $uflag -rLL=130n -man)
+
+echo "checking for normative (no extra) spacing after URI ($uflag)" >&2
+# This is what we expect when linking the tag works.
+#echo "$output" \
+# | grep -q '^ is a viewer for intermediate' \
+# || wail # 14 spaces
+# ...but in the meantime...
+echo "$output" | grep -q '[^[:space:]] is a viewer for' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_link-trailing-text-hugs-previous.sh b/tmac/tests/an_link-trailing-text-hugs-previous.sh
new file mode 100755
index 0000000..e3e5a1d
--- /dev/null
+++ b/tmac/tests/an_link-trailing-text-hugs-previous.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 2022-12-04 "groff test suite"
+.SH Name
+foo \- frobnicate a bar
+.SH Authors
+.I foo
+was written by
+.MT jp@\:example\:.com
+J.\& Ponderous
+.ME (deceased).'
+
+output=$(printf "%s\n" "$input" | "$groff" -rU0 -man -Tascii -P-cbou)
+echo "$output"
+echo "checking that trailing text hugs link URI (-rU0)"
+echo "$output" | grep -q '\.com>(deceased)\.$' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -rU1 -man -Tascii -P-cbou)
+echo "$output" | od -c
+echo "checking that trailing text hugs link text (-rU1)"
+echo "$output" | grep -q 'Ponderous(deceased).$' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_no-break-after-short-paragraph-tags.sh b/tmac/tests/an_no-break-after-short-paragraph-tags.sh
new file mode 100755
index 0000000..0d75f9c
--- /dev/null
+++ b/tmac/tests/an_no-break-after-short-paragraph-tags.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #60624.
+#
+# A page break should not follow the tag in a tagged paragraph when the
+# tag can fit within the indentation.
+
+FAIL=
+
+INPUT='.TH foo 1 2021-05-18 "groff test suite"
+.SH Name
+foo \- frobnicate a thingamajig
+.rs \" force spacing on
+.sp 50
+.TP
+3
+7th edition'
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man -rcR=0)
+
+echo "$OUTPUT" | grep -Eqx ' +3 +7th edition'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_output-footer-when-continuously-rendering.sh b/tmac/tests/an_output-footer-when-continuously-rendering.sh
new file mode 100755
index 0000000..4cf476b
--- /dev/null
+++ b/tmac/tests/an_output-footer-when-continuously-rendering.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Ensure that the page footer is printed even when a pending output line
+# is 1v from the page bottom. (A page ejection inside an end of input
+# trap exits the formatter.)
+
+input='.TH foo 1 2022-11-02 "groff test suite"
+.SH Name
+foo \\- frobnicate a bar
+.SH Description
+.rs
+.sp 60v
+line 61
+.br
+line 62'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man)
+echo "$output"
+echo "$output" | grep -Eqx 'groff test suite +2022-11-02 +foo\(1\)'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_page-footers-present.sh b/tmac/tests/an_page-footers-present.sh
new file mode 100755
index 0000000..2ce1650
--- /dev/null
+++ b/tmac/tests/an_page-footers-present.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #60609.
+
+INPUT='.TH foo 1 2021-05-16 "groff test suite" "Volume 1"
+.SH Name
+foo \- a frobnicating thing
+.TH bar 1 2021-05-16 "groff test suite" "Volume 2"
+.SH Name
+bar \- a wretched hive of scum and villainy'
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man)
+
+FAIL=
+
+if ! echo "$OUTPUT" | grep -Eqx 'groff test suite +2021-05-16 +foo\(1\)'
+then
+ FAIL=yes
+ echo "first page footer test failed (continuous rendering on)" >&2
+fi
+
+if ! echo "$OUTPUT" | grep -Eqx 'groff test suite +2021-05-16 +bar\(1\)'
+then
+ FAIL=yes
+ echo "second page footer test failed (continuous rendering on)" >&2
+fi
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man -rcR=0)
+
+if ! echo "$OUTPUT" | grep -Eqx 'groff test suite +2021-05-16 +1'
+then
+ FAIL=yes
+ echo "first page footer test failed (continuous rendering off)" >&2
+fi
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man -rcR=0 -rC1)
+
+if ! echo "$OUTPUT" | sed '1,/^groff test suite/d' \
+ | grep -Eqx 'groff test suite +2021-05-16 +2'
+then
+ FAIL=yes
+ echo "second page footer test failed (continuous rendering off," \
+ " cotinuous numbering on)" >&2
+fi
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=80:
diff --git a/tmac/tests/an_page-header-has-current-data.sh b/tmac/tests/an_page-header-has-current-data.sh
new file mode 100755
index 0000000..90e3b59
--- /dev/null
+++ b/tmac/tests/an_page-header-has-current-data.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Misconfiguration of traps or our man(7) implementation's page-flushing macros,
+# or poor ordering of logic in its TH macro, can cause page headers to render
+# with incorrect information.
+
+INPUT='.TH foo 1 2021-05-16 "groff test suite" "Volume 1"
+.SH Name
+foo \- a frobnicating thing
+.TH bar 1 2021-05-16 "groff test suite" "Volume 2"
+.SH Name
+bar \- a wretched hive of scum and villainy'
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man)
+echo "$OUTPUT"
+
+FAIL=
+
+if ! echo "$OUTPUT" | grep -Eqx 'foo\(1\) +Volume 1 +foo\(1\)'
+then
+ FAIL=yes
+ echo "first page header test failed (continuous rendering on)" >&2
+fi
+
+if ! echo "$OUTPUT" | sed '1,/^groff test suite/d' \
+ | grep -Eqx 'bar\(1\) +Volume 2 +bar\(1\)'
+then
+ FAIL=yes
+ echo "second page header test failed (continuous rendering on)" >&2
+fi
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man -rcR=0)
+echo "$OUTPUT"
+
+if ! echo "$OUTPUT" | grep -Eqx 'foo\(1\) +Volume 1 +foo\(1\)'
+then
+ FAIL=yes
+ echo "first page header test failed (continuous rendering off)" >&2
+fi
+
+if ! echo "$OUTPUT" | sed '1,/^groff test suite/d' \
+ | grep -Eqx 'bar\(1\) +Volume 2 +bar\(1\)'
+then
+ FAIL=yes
+ echo "second page header test failed (continuous rendering off)" >&2
+fi
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=80:
diff --git a/tmac/tests/an_reset-hyphenation-correctly.sh b/tmac/tests/an_reset-hyphenation-correctly.sh
new file mode 100755
index 0000000..7191419
--- /dev/null
+++ b/tmac/tests/an_reset-hyphenation-correctly.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Fix problem observed while implementing Savannah #61734. Using a
+# hyphenation of "en" (English) with the hyphenation mode for Swedish
+# produces bad breaks.
+
+input='.TH foo 1 2022-02-21 "groff test suite"
+xx
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+glyph
+'
+
+fail=
+
+wail () {
+ echo "...$* FAILED" >&2
+ fail=yes
+}
+
+echo "checking continuous rendering mode" >&2
+output=$(printf "%s" "$input" \
+ | "$groff" -Tascii -P-cbou -man -msv -men)
+echo "$output" | grep -q 'g-$' && wail
+
+echo "checking discontinuous (paginated) rendering mode" >&2
+output=$(printf "%s" "$input" \
+ | "$groff" -Tascii -P-cbou -man -rcR=0 -msv -men)
+echo "$output" | grep -q 'g-$' && wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_title-abbreviation-works.sh b/tmac/tests/an_title-abbreviation-works.sh
new file mode 100755
index 0000000..86ec8d1
--- /dev/null
+++ b/tmac/tests/an_title-abbreviation-works.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #43532.
+#
+# Excessively long man page titles can overrun other parts of the titles
+# (headers and footers). Verify abbreviation of ones that would.
+
+FAIL=
+
+INPUT='.TH foo 1 2021-05-31 "groff test suite"
+.SH Name
+foo \- a command with a very short name'
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man)
+
+if ! echo "$OUTPUT" \
+ | grep -Eq 'foo\(1\) +General Commands Manual +foo\(1\)'
+then
+ FAIL=yes
+ echo "short page title test failed" >&2
+fi
+
+INPUT='.TH CosNotifyChannelAdmin_StructuredProxyPushSupplier 3erl \
+2021-05-31 "groff test suite" "Erlang Module Definition"
+.SH Name
+CosNotifyChannelAdmin_StructuredProxyPushSupplier \- OMFG'
+
+OUTPUT=$(echo "$INPUT" | "$groff" -Tascii -P-cbou -man)
+
+TITLE_ABBV="CosNotif...hSupplier(3erl)"
+PATTERN="$TITLE_ABBV Erlang Module Definition $TITLE_ABBV"
+
+if ! echo "$OUTPUT" | grep -Fq "$PATTERN"
+then
+ FAIL=yes
+ echo "long page title test failed" >&2
+fi
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_use-input-traps-correctly.sh b/tmac/tests/an_use-input-traps-correctly.sh
new file mode 100755
index 0000000..4ad76e6
--- /dev/null
+++ b/tmac/tests/an_use-input-traps-correctly.sh
@@ -0,0 +1,113 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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
+}
+
+# Ensure that input trap-using macros employ the correct request. B, I,
+# SH, SS, SM, and SB need `it`; TP needs `itc`.
+
+# B
+
+input=".TH foo 1 2022-06-07 \"groff test suite\"
+.B \\\\n[.fn]\c
+\\n[.fn]"
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Tascii -P-cbou 2>&1)
+
+echo "checking that B macro uses correct input trap 'it'" >&2
+echo "$output" | grep -Fqx 'BR' || wail
+
+# I
+
+input=".TH foo 1 2022-06-07 \"groff test suite\"
+.I \\\\n[.fn]\c
+\\n[.fn]"
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Tascii -P-cbou 2>&1)
+
+echo "checking that I macro uses correct input trap 'it'" >&2
+echo "$output" | grep -Fqx 'IR' || wail
+
+# SH
+
+input=".TH foo 1 2022-06-07 \"groff test suite\"
+.SH Name\c
+foo \- frobnicate a bar"
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Tascii -P-cbou 2>&1)
+
+echo "checking that SH macro uses correct input trap 'it'" >&2
+echo "$output" | grep -Fqx 'Name' || wail
+
+# SS
+
+input=".TH foo 1 2022-06-07 \"groff test suite\"
+.SS Limitations\c
+Lorem ipsum gitsum voluptatem."
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Tascii -P-cbou 2>&1)
+
+echo "checking that SS macro uses correct input trap 'it'" >&2
+echo "$output" | grep -Fqx ' Limitations' || wail # 3 spaces
+
+# SM
+
+input=".TH foo 1 2022-06-07 \"groff test suite\"
+.SM \\\\n[.s]\c
+\\n[.s]"
+
+output=$(printf "%s\n" "$input" | "$groff" -man -a -Tps 2>&1)
+
+echo "checking that SM macro uses correct input trap 'it'" >&2
+echo "$output" | grep -Fqx '910' || wail
+
+# SB
+
+input=".TH foo 1 2022-06-07 \"groff test suite\"
+.SB \\\\n[.fn]\\\\n[.s]\c
+\\n[.fn]\\n[.s]"
+
+output=$(printf "%s\n" "$input" | "$groff" -man -a -Tps 2>&1)
+
+echo "checking that SB macro uses correct input trap 'it'" >&2
+echo "$output" | grep -Fqx 'TB9TR10' || wail
+
+# TP
+
+input=".TH foo 1 2022-06-07 \"groff test suite\"
+.TP
+.BR \-\-bar [ =\c
+.IR baz ]"
+
+output=$(printf "%s\n" "$input" | "$groff" -man -Tascii -P-cbou 2>&1)
+
+echo "checking that TP macro uses correct input trap 'itc'" >&2
+echo "$output" | grep -Fqx ' --bar[=baz]' || wail # 7 spaces
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_works-with-ec.sh b/tmac/tests/an_works-with-ec.sh
new file mode 100755
index 0000000..2ddb8e8
--- /dev/null
+++ b/tmac/tests/an_works-with-ec.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #63194. Use of '-man -mec -Tdvi' should not
+# make the italic font unavailable in ordinary text.
+#
+# The per mille sign is available only in the EC fonts, so if we
+# failed to switch them in, we'll get an undefined special character
+# warning.
+
+input=$(
+ printf '.TH foo 1 2022-10-10 "groff test suite"\n';
+ printf '.SH N\\['"'"'E]V \\f[BI]groff\\f[] \\fBGNU\\fP\n';
+ printf 'foo \\- \\[%%0]\\fIgroff\n';
+)
+
+output=$(printf "%s\n" "$input" | "$groff" -man -mec -Tdvi -z 2>&1)
+echo "$output"
+test -z "$output"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/andoc_P-register-works.sh b/tmac/tests/andoc_P-register-works.sh
new file mode 100755
index 0000000..e4e8f77
--- /dev/null
+++ b/tmac/tests/andoc_P-register-works.sh
@@ -0,0 +1,117 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 going back and forth from man(7) to mdoc(7).
+
+input='.TH foo 1 2022-12-11 "groff test suite"
+.SH Name
+foo \- frobinicate a bar
+.bp
+.SH Description
+It took a while to get here.
+.Dd 2022-12-11
+.Dt bar 1
+.Os "groff test suite"
+.Sh Name
+.Nm bar
+.Nd erect something for people to walk into
+.bp
+.Sh Description
+It took a while to get here.
+.TH baz 7 2022-12-11 "groff test suite"
+.SH Name
+baz \- what they do not play at Mos Eisley spaceport cantina
+.bp
+.SH Description
+It took a while to get here.'
+
+# First, check without continuous numbering. Each page starts at P.
+
+output=$(printf "%s\n" "$input" | "$groff" -rcR=0 -rP13 -mandoc \
+ -Tascii -P-cbou)
+echo "$output"
+
+echo "checking first document, first page footer (discontinuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +13$" \
+ | grep '^64:' || wail
+
+echo "checking first document, second page footer (discontinuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +14$" \
+ | grep '^130:' || wail
+
+echo "checking second document, first page footer (discontinuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +13$" \
+ | grep '^196:' || wail
+
+echo "checking second document, second page footer (discontinuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +14$" \
+ | grep '^262:' || wail
+
+echo "checking third document, first page footer (discontinuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +13$" \
+ | grep '^328:' || wail
+
+echo "checking third document, second page footer (discontinuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +14$" \
+ | grep '^394:' || wail
+
+# Now, check _with_ continuous numbering. Only the first page is
+# numbered P.
+
+output=$(printf "%s\n" "$input" | "$groff" -rcR=0 -rC1 -rP13 -mandoc \
+ -Tascii -P-cbou)
+echo "$output"
+
+echo "checking first document, first page footer (continuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +13$" \
+ | grep '^64:' || wail
+
+echo "checking first document, second page footer (continuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +14$" \
+ | grep '^130:' || wail
+
+echo "checking second document, first page footer (continuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +15$" \
+ | grep '^196:' || wail
+
+echo "checking second document, second page footer (continuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +16$" \
+ | grep '^262:' || wail
+
+echo "checking third document, first page footer (continuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +17$" \
+ | grep '^328:' || wail
+
+echo "checking third document, second page footer (continuous)" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +18$" \
+ | grep '^394:' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/andoc_check-an-to-doc-transition.sh b/tmac/tests/andoc_check-an-to-doc-transition.sh
new file mode 100755
index 0000000..42dc2ee
--- /dev/null
+++ b/tmac/tests/andoc_check-an-to-doc-transition.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 2022-12-11 "groff test suite"
+.SH Name
+foo \- frobinicate a bar
+.Dd 2022-12-11
+.Dt bar 1
+.Os "groff test suite"
+.Sh Name
+.Nm bar
+.Nd erect a thing to be walked into'
+
+output=$(printf "%s\n" "$input" | "$groff" -mandoc -Tascii -P-cbou)
+echo "$output"
+
+echo "checking for one foo(1) header" >&2
+test $(echo "$output" \
+ | grep -Ec "foo\(1\) +General Commands Manual +foo\(1\)") \
+ -eq 1 || fail
+
+echo "checking for one foo(1) footer" >&2
+test $(echo "$output" \
+ | grep -Ec "groff test suite +2022-12-11 +foo\(1\)") -eq 1 \
+ || fail
+
+echo "checking for one bar(1) header" >&2
+test $(echo "$output" \
+ | grep -Ec "bar\(1\) +General Commands Manual +bar\(1\)") \
+ -eq 1 || fail
+
+echo "checking for one bar(1) barter" >&2
+test $(echo "$output" \
+ | grep -Ec "groff test suite +2022-12-11 +bar\(1\)") -eq 1 \
+ || fail
+
+echo "checking for uninitialized header and footer fields"
+echo "$output" | grep -E "(UNTITLED|UNDATED|LOCAL)" && fail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/andoc_clear-doc-traps.sh b/tmac/tests/andoc_clear-doc-traps.sh
new file mode 100755
index 0000000..9a754e6
--- /dev/null
+++ b/tmac/tests/andoc_clear-doc-traps.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #59246.
+#
+# andoc should remove mdoc(7) traps before rendering a man(7) page.
+# Continuous rendering has to be _off_ to catch this.
+
+EXAMPLE=\
+'.Dd October 11, 2020
+.Dt mdoc\-test 7
+.Os
+.Sh Name
+.Nm mdoc\-test
+.Nd lay mine
+.Sh Description
+Just testing.
+.TH man\-test 7 2020-10-11
+.SH Name
+man-test \- drive sheep across minefield
+.SH Description
+\[lq]doc\-footer\[rq] should definitely not be sprung by this document.'
+
+! printf "%s\n" "$EXAMPLE" \
+ | "$groff" -Tascii -P-cbou -mandoc -rcR=0 \
+ | grep -E '^BSD +October 11, 2020 +3$'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/andoc_flush-between-packages.sh b/tmac/tests/andoc_flush-between-packages.sh
new file mode 100755
index 0000000..6b24f84
--- /dev/null
+++ b/tmac/tests/andoc_flush-between-packages.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #59016.
+#
+# Ensure that a partially-collected line at the end of a file gets
+# flushed, and page footers written, before proceeding to the next
+# document. Check going from man(7) to mdoc(7) documents and back.
+
+EXAMPLE=\
+'.TH man\-flush\-test 7 2020-10-11 "groff test page 1"
+.SH Name
+man\-flush-test \- a sanity test for groff_man(7)
+.SH Description
+This gratuitously loquacious sentence should end up with a
+partially-collected output line.
+.Dd October 11, 2020
+.Dt mdoc\-test 7
+.Os "groff test page 2"
+.Sh Name
+.Nm mdoc\-test
+.Nd a sanity test for groff_mdoc(7)
+.Sh Description
+This additional gratuitously loquacious sentence should end up with a
+partially-collected output line.
+.TH man\-flush\-test2 7 2020-10-11 "groff test page 3"
+.SH Name
+man\-flush-test2 \- a second sanity test for groff_man(7)
+.SH Description
+This supernumerary loquacious sentence should end up with a
+partially-collected output line.'
+
+OUTPUT=$(printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -mandoc)
+
+FAIL=
+
+# Strip blank lines from the output first; all we care about for this
+# test is the presence, adjacency, and ordering of non-blank lines.
+
+if [ -z "$(echo "$OUTPUT" \
+ | sed '/^$/d' \
+ | sed -n '/collected/{N;/test page 1/p;}')" ]
+then
+ FAIL=yes
+ echo "man to mdoc transition failed" >&2
+fi
+
+if [ -z "$(echo "$OUTPUT" \
+ | sed '/^$/d' \
+ | sed -n '/partially-collected/{N;/test page 2/p;}')" ]
+then
+ FAIL=yes
+ echo "mdoc to man transition failed" >&2
+fi
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_CS-works.sh b/tmac/tests/doc_CS-works.sh
new file mode 100755
index 0000000..dfcc0f0
--- /dev/null
+++ b/tmac/tests/doc_CS-works.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+DOCUMENT=\
+'.Dd 2020-10-31
+.Dt sample 1
+.Os
+.Sh Name
+.Nm sample
+.Nd test subject for groff'
+
+echo "testing -rCS=0" >&2
+echo "$DOCUMENT" | "$groff" -rCS=0 -Tascii -P-cbou -mdoc \
+ | grep -q Name || exit 1
+
+echo "testing -rCS=1" >&2
+echo "$DOCUMENT" | "$groff" -rCS=1 -Tascii -P-cbou -mdoc \
+ | grep -q NAME || exit 1
+
+echo "testing default (no -rCS argument)" >&2
+echo "$DOCUMENT" | "$groff" -Tascii -P-cbou -mdoc \
+ | grep -q Name || exit 1
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_CT-works.sh b/tmac/tests/doc_CT-works.sh
new file mode 100755
index 0000000..04c4db7
--- /dev/null
+++ b/tmac/tests/doc_CT-works.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+DOCUMENT=\
+'.Dd 2020-10-31
+.Dt sample 1
+.Os
+.Sh Name
+.Nm sample
+.Nd test subject for groff'
+
+echo "testing -rCT=0" >&2
+echo "$DOCUMENT" | "$groff" -rCT=0 -Tascii -P-cbou -mdoc \
+ | grep -q 'sample(1)' || exit 1
+
+echo "testing -rCT=1" >&2
+echo "$DOCUMENT" | "$groff" -rCT=1 -Tascii -P-cbou -mdoc \
+ | grep -q 'SAMPLE(1)' || exit 1
+
+echo "testing default (no -rCT argument)" >&2
+echo "$DOCUMENT" | "$groff" -Tascii -P-cbou -mdoc \
+ | grep -q 'sample(1)' || exit 1
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_D-places-page-numbers-correctly.sh b/tmac/tests/doc_D-places-page-numbers-correctly.sh
new file mode 100755
index 0000000..15e377f
--- /dev/null
+++ b/tmac/tests/doc_D-places-page-numbers-correctly.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+DOCUMENT=\
+'.Dd 2020-11-17
+.Dt sample 1
+.Os "groff test suite"
+.Sh Name
+.Nm sample
+.Nd test subject for groff
+.bp
+.Sh Description
+This program does many things.'
+
+# Regression-test Debian #919890.
+#
+# Put page numbers in the correct places when double-sided rendering.
+
+echo "confirming page number on right on recto (odd-numbered) pages" >&2
+echo "$DOCUMENT" | "$groff" -rcR=0 -rD1 -Tascii -P-cbou -mdoc \
+ | grep -q '^groff test suite *2020-11-17 *1$' || exit 1
+
+echo "confirming page number on left on verso (even-numbered) pages" >&2
+echo "$DOCUMENT" | "$groff" -rcR=0 -rD1 -Tascii -P-cbou -mdoc \
+ | grep -q '^2 *2020-11-17 *groff test suite$' || exit 1
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_Lk-respect-sentence-ending-punctuation.sh b/tmac/tests/doc_Lk-respect-sentence-ending-punctuation.sh
new file mode 100755
index 0000000..7f2cc22
--- /dev/null
+++ b/tmac/tests/doc_Lk-respect-sentence-ending-punctuation.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #59738. The processing of arguments after
+# the link text should not break end-of-sentence detection.
+
+input='.Dd 2022-09-15
+.Dt foo 1
+.Os "groff test suite"
+.Sh Name
+.Nm foo
+.Nd frobnicate a bar
+.Sh Description
+Click
+.Lk http://example.com here .
+Follow instructions.'
+
+output=$(echo "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output" | grep -Fq 'com. Follow' # 2 spaces
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_Mt-works.sh b/tmac/tests/doc_Mt-works.sh
new file mode 100755
index 0000000..d779084
--- /dev/null
+++ b/tmac/tests/doc_Mt-works.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+set -e
+
+# Regression-test Savannah #60025.
+#
+# Ensure .Mt renders correctly.
+
+input='.Dd 2021-02-10
+.Dt mandoc 1
+.Os groff test suite
+.Sh Authors
+.An -nosplit
+The
+.Nm mandoc
+utility was written by
+.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
+and is maintained by
+.An Ingo Schwarze Aq Mt schwarze@openbsd.org .'
+
+output=$(echo "$input" | "$groff" -Tascii -P-cbou -mdoc)
+
+echo "$output" \
+ | grep -Fq 'written by Kristaps Dzonsons <kristaps@bsd.lv>'
+
+echo "$output" \
+ | grep -Fq 'is maintained by Ingo Schwarze <schwarze@openbsd.org>.'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_Nm-works.sh b/tmac/tests/doc_Nm-works.sh
new file mode 100755
index 0000000..a27e931
--- /dev/null
+++ b/tmac/tests/doc_Nm-works.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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 `Nm` macro (and regression-test Savannah #63377).
+
+input='.Dd 2022-11-17
+.Dt foo 1
+.Os "groff test suite"
+.Sh Name
+.Nm foo
+.Nd frobnicate a bar
+.Sh Description
+.Nm
+is a program.'
+
+echo "checking Nm's interpolation of text after initial call" >&2
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output"
+echo "$output" | grep -q 'foo is a program\.' || wail
+
+# Handle multiple declarations in "Name" section.
+
+input='.Dd 2022-11-17
+.Dt trig.h 3
+.Os "groff test suite"
+.Sh Name
+.Nm sin ,
+.Nm cos ,
+.Nm tan
+.Nd trigonometric functions
+.Sh Description
+.Nm
+returns the sine of its argument,
+an angle
+.Ms theta .'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output"
+
+echo "checking Nm behavior when called multiple times (Name)" >&2
+echo "$output" | grep -q 'sin, cos, tan -- trigonometric' || wail
+
+echo "checking Nm behavior when called multiple times (Description)" >&2
+echo "$output" | grep -q 'sin returns the sine' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_P-register-works.sh b/tmac/tests/doc_P-register-works.sh
new file mode 100755
index 0000000..a3fe817
--- /dev/null
+++ b/tmac/tests/doc_P-register-works.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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='.Dd 2022-12-11
+.Dt foo 1
+.Os "groff test suite"
+.Sh Name
+.Nm foo
+.Nd frobnicate a bar
+.bp
+.Sh Description
+It took a while to get here.'
+
+output=$(printf "%s\n" "$input" | "$groff" -rcR=0 -rP13 -mdoc -Tascii \
+ -P-cbou)
+echo "$output"
+
+echo "checking first page footer" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +13$" \
+ | grep '^64:' || wail
+
+echo "checking second page footer" >&2
+echo "$output" | grep -En "^groff test suite +2022-12-11 +14$" \
+ | grep '^130:' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_X-register-works.sh b/tmac/tests/doc_X-register-works.sh
new file mode 100755
index 0000000..d09d93b
--- /dev/null
+++ b/tmac/tests/doc_X-register-works.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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
+}
+
+# Ensure the X register takes effect on the right page and looks right.
+
+input='.Dd 2022-12-14
+.Dt foo 1
+.Os "groff foo test suite"
+.Dd 2022-12-14
+.Dt bar 1
+.Os "groff bar test suite"'
+
+output=$(printf "%s\n" "$input" \
+ | "$groff" -Tascii -P-cbou -rcR=0 -rC1 -rX1 -mdoc)
+echo "$output"
+
+echo "checking first page footer" >&2
+echo "$output" | grep -Eqx 'groff foo test suite +2022-12-14 +1' || wail
+
+echo "checking second page footer" >&2
+echo "$output" | grep -Eqx 'groff bar test suite +2022-12-14 +1a' \
+ || wail
+
+# XXX: mdoc output does not yet suppress headers and footers.
+#
+#input='.Dd 2022-12-14
+#.Dt baz 1
+#.Os "groff baz test suite"
+#.Sh Name
+#.Nm baz
+#.Nd what you will not hear at the Mos Eisley spaceport cantina
+#.Sh Description
+#This program is a fifth wheel.'
+#
+#output=$(printf "%s\n" "$input" \
+# | "$groff" -Thtml -rcR=0 -rC1 -rX1 -mdoc)
+#echo "$output"
+#
+#echo "checking for absence of footer text in HTML output" >&2
+#echo "$OUTPUT" | grep -q 'groff baz test suite' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_accept-mixed-case-section-headings.sh b/tmac/tests/doc_accept-mixed-case-section-headings.sh
new file mode 100755
index 0000000..a38afd6
--- /dev/null
+++ b/tmac/tests/doc_accept-mixed-case-section-headings.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Ensure we recognize mixed-case section headings ("Name" as well as
+# "NAME").
+
+EXAMPLE='\
+.Dd September 14, 2020
+.Dt mdoc\-test 7
+.Os
+.Sh Name
+.Nm mdoc\-test
+.Nd a smoke test for groff'"'"'s mdoc implementation
+.Sh Description
+This page has mixed-case section headings.
+.Pp
+This paragraph works around Savannah #59106.
+.Dd September 14, 2020
+.Dt mdoc\-test 7
+.Os
+.Sh NAME
+.Nm mdoc\-test
+.Nd a smoke test for groff'"'"'s mdoc implementation
+.Sh DESCRIPTION
+This page has fully-capitalized section headings.\
+'
+
+OUTPUT=$(printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -mdoc)
+FAIL=
+
+if [ -z "$(echo "$OUTPUT" | sed -n '/Name/{N;/smoke/p;}')" ]
+then
+ FAIL=yes
+ echo "section \"Name\" check failed" >&2
+fi
+
+if [ -z "$(echo "$OUTPUT" | sed -n '/Description/{N;/mixed-case/p;}')" ]
+then
+ FAIL=yes
+ echo "section \"Description\" check failed" >&2
+fi
+
+if [ -z "$(echo "$OUTPUT" | sed -n '/NAME/{N;/smoke/p;}')" ]
+then
+ FAIL=yes
+ echo "section \"NAME\" check failed" >&2
+fi
+
+if [ -z "$(echo "$OUTPUT" | sed -n '/DESCRIPTION/{N;/fully-cap/p;}')" ]
+then
+ FAIL=yes
+ echo "section \"DESCRIPTION\" check failed" >&2
+fi
+
+test -z "$FAIL"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_do-not-loop-infinitely-when-shortening-headers.sh b/tmac/tests/doc_do-not-loop-infinitely-when-shortening-headers.sh
new file mode 100755
index 0000000..6d06f0d
--- /dev/null
+++ b/tmac/tests/doc_do-not-loop-infinitely-when-shortening-headers.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+DOCUMENT=\
+'.Dd 2020-11-17
+.Dt ftp 1
+.Os "groff test suite"
+.Sh Name
+.Nm ftp
+.Nd transfer files insecurely'
+
+# Regression-test Debian #411227.
+#
+# Don't loop infinitely when trying to shorten page header and we can't
+# shrink it any further.
+
+echo "$DOCUMENT" | "$groff" -z -rLT=35n -Tascii -P-cbou -mdoc
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_heading-font-remapping-works.sh b/tmac/tests/doc_heading-font-remapping-works.sh
new file mode 100755
index 0000000..27f5196
--- /dev/null
+++ b/tmac/tests/doc_heading-font-remapping-works.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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
+}
+
+# Ensure that italics in a section heading get remapped to bold italics
+# (if the heading font is bold).
+
+input='.Dd 2022-12-26
+.Dt foo 1
+.Os "groff test suite"
+.Sh Name
+.Nm foo
+.Nd frobnicate a bar
+.Sh Hacking Xr groff
+Have fun!'
+
+output=$(printf "%s\n" "$input" | "$groff" -mdoc -Tascii -Z)
+echo "$output"
+
+echo "$output" | sed -n '/tHacking/{n
+/x font 4 BI/{n
+/f4/{n
+/h/{n
+/tgroff/{n
+/n/{n
+/f1/p;}
+}
+}
+}
+}
+}' | grep -Fqx f1
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_indents-correctly.sh b/tmac/tests/doc_indents-correctly.sh
new file mode 100755
index 0000000..216e9c2
--- /dev/null
+++ b/tmac/tests/doc_indents-correctly.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Debian #1022179.
+#
+# Ensure that subsection headings are indent correctly even if they
+# break across output lines.
+
+input='.Dd 2022-10-28
+.Dt foo 1
+.Os
+.Sh "A long section heading that wraps to illustrate the fact that the\
+ indentation of said title is consistent even if it breaks across lines"
+Discussion should be indented as ordinary paragraph.
+.Ss "A long subsection heading that wraps to illustrate the fact that\
+ the indentation of said title is consistent even if it breaks across\
+ lines"
+Further discussion should be indented as ordinary paragraph.'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc)
+fail=
+
+# Verify that default `Sh` indentation is zero.
+if ! echo "$output" | grep -Eq '^A +long +section +heading'
+then
+ fail=yes
+ echo "default 'Sh' indentation check failed on 1st line" >&2
+fi
+
+if ! echo "$output" | grep -Eq '^of said title is consistent'
+then
+ fail=yes
+ echo "default 'Sh' indentation check failed on 2nd line" >&2
+fi
+
+# Verify that paragraph indentation after section heading is correct.
+# 7 spaces in string literal.
+if ! echo "$output" | grep -Eq '^ Discussion should be indented'
+then
+ fail=yes
+ echo "'Pp' indentation after 'Sh' check failed" >&2
+fi
+
+# Verify that default `Ss` indentation is three ens.
+# 3 spaces in string literal.
+if ! echo "$output" | grep -Eq '^ A +long +subsection +heading'
+then
+ fail=yes
+ echo "default 'Ss' indentation check failed on 1st line" >&2
+fi
+
+# 3 spaces in string literal.
+if ! echo "$output" | grep -Eq '^ indentation of said title is'
+then
+ fail=yes
+ echo "default 'Ss' indentation check failed on 2nd line" >&2
+fi
+
+# Verify that paragraph indentation after subsection heading is correct.
+# 7 spaces in string literal.
+if ! echo "$output" | grep -Eq '^ Further discussion should be'
+then
+ fail=yes
+ echo "'Pp' indentation after 'Ss' check failed" >&2
+fi
+
+test -z "$fail"
+exit
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_output-footer-when-continuously-rendering.sh b/tmac/tests/doc_output-footer-when-continuously-rendering.sh
new file mode 100755
index 0000000..3303071
--- /dev/null
+++ b/tmac/tests/doc_output-footer-when-continuously-rendering.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Ensure that the page footer is printed even when a pending output line
+# is 1v from the page bottom. (A page ejection inside an end of input
+# trap exits the formatter.)
+
+input='.Dd 2022-11-02
+.Dt foo 1
+.Os "groff test suite"
+.Sh Name
+.Nm foo
+.Nd frobnicate a bar
+.Sh Description
+.rs
+.sp 60v
+line 61
+.br
+line 62'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output" | grep -Eqx 'groff test suite +2022-11-02 +foo\(1\)'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_smoke-test.sh b/tmac/tests/doc_smoke-test.sh
new file mode 100755
index 0000000..09d1ad0
--- /dev/null
+++ b/tmac/tests/doc_smoke-test.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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
+}
+
+# Regression-test Savannah #51003.
+#
+# Ensure we can render mdoc man pages from a build tree.
+
+input='.Dd August 25, 2020
+.Dt mdoc\-test 7
+.Os
+.Sh Name
+.Nm mdoc\-test
+.Nd a smoke test for groff'"'"'s mdoc implementation
+.Sh Description
+If you can read this without a hailstorm of warnings,
+things are probably working.'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output"
+fail=
+
+echo "checking header for correct content" >&2
+echo "$output" | grep -qE '^mdoc-test\(7\) +Miscellaneous' || wail
+
+echo "checking for section heading \"Name\"" >&2
+echo "$output" | grep -qE '^Name$' || wail
+
+echo "checking for section heading \"Description\"" >&2
+echo "$output" | grep -qE '^Description$' || wail
+
+echo "checking paragraph body for correct content" >&2
+echo "$output" | grep -qE 'you can read this' || wail
+
+echo "checking footer for correct content" >&2
+echo "$output" | grep -qE '^GNU +August 25, 2020 +mdoc-test\(7\)' \
+ || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/e_chapter-titles-work.sh b/tmac/tests/e_chapter-titles-work.sh
new file mode 100755
index 0000000..3c7c6c1
--- /dev/null
+++ b/tmac/tests/e_chapter-titles-work.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Ensure that chapter (and appendix) titles aren't broken by
+# localization rigamarole.
+
+input='.de $C
+. tm $C: \\$@
+..
+.++ C
+.+c "The Boy Sickens"
+.+c "The Boy Dies"
+.++ A
+.+c "Pathology of Boy Aged 11 Years"'
+
+fail=
+
+wail () {
+ echo "...FAILED" >&2
+ fail=YES
+}
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -me 2>&1)
+
+echo "checking for correct arguments given to \$C hook macro (1)" >&2
+echo "$output" | grep -Fqx '$C: "Chapter" "1" "The Boy Sickens"' || wail
+
+# Ensure that the chapter number got incremented.
+echo "checking for correct arguments given to \$C hook macro (2)" >&2
+echo "$output" | grep -Fqx '$C: "Chapter" "2" "The Boy Dies"' || wail
+
+# Ensure that an appendix chapter uses uppercase alphabetical numbers.
+echo "checking for correct arguments given to \$C hook macro (3)" >&2
+echo "$output" \
+ | grep -Fqx '$C: "Appendix" "A" "Pathology of Boy Aged 11 Years"' \
+ || wail
+
+echo "checking formatted chapter heading output (1)" >&2
+echo "$output" | grep -Fq "Chapter 1" || wail
+
+echo "checking formatted chapter heading output (2)" >&2
+echo "$output" | grep -Fq "Chapter 2" || wail
+
+echo "checking formatted appendix heading output" >&2
+echo "$output" | grep -Fq "Appendix A" || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/e_columns-work-on-long-pages.sh b/tmac/tests/e_columns-work-on-long-pages.sh
new file mode 100755
index 0000000..2ee9144
--- /dev/null
+++ b/tmac/tests/e_columns-work-on-long-pages.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #55081.
+#
+# Ensure that long page lengths don't break columnation.
+
+EXAMPLE=\
+'.pl 159v
+.2c
+Column 1.
+.bc
+Column 2.'
+
+echo "$EXAMPLE" \
+ | "$groff" -Tascii -P-cbou -me \
+ | grep -Eqx 'Column 1\. +Column 2\.'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/e_delayed-text-marks-work.sh b/tmac/tests/e_delayed-text-marks-work.sh
new file mode 100755
index 0000000..71845ad
--- /dev/null
+++ b/tmac/tests/e_delayed-text-marks-work.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+set -e
+
+# Ensure that delayed text marks increment and reset as they should.
+
+input='.pp
+paragraph 1
+.(d
+\*# foo
+.)d
+.(d
+\*# bar
+.)d
+.pd
+.(d
+\*# baz
+.)d
+.pp
+paragraph 2
+.(d
+\*# qux
+.)d
+.pd
+.pp
+paragraph 3'
+
+output=$(echo "$input" | "$groff" -Tascii -P-cbou -me)
+
+echo "$output" | grep -Fx '[1] foo'
+echo "$output" | grep -Fx '[2] bar'
+echo "$output" | grep -Fx '[1] baz'
+echo "$output" | grep -Fx '[2] qux'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/e_footnote-marks-work.sh b/tmac/tests/e_footnote-marks-work.sh
new file mode 100755
index 0000000..38f1d9f
--- /dev/null
+++ b/tmac/tests/e_footnote-marks-work.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+set -e
+
+# Ensure that footnote marks increment as they should.
+
+input='.pp
+Jackdaws*
+.(f
+* foo
+.)f
+love my big\**
+.(f
+\** bar
+.)f
+sphinx**
+.(f
+** baz
+.)f
+of quartz.\**
+.(f
+\** qux
+.)f
+.+c
+.pp
+Pack my box with five dozen liquor jugs.\**
+.(f
+\** ogg
+.)f'
+
+output=$(echo "$input" | "$groff" -Tascii -P-cbou -me)
+
+echo "$output" \
+ | grep -F 'Jackdaws* love my big[1] sphinx** of quartz.[2]'
+
+echo "$output" \
+ | grep -F '* foo'
+
+echo "$output" \
+ | grep -F '[1] bar'
+
+echo "$output" \
+ | grep -F '** baz'
+
+echo "$output" \
+ | grep -F '[2] qux'
+
+echo "$output" \
+ | grep -F 'Pack my box with five dozen liquor jugs.[1]'
+
+echo "$output" \
+ | grep -F '[1] ogg'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/e_footnotes-work-with-columns.sh b/tmac/tests/e_footnotes-work-with-columns.sh
new file mode 100755
index 0000000..fbf3238
--- /dev/null
+++ b/tmac/tests/e_footnotes-work-with-columns.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #58736.
+#
+# Returning to single columnation shouldn't break if footnotes are used.
+
+EXAMPLE=\
+'foo
+.(f
+footnote
+.)f
+.2c
+bar
+.bc
+baz
+.1c
+qux'
+
+test -n "$(echo "$EXAMPLE" \
+ | "$groff" -Tascii -P-cbou -me \
+ | sed -n '/foo/{N;/bar *baz/{N;/qux/p;};}')"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/e_ld-works.sh b/tmac/tests/e_ld-works.sh
new file mode 100755
index 0000000..1c315a8
--- /dev/null
+++ b/tmac/tests/e_ld-works.sh
@@ -0,0 +1,131 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Test the `ld` macro.
+
+input='.nr yr 108
+.nr mo 12
+.nr dy 15
+.nr dw 2
+.ld
+.++ C
+.+c "Fleeing the Impoverished, Drunken Countryside for Dublin"
+.pp
+The day was \*(dw, \*(td.
+.++ A
+.+c "How to Write for The Toast"
+.pp
+Submit it on spec.'
+
+fail=
+
+wail () {
+ echo "...FAILED" >&2
+ fail=YES
+}
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -me)
+output_cs=$(printf "%s\n" "$input" | "$groff" -Tutf8 -P-cbou -me -mcs)
+output_de=$(printf "%s\n" "$input" | "$groff" -Tutf8 -P-cbou -me -mde)
+output_fr=$(printf "%s\n" "$input" | "$groff" -Tutf8 -P-cbou -me -mfr)
+output_it=$(printf "%s\n" "$input" | "$groff" -Tutf8 -P-cbou -me -mit)
+output_sv=$(printf "%s\n" "$input" | "$groff" -Tutf8 -P-cbou -me -msv)
+
+echo 'checking that `td` string updated correctly for English' >&2
+echo "$output" | grep -q 'The day was Monday, December 15, 2008\.$' \
+ || wail
+
+echo 'checking for correct English "Chapter" string' >&2
+echo "$output" | grep -Eqx ' +Chapter 1' || wail
+
+echo 'checking for correct English "Appendix" string' >&2
+echo "$output" | grep -Eqx ' +Appendix A' || wail
+
+# POSIX grep (as of Issue 7) does not provide any locale-independent
+# mechanism for matching 8-bit characters--they do not even match "any"
+# character ('.'). When checking the date strings, we therefore skip
+# them. (Fortunately, at present, none of the translations of "Chapter"
+# or "Appendix" require non-Basic Latin letters.)
+
+# Czech localization
+echo 'checking that `td` string updated correctly for Czech (1)' >&2
+echo "$output_cs" | grep -q 'The day was Pond' || wail
+
+echo 'checking that `td` string updated correctly for Czech (2)' >&2
+echo "$output_cs" | grep -q ', 15 Prosinec 2008\.$' || wail
+
+echo 'checking for correct Czech "Chapter" string' >&2
+echo "$output_cs" | grep -Eqx ' +Kapitola 1' || wail
+
+echo 'checking for correct Czech "Appendix" string' >&2
+echo "$output_cs" | grep -Eqx ' +Dodatek A' || wail
+
+# German localization
+echo 'checking that `td` string updated correctly for German' >&2
+echo "$output_de" \
+ | grep -q 'The day was Montag, 15\. Dezember\. 2008\.$' || wail
+
+echo 'checking for correct German "Chapter" string' >&2
+echo "$output_de" | grep -Eqx ' +Kapitel 1' || wail
+
+echo 'checking for correct German "Appendix" string' >&2
+echo "$output_de" | grep -Eqx ' +Anhang A' || wail
+
+# French localization
+echo 'checking that `td` string updated correctly for French (1)' >&2
+echo "$output_fr" | grep -q 'The day was Lundi, 15 D'
+
+echo 'checking that `td` string updated correctly for French (2)' >&2
+echo "$output_fr" | grep -q 'cembre 2008\.$' || wail
+
+echo 'checking for correct French "Chapter" string' >&2
+echo "$output_fr" | grep -Eqx ' +Chapitre 1' || wail
+
+echo 'checking for correct French "Appendix" string' >&2
+echo "$output_fr" | grep -Eqx ' +Annexe A' || wail
+
+# Italian localization
+echo 'checking that `td` string updated correctly for Italian' >&2
+echo "$output_it" | grep -q 'The day was Lunedì, 15 Dicembre 2008\.$'
+
+echo 'checking for correct Italian "Chapter" string' >&2
+echo "$output_it" | grep -Eqx ' +Capitolo 1' || wail
+
+echo 'checking for correct Italian "Appendix" string' >&2
+echo "$output_it" | grep -Eqx ' +Appendice A' || wail
+
+# Swedish localization
+echo 'checking that `td` string updated correctly for Swedish (1)' >&2
+echo "$output_sv" | grep -q 'The day was m'
+
+echo 'checking that `td` string updated correctly for Swedish (2)' >&2
+echo "$output_sv" | grep -q 'ndag, 15 december 2008\.$' || wail
+
+echo 'checking for correct Swedish "Chapter" string' >&2
+echo "$output_sv" | grep -Eqx ' +Kapitel 1' || wail
+
+echo 'checking for correct Swedish "Appendix" string' >&2
+echo "$output_sv" | grep -Eqx ' +Bilaga A' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/e_line-numbering-works.sh b/tmac/tests/e_line-numbering-works.sh
new file mode 100755
index 0000000..427840e
--- /dev/null
+++ b/tmac/tests/e_line-numbering-works.sh
@@ -0,0 +1,141 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Test the line numbering feature.
+
+input='.nr pp 18 \\" to make troff output consistent with nroff
+.if r mypo .po \\n[mypo]u
+.if !d C .ds C\\" empty
+.pp
+Feck, vex loping bad jazz: quench my thirst.
+Feck, vex loping bad jazz: quench my thirst.
+.pp
+.n1 \\*C
+Jackdaws love my big sphinx of quartz.
+Jackdaws love my big sphinx of quartz.
+Jackdaws love my big sphinx of quartz.
+.pp
+How vexingly quick daft zebras jump!
+.pp
+.n2 +6
+Waltz, bad nymph, for quick jigs vex.
+Waltz, bad nymph, for quick jigs vex.
+.pp
+.n2 99
+Pack my box with five dozen liquor jugs.
+Pack my box with five dozen liquor jugs.
+Pack my box with five dozen liquor jugs.
+.pp
+.n2
+The five boxing wizards jump quickly.
+The five boxing wizards jump quickly.'
+
+fail=
+
+wail () {
+ echo "...FAILED" >&2
+ fail=YES
+}
+
+echo '*** basic output (line number field prepended)' >&2
+output=$(echo "$input" | "$groff" -Tascii -P-cbou -me)
+
+echo "$output"
+
+# We expect the foregoing to produce a me(7) diagnostic complaining of a
+# negative page offset but we're not testing for that.
+
+echo 'checking for 0 page offset and 5n paragraph indentation (1)' >&2
+echo "$output" | grep -q '^ Feck.*vex$' || wail # 5 spaces
+
+# troff uses backspaces to emit the line number, so we can't anchor the
+# matches to the beginning of the line with '^'.
+
+# These patterns have 6 embedded spaces until further notice.
+echo 'checking for line number field plus 60n line length' >&2
+echo "$output" | grep -q '1 Jackdaws.*love$' || wail
+
+echo 'checking for non-numbering of blank lines' >&2
+echo "$output" | grep -q '4 How.*jump!$' || wail
+
+echo 'checking offset-advanced two-digit line number' >&2
+echo "$output" | grep -q '^10 Waltz,.*bad nymph$'
+
+echo 'checking three-digit line number' >&2
+echo "$output" | grep -q '^100 with.*dozen$'
+
+echo 'checking for 0 page offset and 5n paragraph indentation (2)' >&2
+echo "$output" | grep -q '^ The.*boxing$' || wail # 5 spaces
+
+echo '*** roff(1)-compatible output (shorter line length)' >&2
+output=$(echo "$input" | "$groff" -dCC -Tascii -P-cbou -me)
+
+echo "$output"
+
+echo 'checking for 0 page offset and 5n paragraph indentation (1)' >&2
+echo "$output" | grep -q '^ Feck.*vex' || wail # 5 spaces
+
+echo 'checking for line number field plus 56n line length' >&2
+echo "$output" \
+ | grep -q ' 1 Jackdaws.*Jackdaws$' || wail # 2, then 6 spaces
+
+# These patterns have 6 embedded spaces until further notice.
+echo 'checking for non-numbering of blank lines' >&2
+echo "$output" | grep -q '4 How.*jump!$' || wail
+
+echo 'checking offset-advanced two-digit line number' >&2
+echo "$output" | grep -q ' 10 Waltz,.*bad$' || wail
+
+echo 'checking three-digit line number' >&2
+echo "$output" | grep -q '^100 box.*dozen$'
+
+echo 'checking for 0 page offset and 5n paragraph indentation (2)' >&2
+echo "$output" | grep -q '^ The.*boxing$' || wail # 5 spaces
+
+echo '*** output with 4n page offset' >&2
+output=$(echo "$input" | "$groff" -rmypo=4n -Tascii -P-cbou -me)
+
+echo "$output"
+
+echo 'checking for 4n page offset and 5n paragraph indentation (1)' >&2
+echo "$output" | grep -q '^ Feck.*vex' || wail # 9 spaces
+
+echo 'checking for line number field plus 60n line length' >&2
+echo "$output" \
+ | grep -q ' 1 Jackdaws.*love$' || wail # 2, then 6 spaces
+
+# These patterns have 6 embedded spaces until further notice.
+echo 'checking for non-numbering of blank lines' >&2
+echo "$output" | grep -q '4 How.*jump!$' || wail
+
+echo 'checking offset-advanced two-digit line number' >&2
+echo "$output" | grep -q ' 10 Waltz,.*bad$' || wail
+
+echo 'checking three-digit line number' >&2
+echo "$output" | grep -q '^100 box.*dozen$'
+
+echo 'checking for 4n page offset and 5n paragraph indentation (2)' >&2
+echo "$output" | grep -q '^ The.*boxing$' || wail # 9 spaces
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/e_rejects-too-short-page-lengths.sh b/tmac/tests/e_rejects-too-short-page-lengths.sh
new file mode 100755
index 0000000..526f640
--- /dev/null
+++ b/tmac/tests/e_rejects-too-short-page-lengths.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Page lengths that are too short cause loss of header/footer text and
+# infinite trap recursion in extreme cases.
+#
+# As of the time of this writing, bad behavior (a superfluous page
+# break) sets in at 14v, and we start to lose headers/footers at a
+# length of 13v. Get down to 7v and the traps infinitely recurse.
+
+input='.pl 7v
+.he "A"B"C"
+.fo "D"E"F"
+.lp
+foobar
+'
+
+fail=
+
+wail () {
+ echo "...FAILED" >&2
+ fail=YES
+}
+
+output=$(printf '%s\n' "$input" | "$groff" -Tascii -P-cbou -me 2>&1)
+status=$?
+
+echo "checking for nonzero exit status" >&2
+test $status -ne 0 || wail
+
+# grepping diagnostic messages is a tar pit. I hope I don't come to
+# regret this.
+
+echo "checking for lack of diagnostic about infinite loop" >&2
+echo "$output" | grep -q 'troff.*fatal.*infinite' && wail
+
+echo "checking for diagnostic about page length" >&2
+echo "$output" | grep -q 'e\.tmac.*page length' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/ec_works.sh b/tmac/tests/ec_works.sh
new file mode 100755
index 0000000..42ce59b
--- /dev/null
+++ b/tmac/tests/ec_works.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Verify that the EC fonts get loaded by using their Euro and per mille
+# glyphs (which aren't in the CM fonts) to detect them.
+input='.ec @
+.de EM
+. ft @@$1
+. nop @[Eu] @[%0]
+..
+.nf
+.EM TR
+.EM TI
+.EM TB
+.EM TBI
+.EM HR
+.EM HI
+.EM HB
+.EM HBI
+.EM CW
+.EM CWI'
+
+output=$(printf "%s\n" "$input" | "$groff" -mec -Tdvi -z 2>&1)
+test -z "$output"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/latin2_works.sh b/tmac/tests/latin2_works.sh
new file mode 100755
index 0000000..9cadf55
--- /dev/null
+++ b/tmac/tests/latin2_works.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# Copyright (C) 2022-2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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
+}
+
+input=$(\
+ printf '\\[A ho]\\[ab]\\[/L]\\[S aa]';
+ printf '\\[vS]\\[S ac]\\[T ah]\\[Z aa]\\[vZ]\\[Z a.]\n';
+ printf '\\[a ho]\\[ho]\\[/l]\\[s aa]';
+ printf '\\[vs]\\[s ac]\\[t ah]\\[z aa]\\[a"]\\[vZ]\\[z a.]\n';
+ printf '\\[R aa]\\[A ab]\\[L aa]\\[C aa]';
+ printf '\\[C ah]\\[E ho]\\[E ah]\\[D ah]\n';
+ printf '\\[u0110]\\[N aa]\\[N ah]\\[O a"]';
+ printf '\\[R ah]\\[U ao]\\[U a"]\\[T ac]\n';
+ printf '\\[r aa]\\[a ab]\\[l aa]\\[c aa]';
+ printf '\\[c ah]\\[e ho]\\[e ah]\\[d ah]\n';
+ printf '\\[u0111]\\[n aa]\\[n ah]\\[o a"]';
+ printf '\\[r ah]\\[u ao]\\[u a"]\\[t ac]\\[a.]\n';
+)
+
+output=$(printf "%s\n" "$input" | "$groff" -Tlatin1 -mlatin2 \
+ | LC_ALL=C od -t o1)
+printf "%s\n" "$output"
+printf "$output" \
+ | grep -Eq '^0000000 +241 242 243 246 251 252 253 254 256 257 +' \
+ || wail "in block 0xA0"
+printf "$output" \
+ | grep -Eq '^0000000 +.* 261 262 263 266 271$' \
+ || wail "in block 0xB0 (address 0..017)"
+printf "$output" \
+ | grep -Eq '^0000020 +272 273 274 275 256 277 +' \
+ || wail "in block 0xB0 (address 020..037)"
+printf "$output" \
+ | grep -Eq '^0000020 +.* 300 303 305 306 310 312 314 317 040$' \
+ || wail "in block 0xC0"
+printf "$output" \
+ | grep -Eq '^0000040 +320 321 322 325 330 331 333 336 +' \
+ || wail "in block 0xD0"
+printf "$output" \
+ | grep -Eq '^0000040 +.* 340 343 345 346 350 352 354$' \
+ || wail "in block 0xE0 (address 040..057)"
+printf "$output" \
+ | grep -Eq '^0000060 +357 +' \
+ || wail "in block 0xE0 (address 060..077)"
+printf "$output" \
+ | grep -Eq \
+ '^0000060 +.* 360 361 362 365 370 371 373 376 377( 012)+$' \
+ || wail "in block 0xF0"
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/latin5_works.sh b/tmac/tests/latin5_works.sh
new file mode 100755
index 0000000..62e1c11
--- /dev/null
+++ b/tmac/tests/latin5_works.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Copyright (C) 2022-2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+input=$(printf '\\[G ab]\\[g ab]\\[u0130]\\[.i]\\[S ac]\\[s ac]')
+output=$(printf "%s\n" "$input" | "$groff" -Tlatin1 -mlatin5 \
+ | LC_ALL=C od -t o1)
+printf "%s\n" "$output"
+printf "$output" \
+ | grep -Eq '^0000000 +320 360 335 375 336 376 +'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/latin9_works.sh b/tmac/tests/latin9_works.sh
new file mode 100755
index 0000000..ca5e23b
--- /dev/null
+++ b/tmac/tests/latin9_works.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Copyright (C) 2022-2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+input=$(printf '\\[Eu]\\[vS]\\[vs]\\[vZ]\\[vz]\\[OE]\\[oe]\\[:Y]\n')
+output=$(printf "%s\n" "$input" | "$groff" -Tlatin1 -mlatin9 \
+ | LC_ALL=C od -t o1)
+printf "%s\n" "$output"
+printf "$output" \
+ | grep -Eq '^0000000 +244 246 250 264 270 274 275 276 +'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/localization-works.sh b/tmac/tests/localization-works.sh
new file mode 100755
index 0000000..d807018
--- /dev/null
+++ b/tmac/tests/localization-works.sh
@@ -0,0 +1,189 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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='.tm .hy=\n[.hy]'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mcs 2>&1)
+echo 'checking raw troff with -mcs' >&2
+echo "$output" | grep -Fqx '.hy=1' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mde 2>&1)
+echo 'checking raw troff with -mde' >&2
+echo "$output" | grep -Fqx '.hy=1' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -men 2>&1)
+echo 'checking raw troff with -men' >&2
+echo "$output" | grep -Fqx '.hy=4' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mfr 2>&1)
+echo 'checking raw troff with -mfr' >&2
+echo "$output" | grep -Fqx '.hy=4' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mit 2>&1)
+echo 'checking raw troff with -mit' >&2
+echo "$output" | grep -Fqx '.hy=1' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -msv 2>&1)
+echo 'checking raw troff with -msv' >&2
+echo "$output" | grep -Fqx '.hy=32' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -me -mcs 2>&1)
+echo 'checking -me with -mcs' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -me -mde 2>&1)
+echo 'checking -me with -mde' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -me -men 2>&1)
+echo 'checking -me with -men' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -me -mfr 2>&1)
+echo 'checking -me with -mfr' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -me -mit 2>&1)
+echo 'checking -me with -mit' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -me -msv 2>&1)
+echo 'checking -me with -msv' >&2
+echo "$output" | grep -Fqx '.hy=34' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -ms -mcs 2>&1)
+echo 'checking -ms with -mcs' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -ms -mde 2>&1)
+echo 'checking -ms with -mde' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -ms -men 2>&1)
+echo 'checking -ms with -men' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -ms -mfr 2>&1)
+echo 'checking -ms with -mfr' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -ms -mit 2>&1)
+echo 'checking -ms with -mit' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -ms -msv 2>&1)
+echo 'checking -ms with -msv' >&2
+echo "$output" | grep -Fqx '.hy=34' || wail
+
+input='.TH foo 1 2022-01-06 "groff test suite"
+.tm .hy=\n[.hy]'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=0 -man -mcs 2>&1)
+echo 'checking -man with -rcR=0 -mcs' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=0 -man -mde 2>&1)
+echo 'checking -man with -rcR=0 -mde' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=0 -man -men 2>&1)
+echo 'checking -man with -rcR=0 -men' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=0 -man -mfr 2>&1)
+echo 'checking -man with -rcR=0 -mfr' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=0 -man -mit 2>&1)
+echo 'checking -man with -rcR=0 -mit' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=0 -man -msv 2>&1)
+echo 'checking -man with -rcR=0 -msv' >&2
+echo "$output" | grep -Fqx '.hy=34' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=1 -man -mcs 2>&1)
+echo 'checking -man with -rcR=1 -mcs' >&2
+echo "$output" | grep -Fqx '.hy=1' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=1 -man -mde 2>&1)
+echo 'checking -man with -rcR=1 -mde' >&2
+echo "$output" | grep -Fqx '.hy=1' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=1 -man -men 2>&1)
+echo 'checking -man with -rcR=1 -men' >&2
+echo "$output" | grep -Fqx '.hy=4' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=1 -man -mfr 2>&1)
+echo 'checking -man with -rcR=1 -mfr' >&2
+echo "$output" | grep -Fqx '.hy=4' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=1 -man -mit 2>&1)
+echo 'checking -man with -rcR=1 -mit' >&2
+echo "$output" | grep -Fqx '.hy=1' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=1 -man -msv 2>&1)
+echo 'checking -man with -rcR=1 -msv' >&2
+echo "$output" | grep -Fqx '.hy=32' || wail
+
+# Ensure that the 'trap bit' (hyphenation value 2, which has nothing to
+# do with any language) is preserved when switching locales back from a
+# CJK language, since those languages' modes unconditionally clear it.
+
+input='.TH foo 1 2022-04-09 "groff test suite"
+.SH 名前
+foo \- APT 用選択制御ファイル
+.mso en.tmac
+.TH bar 1 2022-04-09 "groff test suite"
+.SH Name
+bar \- three subjects walk into this
+.tm .hy=\n[.hy]'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=0 -man -mja \
+ -men 2>&1)
+echo 'checking -man with -rcR=0 -mja -men' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+input='.TH foo 1 2022-04-09 "groff test suite"
+.SH 名称
+foo \- 解析 man 手册页的头部信息
+.mso en.tmac
+.TH bar 1 2022-04-09 "groff test suite"
+.SH Name
+bar \- three subjects walk into this
+.tm .hy=\n[.hy]'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -rcR=0 -man -mzh \
+ -men 2>&1)
+echo 'checking -man with -rcR=0 -mzh -men' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/pdfpic_does-not-choke-on-bad-pdfinfo-output.sh b/tmac/tests/pdfpic_does-not-choke-on-bad-pdfinfo-output.sh
new file mode 100755
index 0000000..7e58849
--- /dev/null
+++ b/tmac/tests/pdfpic_does-not-choke-on-bad-pdfinfo-output.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+# Give the output a name that won't collide with another test.
+gnu_pdf="${abs_top_builddir:-.}/doc/gnu-no-choke-on-pdfinfo.pdf"
+
+# Regression-test Savannah #58206.
+
+# We need gs(1) and pdfpic.tmac needs pdfinfo(1).
+for cmd in gs pdfinfo
+do
+ if ! command -v $cmd >/dev/null
+ then
+ echo "cannot locate '$cmd' command" >&2
+ exit 77 # skip
+ fi
+done
+
+# Locate directory containing our test artifacts.
+artifact_dir=
+
+for buildroot in . .. ../..
+do
+ d=$buildroot/doc
+ if [ -f $d/gnu.eps ]
+ then
+ artifact_dir=$d
+ gnu_eps=$artifact_dir/gnu.eps
+ break
+ fi
+done
+
+# If we can't find it, we can't test.
+test -z "$artifact_dir" && exit 77 # skip
+
+if [ -e "$gnu_pdf" ]
+then
+ echo "temporary output file '$gnu_pdf' already exists" >&2
+ exit 77 # skip
+fi
+
+fail=
+
+input='.am pdfpic@error
+. ab
+..
+Here is a picture of a wildebeest.
+.PDFPIC '"$gnu_pdf"
+
+if ! gs -q -o - -sDEVICE=pdfwrite -f "$gnu_eps" \
+ -c "[ /Title (\000B\000U\000S\000T\000E\000D) /DOCINFO pdfmark" \
+ > "$gnu_pdf"
+then
+ echo "gs command failed" >&2
+ rm -f "$gnu_pdf"
+ exit 77 # skip
+fi
+
+test -z "$fail" \
+ && printf '%s\n' "$input" | "$groff" -Tpdf -U -z || fail=YES
+
+rm -f "$gnu_pdf"
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/pdfpic_falls-back-to-PSPIC.sh b/tmac/tests/pdfpic_falls-back-to-PSPIC.sh
new file mode 100755
index 0000000..a77f431
--- /dev/null
+++ b/tmac/tests/pdfpic_falls-back-to-PSPIC.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+# Give the output a name that won't collide with another test.
+gnu_base="${abs_top_builddir:-.}/doc/gnu-fallback-pspic"
+gnu_fallback_eps="$gnu_base.eps"
+gnu_pdf="$gnu_base.pdf"
+
+if ! command -v gs >/dev/null
+then
+ echo "cannot locate 'gs' command" >&2
+ exit 77 # skip
+fi
+
+# Locate directory containing our test artifacts.
+artifact_dir=
+
+for buildroot in . .. ../..
+do
+ d=$buildroot/doc
+ if [ -f $d/gnu.eps ]
+ then
+ artifact_dir=$d
+ gnu_eps=$artifact_dir/gnu.eps
+ break
+ fi
+done
+
+# If we can't find it, we can't test.
+test -z "$artifact_dir" && exit 77 # skip
+
+if [ -e "$gnu_pdf" ]
+then
+ echo "temporary output file '$gnu_pdf' already exists" >&2
+ exit 77 # skip
+fi
+
+fail=
+
+input='.am pdfpic@error
+. ab
+..
+Here is a picture of a wildebeest.
+.PDFPIC '"$gnu_pdf"
+
+if ! gs -q -o - -sDEVICE=pdfwrite -f "$gnu_eps" > "$gnu_pdf"
+then
+ echo "gs command failed" >&2
+ rm -f "$gnu_fallback_eps" "$gnu_pdf"
+ exit 77 # skip
+fi
+
+test -z "$fail" \
+ && printf '%s\n' "$input" | "$groff" -Tps -U -z || fail=YES
+
+rm -f "$gnu_fallback_eps" "$gnu_pdf"
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_IP-indents-using-paragraph-type-size.sh b/tmac/tests/s_IP-indents-using-paragraph-type-size.sh
new file mode 100755
index 0000000..0973107
--- /dev/null
+++ b/tmac/tests/s_IP-indents-using-paragraph-type-size.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+export GROFF_TYPESETTER=
+
+# Regression-test Savannah #59604.
+#
+# Ensure that the indentation amount used by IP is based on the type
+# size of the _paragraph_, not a preceding heading (which might have
+# been affected by GROWPS).
+
+EXAMPLE=\
+'.nr PSINCR 3p
+.nr GROWPS 3
+.SH 1
+Text
+.IP 1. 4
+Filling
+.IP 2. 4
+Sentences'
+
+OUTPUT=$(echo "$EXAMPLE" | "$groff" -ms -Z \
+ | sed -n '/^H92000$/{
+ N
+ /\ntFilling$/{
+ p
+ b
+ }
+ }')
+test -n "$OUTPUT"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_IP-respects-inter-sentence-space-in-tags.sh b/tmac/tests/s_IP-respects-inter-sentence-space-in-tags.sh
new file mode 100755
index 0000000..70ca4d0
--- /dev/null
+++ b/tmac/tests/s_IP-respects-inter-sentence-space-in-tags.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #59742.
+#
+# Ensure that a non-default inter-sentence space setting is respected
+# inside a multi-sentence tag to an indented paragraph.
+
+EXAMPLE=\
+'.ss 12 24
+.LP
+Foo. Bar.
+.IP "Baz. Qux."
+Foo. Bar.
+'
+
+echo "$EXAMPLE" \
+ | "$groff" -Tascii -P-cbou -ms \
+ | grep -qx 'Baz\. Qux\.' # 3 spaces.
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_PN-works.sh b/tmac/tests/s_PN-works.sh
new file mode 100755
index 0000000..1c72634
--- /dev/null
+++ b/tmac/tests/s_PN-works.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #59823.
+#
+# Ensure retention of superfluous but fossilized register PN.
+
+EXAMPLE=\
+'.bp 2
+.LP
+This is page \n[PN].
+'
+
+printf "%s" "$EXAMPLE" \
+ | "$groff" -Tascii -P-cbou -ms \
+ | grep -Fqx 'This is page 2.'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_R-handles-its-arguments.sh b/tmac/tests/s_R-handles-its-arguments.sh
new file mode 100755
index 0000000..23380d9
--- /dev/null
+++ b/tmac/tests/s_R-handles-its-arguments.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #59348.
+#
+# Ensure that .R actually handles its arguments.
+
+EXAMPLE=\
+'.LP
+of the form
+.I
+.R * id\\c module
+.R
+\&.
+'
+
+# That \c's a killer. Can't use echo.
+printf "%s" "$EXAMPLE" \
+ | "$groff" -Tascii -P-cbou -ms \
+ | grep -Fqx 'of the form module*id.'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_SH-resets-IP-indentation-amount.sh b/tmac/tests/s_SH-resets-IP-indentation-amount.sh
new file mode 100755
index 0000000..71aa6c9
--- /dev/null
+++ b/tmac/tests/s_SH-resets-IP-indentation-amount.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #60222.
+#
+# SH should reset IP indentation amount as other paragraphing macros do.
+
+EXAMPLE=\
+'.IP @ 3n
+3n indentation
+.SH
+Section heading
+.IP
+default indentation
+'
+
+echo "$EXAMPLE" \
+ | "$groff" -Tascii -P-cbou -ms \
+ | grep -qx ' default indentation' # 5 spaces
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_TC-works-with-percent-in-custom-titles.sh b/tmac/tests/s_TC-works-with-percent-in-custom-titles.sh
new file mode 100755
index 0000000..6939619
--- /dev/null
+++ b/tmac/tests/s_TC-works-with-percent-in-custom-titles.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #59345.
+#
+# Ensure that .TC succeeds in assigning the 'i' format to the page
+# number register when '%' is used in a custom header or footer.
+
+EXAMPLE=\
+'.OH ##%##
+.NH 1
+Foo
+.XS
+Foo
+.XE
+.LP
+Bar.
+.TC
+'
+
+OUTPUT=$(echo "$EXAMPLE" | "$groff" -Tascii -P-cbou -ms)
+# Strip blank lines from the output first; all we care about for this
+# test is the presence, adjacency, and ordering of non-blank lines.
+FILTERED_OUTPUT=$(echo "$OUTPUT" \
+ | sed '/^$/d' \
+ | sed -n '/i/{
+N;/Table of Contents/{
+N;/Foo[. ][. ]*1/p;
+};
+}')
+test -n "$FILTERED_OUTPUT"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_XA-literal-no-argument-suppresses-leader.sh b/tmac/tests/s_XA-literal-no-argument-suppresses-leader.sh
new file mode 100755
index 0000000..a5099a1
--- /dev/null
+++ b/tmac/tests/s_XA-literal-no-argument-suppresses-leader.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #61853.
+#
+# The word "no" as the first argument to the `XA` macro should suppresss
+# not just the page number, but the leader before it as well.
+
+input='.PP
+.XS
+This is my TOC entry
+.XA no
+There are many like it
+.XE
+But this one is mine.
+.TC
+'
+
+fail=
+
+wail () {
+ echo "...FAILED" >&2
+ fail=YES
+}
+
+# Be aware of
+# <https://unix.stackexchange.com/questions/383217/\
+# shell-keep-trailing-newlines-n-in-command-substitution> when comparing
+# this to interactive output.
+output=$(printf '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms)
+
+echo "checking for presence of supplemental TOC entry" >&2
+echo "$output" | grep -q 'There are many like it' || wail
+
+echo "checking for suppressed leader in supplemental TOC entry" >&2
+echo "$output" | grep -qx 'There are many like it' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_honor-MINGW-when-two-columns.sh b/tmac/tests/s_honor-MINGW-when-two-columns.sh
new file mode 100755
index 0000000..b7e142b
--- /dev/null
+++ b/tmac/tests/s_honor-MINGW-when-two-columns.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #62687.
+
+input='.nr MINGW 5n
+.pl 16v
+.2C
+.PP
+Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
+accusantium doloremque laudantium, totam rem aperiam eaque ipsa,'
+
+output=$(printf '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms)
+echo "$output"
+
+echo "$output" | grep -Eq 'Sed +ut +perspiciatis, +unde {5}[a-z]'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_mark-column-start-correctly.sh b/tmac/tests/s_mark-column-start-correctly.sh
new file mode 100755
index 0000000..f37be3b
--- /dev/null
+++ b/tmac/tests/s_mark-column-start-correctly.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #62686.
+
+input='.pl 15v
+.2C
+.PP
+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.'
+
+output=$(printf '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms)
+echo "$output"
+
+echo "$output" | grep -Eq 'Sed +ut +perspiciatis, unde +voluptatem'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_no-excess-space-around-displays.sh b/tmac/tests/s_no-excess-space-around-displays.sh
new file mode 100755
index 0000000..a2193fe
--- /dev/null
+++ b/tmac/tests/s_no-excess-space-around-displays.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Regression-test Savannah #62688.
+
+input='.pl 19v
+.LP
+This is my first paragraph.
+.LD
+This is my block display.
+.DE
+.LP
+This is my second paragraph.'
+
+output=$(printf '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms \
+ | awk '{print NR, $0}')
+
+echo "$output" | grep -Fqx '11 This is my second paragraph.'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/s_rejects-too-short-page-lengths.sh b/tmac/tests/s_rejects-too-short-page-lengths.sh
new file mode 100755
index 0000000..3869838
--- /dev/null
+++ b/tmac/tests/s_rejects-too-short-page-lengths.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# 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"
+
+# Page lengths that are too short cause loss of header/footer text and
+# infinite trap recursion in extreme cases.
+#
+# As of the time of this writing, bad behavior (a superfluous page
+# break) sets in at 14v, and we start to lose headers/footers at a
+# length of 13v. Get down to 7v and the traps infinitely recurse.
+
+input='.pl 7v
+.ds CF footer
+.P1 \" ensure header on page 1
+.LP
+foobar
+'
+
+fail=
+
+wail () {
+ echo "...FAILED" >&2
+ fail=YES
+}
+
+output=$(printf '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms 2>&1)
+status=$?
+
+echo "checking for nonzero exit status" >&2
+test $status -ne 0 || wail
+
+# grepping diagnostic messages is a tar pit. I hope I don't come to
+# regret this.
+
+echo "checking for lack of diagnostic about infinite loop" >&2
+echo "$output" | grep -q 'troff.*fatal.*infinite' && wail
+
+echo "checking for diagnostic about page length" >&2
+echo "$output" | grep -q 's\.tmac.*page length' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72: