[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 24/38: [tests]: Add more cases w/ newlines as delimiters.
From: |
G. Branden Robinson |
Subject: |
[groff] 24/38: [tests]: Add more cases w/ newlines as delimiters. |
Date: |
Mon, 3 Oct 2022 01:42:58 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 110f72e40a5bcb911b8a618fddf9093bb56806f4
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Oct 1 02:55:53 2022 -0500
[tests]: Add more cases w/ newlines as delimiters.
* src/roff/groff/tests/some_escapes_accept_newline_delimiters.sh: Add
test cases for `\A` and test formatted output of escape sequences, not
just the absence of diagnostics from permitted use of newlines as
argument delimiters.
Several of these cases fail due to inconsistent implementation logic.
They tend to center around (1) not checking to see if the newline was
the opening delimiter when encountering another one, then complaining
that there wasn't a closing one and (2) when the delimiter is a newline,
failing to synthesize an extra newline token to cause an input line
ending to be interpreted.
checking that newline is accepted as delimiter to 'A' escape
...FAILED
checking correct handling of newline delimiter to 'A' escape
troff:<standard input>:2: warning: missing closing delimiter in identifier
validation escape sequence (got a newline)
checking that newline is accepted as delimiter to 'b' escape
checking correct handling of newline delimiter to 'b' escape
checking that newline is accepted as delimiter to 'o' escape
checking correct handling of newline delimiter to 'o' escape
...FAILED
checking that newline is accepted as delimiter to 'w' escape
checking correct handling of newline delimiter to 'w' escape
checking that newline is accepted as delimiter to 'X' escape
checking correct handling of newline delimiter to 'X' escape
...FAILED
checking that newline is accepted as delimiter to 'Z' escape
...FAILED
checking correct handling of newline delimiter to 'Z' escape
troff:<standard input>:2: warning: missing closing delimiter in zero-width
escape (got a newline)
...FAILED
Here's the same test against groff 1.22.4.
checking that newline is accepted as delimiter to 'A' escape
...FAILED
checking correct handling of newline delimiter to 'A' escape
troff: <standard input>:2: warning: missing closing delimiter
checking that newline is accepted as delimiter to 'b' escape
...FAILED
checking correct handling of newline delimiter to 'b' escape
troff: <standard input>:3: warning: missing closing delimiter
checking that newline is accepted as delimiter to 'o' escape
...FAILED
checking correct handling of newline delimiter to 'o' escape
troff: <standard input>:2: warning: missing closing delimiter
checking that newline is accepted as delimiter to 'w' escape
...FAILED
checking correct handling of newline delimiter to 'w' escape
troff: <standard input>:2: warning: missing closing delimiter
checking that newline is accepted as delimiter to 'X' escape
checking correct handling of newline delimiter to 'X' escape
...FAILED
checking that newline is accepted as delimiter to 'Z' escape
...FAILED
checking correct handling of newline delimiter to 'Z' escape
troff: <standard input>:2: warning: missing closing delimiter
---
ChangeLog | 8 ++
.../some_escapes_accept_newline_delimiters.sh | 94 +++++++++++++++++-----
2 files changed, 81 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 39be03513..8cd883b1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-10-01 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/groff/tests/\
+ some_escapes_accept_newline_delimiters.sh: Add test cases for
+ `\A` and test formatted output of escape sequences, not just the
+ absence of diagnostics from permitted use of newlines as
+ argument delimiters.
+
2022-09-29 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/libs/libdriver/input.cpp (do_file): Make use of
diff --git a/src/roff/groff/tests/some_escapes_accept_newline_delimiters.sh
b/src/roff/groff/tests/some_escapes_accept_newline_delimiters.sh
index 1bb2a2a22..98ff2d560 100755
--- a/src/roff/groff/tests/some_escapes_accept_newline_delimiters.sh
+++ b/src/roff/groff/tests/some_escapes_accept_newline_delimiters.sh
@@ -32,44 +32,96 @@ wail () {
# A handful of escape sequences bizarrely accept newlines as argument
# delimiters. Don't throw diagnostics if they are used.
+input="\A
+ABC
+D
+.pl \n(nlu"
+
+echo "checking that newline is accepted as delimiter to 'A' escape" >&2
+error=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
+test -z "$error" || wail
+
+echo "checking correct handling of newline delimiter to 'A' escape" >&2
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww)
+test "$output" = "1 D" || wail
+
input=".sp
\b
-+|+
-That's my bracket.
+ABC
+D
.pl \n(nlu"
echo "checking that newline is accepted as delimiter to 'b' escape" >&2
-output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
-test -z "$output" || wail
+error=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
+test -z "$error" || wail
-input="caf\o
-e\(aa
-in Paris
+echo "checking correct handling of newline delimiter to 'b' escape" >&2
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww)
+echo "$output" | grep -Fqx "B D" || wail
+
+input="\o
+ABC
+D
.pl \n(nlu"
echo "checking that newline is accepted as delimiter to 'o' escape" >&2
-output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
-test -z "$output" || wail
+error=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
+test -z "$error" || wail
+
+echo "checking correct handling of newline delimiter to 'o' escape" >&2
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww \
+ | LC_ALL=C od -t c)
+# 7 spaces between C and D.
+printf "%s\n" "$output" \
+ | grep -Eqx '0000000 +A +\\b +B +\\b +C D +\\n' || wail
-input="The word _girth_ has a width of
-.nr w \w
-girth
-\nw units.
+input="\w
+ABC
+D
.pl \n(nlu"
echo "checking that newline is accepted as delimiter to 'w' escape" >&2
-output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
-test -z "$output" || wail
+error=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
+test -z "$error" || wail
+
+echo "checking correct handling of newline delimiter to 'w' escape" >&2
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww)
+test "$output" = "72 D" || wail
-input="I am issuing a device control command
-\X
-tty: bogus
-now.
+input="\X
+tty: link http://example.com
+D
.pl \n(nlu"
echo "checking that newline is accepted as delimiter to 'X' escape" >&2
-output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
-test -z "$output" || wail
+error=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
+test -z "$error" || wail
+
+echo "checking correct handling of newline delimiter to 'X' escape" >&2
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -P -c)
+test "$output" = ' D' || wail
+
+input="\Z
+ABC
+D
+.pl \n(nlu"
+
+echo "checking that newline is accepted as delimiter to 'Z' escape" >&2
+error=$(printf "%s\n" "$input" | "$groff" -Tascii -ww -z 2>&1)
+test -z "$error" || wail
+
+# This looks really weird but is consistent. A newline used as a
+# delimiter still gets interpreted as an input line ending. What we see
+# here is 'ABC', the drawing position is reset, a word space (from
+# filling, but overstruck by 'A') goes on the output, then 'D', so it
+# appears as 'ADC'.
+#
+# `printf '\\Z@ABC@\nD\n'` produces the same output.
+echo "checking correct handling of newline delimiter to 'Z' escape" >&2
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -ww \
+ | LC_ALL=C od -t c)
+printf "%s\n" "$output" | grep -Eqx '0000000 +A +B +\\b +D +C +\\n' \
+ || wail
test -z "$fail"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 24/38: [tests]: Add more cases w/ newlines as delimiters.,
G. Branden Robinson <=