[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 86/115: [eqn]: Improve tests of line number accuracy.
From: |
G. Branden Robinson |
Subject: |
[groff] 86/115: [eqn]: Improve tests of line number accuracy. |
Date: |
Thu, 1 Jun 2023 10:46:14 -0400 (EDT) |
gbranden pushed a commit to branch branden-2022-06-01
in repository groff.
commit 29b8dc8cae47f7be255772cb60b5ab080a38bb1d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Apr 30 06:03:08 2023 -0500
[eqn]: Improve tests of line number accuracy.
* src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh: Add
cases to check behavior of valid input, not just error cases. Also
add some unexecuted test cases for future use.
---
ChangeLog | 9 ++++
.../diagnostics-report-correct-line-numbers.sh | 58 ++++++++++++++++++++--
2 files changed, 62 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e3a4dbf3c..6d2128cd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-04-30 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [eqn]: Improve tests of line number accuracy.
+
+ * src/preproc/eqn/tests/\
+ diagnostics-report-correct-line-numbers.sh: Add cases to check
+ behavior of valid input, not just error cases. Also add some
+ unexecuted test cases for future use.
+
2023-04-29 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/include/lf.h (interpret_lf_args):
diff --git a/src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh
b/src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh
index feb78c117..b9deb60a3 100755
--- a/src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh
+++ b/src/preproc/eqn/tests/diagnostics-report-correct-line-numbers.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2022 Free Software Foundation, Inc.
+# Copyright (C) 2022-2023 Free Software Foundation, Inc.
#
# This file is part of groff.
#
@@ -19,6 +19,7 @@
#
eqn="${abs_top_builddir:-.}/eqn"
+groff="${abs_top_builddir:-.}/test-groff"
fail=
wail () {
@@ -29,27 +30,74 @@ wail () {
# Verify that correct input file line numbers are reported.
+echo "checking for correct line number when no EQ/EN input" >&2
+error=$(printf '.\n.tm FNORD:\\n(.c\n' \
+ | "$eqn" -Tascii | "$groff" -Tascii -z 2>&1 > /dev/null)
+echo "$error" | grep -qx FNORD:2 || wail
+
+echo "checking for correct line number when EQ/EN input empty" >&2
+error=$(printf '.\n.EQ\n.EN\n.tm FNORD:\\n(.c\n' \
+ | "$eqn" -Tascii | "$groff" -Tascii -z 2>&1 > /dev/null)
+echo "$error" | grep -qx FNORD:4 || wail
+
+echo "checking for correct line number when EQ/EN input simple" >&2
+error=$(printf '.\n.EQ\nx\n.EN\n.tm FNORD:\\n(.c\n' \
+ | "$eqn" -Tascii | "$groff" -Tascii -z 2>&1 > /dev/null)
+echo "$error" | grep -qx FNORD:5 || wail
+
echo "checking for absent line number in early EOF diagnostic" >&2
input='.EQ'
-error=$(printf "%s\n" "$input" | "$eqn" 2>&1 > /dev/null)
+error=$(printf '%s\n' "$input" | "$eqn" 2>&1 > /dev/null)
echo "$error" | grep -Eq '^[^:]+:[^:]+: fatal' || wail
echo "checking for correct line number in nested 'EQ' diagnostic" >&2
input='.EQ
.EQ'
-error=$(printf "%s\n" "$input" | "$eqn" 2>&1 > /dev/null)
+error=$(printf '%s\n' "$input" | "$eqn" 2>&1 > /dev/null)
echo "$error" | grep -Eq '^[^:]+:[^:]+:2: fatal' || wail
echo "checking for correct line number in invalid input character" \
"diagnostic" >&2
-error=$(printf ".EQ\nx\n.EN\n\200\n" | "$eqn" 2>&1 > /dev/null)
+error=$(printf '.EQ\nx\n.EN\n\200\n' | "$eqn" 2>&1 > /dev/null)
echo "$error" | grep -Eq '^[^:]+:[^:]+:4: error' || wail
echo "checking for correct line number in invalid input character" \
"diagnostic when 'lf' request used beforehand" >&2
-error=$(printf ".EQ\nx\n.EN\n.lf 99\n\200\n" | "$eqn" 2>&1 > /dev/null)
+error=$(printf '.EQ\nx\n.EN\n.lf 99\n\200\n' | "$eqn" 2>&1 > /dev/null)
echo "$error" | grep -Eq '^[^:]+:[^:]+:99: error' || wail
+echo "checking for correct line number when invalid 'lf' request used" \
+ >&2
+error=$(printf '.lf xyz\n.EQ\n.EQ\n' | "$eqn" 2>&1 > /dev/null)
+echo "$error" | grep -Eq '^[^:]+:[^:]+:3: fatal error' || wail
+
+echo "checking for correct line number when input begins with" \
+ "delimited equation and '-N' not used" >&2
+error=$(printf '$ x =\n' | "$eqn" -Tascii -d'$$' 2>&1 > /dev/null)
+echo "$error" | grep -Eq '^[^:]+:[^:]+:1: fatal error' || wail
+
+echo "checking for correct line number when input begins with" \
+ "delimited equation and '-N' is used" >&2
+error=$(printf '$ x =\n' | "$eqn" -Tascii -d'$$' -N 2>&1 > /dev/null)
+echo "$error" | grep -Eq '^[^:]+:[^:]+:1: error' || wail
+
+test -z "$fail"
+exit
+
+# tests for future use
+
+echo "checking for correct line number when later input contains" \
+ "delimited equation and '-N' not used" >&2
+error=$(printf '.EQ\ndelim $$\n.EN\n$x =\n' \
+ | "$eqn" -Tascii 2>&1 > /dev/null)
+echo "$error" | grep -Eq '^[^:]+:[^:]+:4: fatal error' || wail
+
+echo "checking for correct line number when later input contains" \
+ "delimited equation and '-N' is used" >&2
+error=$(printf '.EQ\ndelim $$\n.EN\n$x =\n' \
+ | "$eqn" -Tascii 2>&1 > /dev/null)
+echo "$error" | grep -Eq '^[^:]+:[^:]+:4: error' || wail
+
test -z "$fail"
# vim:set ai et sw=4 ts=4 tw=72:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 86/115: [eqn]: Improve tests of line number accuracy.,
G. Branden Robinson <=