gbranden pushed a commit to branch master
in repository groff.

commit f096a95296ff201d6cdce70c87759a08e4237928
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 9 02:00:55 2026 -0600

    [groff]: Unit-test `shift` request.
    
    * src/roff/groff/tests/error-shift-request-given-bogus-argument.sh:
    * src/roff/groff/tests/shift-request-works.sh: New files; do it.
    
    * src/roff/groff/groff.am: Update `groff_TESTS` to run tests.
    
    Fixes <https://savannah.gnu.org/bugs/?68895>.
---
 ChangeLog                                          | 11 ++++
 src/roff/groff/groff.am                            |  2 +
 .../error-shift-request-given-bogus-argument.sh    | 51 ++++++++++++++++++
 src/roff/groff/tests/shift-request-works.sh        | 60 ++++++++++++++++++++++
 4 files changed, 124 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 830db4a09..4388c964a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-11-09  G. Branden Robinson <[email protected]>
+
+       [groff]: Unit-test `shift` request.
+
+       * src/roff/groff/tests/\
+       error-shift-request-given-bogus-argument.sh:
+       * src/roff/groff/tests/shift-request-works.sh: New files; do it.
+       * src/roff/groff/groff.am: Update `groff_TESTS` to run tests.
+
+       Fixes <https://savannah.gnu.org/bugs/?68895>.
+
 2026-11-08  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (token::next): Actually throw warning
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index ba3cdeea3..1171475d5 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -124,6 +124,7 @@ groff_TESTS = \
   src/roff/groff/tests/error-rm-request-given-bogus-argument.sh \
   src/roff/groff/tests/error-rn-request-given-bogus-arguments.sh \
   src/roff/groff/tests/error-rr-request-given-bogus-argument.sh \
+  src/roff/groff/tests/error-shift-request-given-bogus-argument.sh \
   src/roff/groff/tests/error-so-request-given-empty-argument.sh \
   src/roff/groff/tests/error-sy-request-given-empty-argument.sh \
   src/roff/groff/tests/evc-request-produces-no-output-if-invalid.sh \
@@ -176,6 +177,7 @@ groff_TESTS = \
   src/roff/groff/tests/rr-request-works.sh \
   src/roff/groff/tests/safer-mode-works.sh \
   src/roff/groff/tests/set-stroke-thickness.sh \
+  src/roff/groff/tests/shift-request-works.sh \
   src/roff/groff/tests/sizes-request-works.sh \
   src/roff/groff/tests/so-request-accepts-embedded-space-in-arg.sh \
   src/roff/groff/tests/so-request-works.sh \
diff --git a/src/roff/groff/tests/error-shift-request-given-bogus-argument.sh 
b/src/roff/groff/tests/error-shift-request-given-bogus-argument.sh
new file mode 100755
index 000000000..42eae5315
--- /dev/null
+++ b/src/roff/groff/tests/error-shift-request-given-bogus-argument.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Copyright 2026 G. Branden Robinson
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+   echo "...FAILED"
+   fail=yes
+}
+
+input='.
+.ec @
+.nf
+.de mac
+arg 1=@@$1
+.shift A
+arg 2=@@$1
+..
+.mac foo bar
+.'
+
+output=$(printf '%s\n' "$input" | "$groff" -a)
+echo "$output"
+
+echo "checking that 'shift' with bogus argument performs no operation" \
+    >&2
+echo "$output" | grep -q "arg 2=foo" || wail
+
+echo "checking that 'shift' with bogus argument throws error" >&2
+error=$(printf '.shift A\n' | "$groff" -z 2>&1 > /dev/null)
+echo "$error" | grep -q "error:"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
diff --git a/src/roff/groff/tests/shift-request-works.sh 
b/src/roff/groff/tests/shift-request-works.sh
new file mode 100755
index 000000000..2f4ec78f0
--- /dev/null
+++ b/src/roff/groff/tests/shift-request-works.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# Copyright 2026 G. Branden Robinson
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# groff is free software; you can redistribute it and/or modify it over
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+   echo "...FAILED"
+   fail=yes
+}
+
+# Unit-test `shift` request.
+
+input='.
+.ec @
+.nf
+.de mac
+arg 1=@@$1
+.shift
+arg 2=@@$1
+.shift 1
+arg 3=@@$1
+.shift 2
+arg 5=@@$1
+..
+.mac foo bar baz qux jat
+.'
+
+output=$(printf '%s\n' "$input" | "$groff" -a)
+echo "$output"
+
+echo "checking that 'shift' with no argument works" >&2
+echo "$output" | grep -q "arg 2=bar" || wail
+
+echo "checking that 'shift' with '1' argument works" >&2
+echo "$output" | grep -q "arg 3=baz" || wail
+
+echo "checking that 'shift' with '2' argument works" >&2
+echo "$output" | grep -q "arg 5=jat" || wail
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:

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

Reply via email to