gbranden pushed a commit to branch master
in repository groff.

commit 4cac9cd1d354ed940faffd0df9223db8593ca936
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 22 06:21:07 2026 -0600

    [soelim]: Add test exercising FSM states.
    
    * src/preproc/soelim/tests/exercise-finite-state-machine.sh: New file;
      test the FSM with unusual inputs.
    
    * src/preproc/soelim/soelim.am: Update `soelim_TESTS` to run test.
---
 ChangeLog                                          |  9 ++++
 src/preproc/soelim/soelim.am                       |  1 +
 .../soelim/tests/exercise-finite-state-machine.sh  | 56 ++++++++++++++++++++++
 3 files changed, 66 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 2c592feff..09f44cbb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-11-22  G. Branden Robinson <[email protected]>
+
+       [soelim]: Add test exercising FSM states.
+
+       * src/preproc/soelim/tests/exercise-finite-state-machine.sh:
+       New file; test the FSM with unusual inputs.
+       * src/preproc/soelim/soelim.am: Update `soelim_TESTS` to run
+       test.
+
 2026-11-22  G. Branden Robinson <[email protected]>
 
        [soelim]: Add warning diagnostic.
diff --git a/src/preproc/soelim/soelim.am b/src/preproc/soelim/soelim.am
index ec815c1d6..a7f40211e 100644
--- a/src/preproc/soelim/soelim.am
+++ b/src/preproc/soelim/soelim.am
@@ -22,6 +22,7 @@ EXTRA_DIST += \
   src/preproc/soelim/soelim.1.man
 
 soelim_TESTS = \
+  src/preproc/soelim/tests/exercise-finite-state-machine.sh \
   src/preproc/soelim/tests/leading-quote-before-file-name-works.sh \
   src/preproc/soelim/tests/passes-through-input-with-eighth-bit-set.sh \
   src/preproc/soelim/tests/warning-escaped-space-gets-lineno-right.sh \
diff --git a/src/preproc/soelim/tests/exercise-finite-state-machine.sh 
b/src/preproc/soelim/tests/exercise-finite-state-machine.sh
new file mode 100755
index 000000000..7ad3fb544
--- /dev/null
+++ b/src/preproc/soelim/tests/exercise-finite-state-machine.sh
@@ -0,0 +1,56 @@
+#!/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/>.
+
+soelim="${abs_top_builddir:-.}/soelim"
+
+fail=
+
+wail () {
+  echo "...FAILED" >&2
+  fail=yes
+}
+
+# Exercise unusual states in soelim's FSM.
+input='.
+.s
+.so
+.l
+.lf
+.'
+
+output=$(echo "$input" | "$soelim")
+echo "$output"
+echo "checking that partial requests are passed through" >&2
+echo "$output" | tr '\n' ' ' | grep -Fq '.lf 1 "- . .s .so .l .lf .' \
+    || wail
+
+# Check these same cases when they immediately precede EOF.  In the
+# absence of the `-r` option, GNU soelim appends the terminal newline
+# missing from the input stream.
+
+for token in .s .so .l .lf
+do
+    echo "checking that token '"$token"' before EOF passes through" >&2
+    output=$(printf "%s" $token | "$soelim")
+    echo "$output" | grep -Fq "$token" || wail
+done
+
+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