Debian Codegraph @

tmac/tests/s_vertical-margins-are-correct.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 #
3 # Copyright 2025 G. Branden Robinson
4 #
5 # This file is part of groff, the GNU roff typesetting system.
6 #
7 # groff is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # groff is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 groff="${abs_top_builddir:-.}/test-groff"
21
22 fail=
23
24 wailscip-shell shell groff 1.24.1-1 wail(). () {
25 echoscip-shell system . . echo. "...FAILED" >&2
26 fail=YES
27 }
28
29 # Unit-test the vertical page margins (before and after titles).
30
31 input='.
32 .ds FR 1\"
33 .P1
34 .if \nT .ds CH Header
35 .if \nT .ds CF Footer
36 .de pp
37 .LP
38 Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
39 accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab
40 illo inventore veritatis et quasi architecto beatae vitae dicta sunt,
41 explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur
42 aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione
43 voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum,
44 quia dolor sit amet consectetur adipiscivelit, sed quia non-numquam eius
45 modi tempora incidunt, ut labore et dolore magnam aliquam quaerat
46 voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam
47 corporis suscipitlaboriosam, nisi ut aliquid ex ea commodi consequatur?
48 Quis autem vel eum iure reprehenderit, qui inea voluptate velit esse,
49 quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo
50 voluptas nulla pariatur? At vero eos et accusamus et iusto odio
51 dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti
52 atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati
53 cupiditate non-provident, similique sunt in culpa, qui officia deserunt
54 mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum
55 facilis est et expedita distinctio. Nam libero tempore, cum soluta
56 nobis est eligendi optio, cumque nihil impedit, quo minus id, quod
57 maxime placeat, facere possimus, omnis voluptas assumenda est, omnis
58 dolor repellendus. Temporibus autem quibusdam et aut officiis debitis
59 aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae
60 sint et molestiae non-recusandae.
61 ..
62 .pp
63 .if \nF \{\
64 See below.\**
65 . FS
66 . if \nF=1 This is a short footnote.
67 . if \nF=2 \{\
68 This is a longer footnote.
69 Ne forte ex homine et veterino semine equorum
70 confieri credas Centauros posse neque esse,
71 aut rabidis canibus succinctas semimarinis
72 corporibus Scyllas et cetera de genere horum.
73 . \}
74 . FE
75 .\}
76 .pp
77 .'
78
79 # Check that body text stops and starts in the correct places even
80 # without titles.
81
82 # GNU coreutils's `nl` command adds trailing tabs to empty lines.
83 output=$(printfscip-shell system . . printf. '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms \
84 | nl -ba | sed 's/[ ]*$//') # That's [tab space].
85 echoscip-shell system . . echo. "$output"
86
87 echoscip-shell system . . echo. "checking that body text begins on correct output line" >&2
88 # That's [tab space] on the next line.
89 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q '^ *7[ ]*Sed *ut *perspiciatis' || wailscip-shell shell groff 1.24.1-1 wail().
90
91 echoscip-shell system . . echo. "checking that body text ends on correct output line" >&2
92 # That's [tab space] on the next line.
93 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q '^ *57[ ]*sint et molestiae' || wailscip-shell shell groff 1.24.1-1 wail().
94
95 # Now check _with_ titles...
96
97 output=$(printfscip-shell system . . printf. '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms -rT1 \
98 | nl -ba | sed 's/[ ]*$//') # That's [tab space].
99 echoscip-shell system . . echo. "$output"
100
101 echoscip-shell system . . echo. "checking for header on correct output line" >&2
102 # That's [tab space] on the next line.
103 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -qx ' *4[ ]*Header' || wailscip-shell shell groff 1.24.1-1 wail().
104
105 echoscip-shell system . . echo. "checking that body text begins on correct output line" >&2
106 # That's [tab space] on the next line.
107 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q '^ *7[ ]*Sed *ut *perspiciatis' || wailscip-shell shell groff 1.24.1-1 wail().
108
109 echoscip-shell system . . echo. "checking that body text ends on correct output line" >&2
110 # That's [tab space] on the next line.
111 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q '^ *57[ ]*sint et molestiae' || wailscip-shell shell groff 1.24.1-1 wail().
112
113 echoscip-shell system . . echo. "checking for footer on correct output line" >&2
114 # That's [tab space] on the next line.
115 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -qx ' *63[ ]*Footer' || wailscip-shell shell groff 1.24.1-1 wail().
116
117 # ...with titles and a short footnote...
118
119 output=$(printfscip-shell system . . printf. '%s\n' "$input" \
120 | "$groff" -Tascii -P-cbou -ms -rT1 -rF1 \
121 | nl -ba | sed 's/[ ]*$//') # That's [tab space].
122 echoscip-shell system . . echo. "$output"
123
124 echoscip-shell system . . echo. "checking for header on correct output line" >&2
125 # That's [tab space] on the next line.
126 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -qx ' *4[ ]*Header' || wailscip-shell shell groff 1.24.1-1 wail().
127
128 echoscip-shell system . . echo. "checking that body text begins on correct output line" >&2
129 # That's [tab space] on the next line.
130 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q '^ *7[ ]*Sed *ut *perspiciatis' || wailscip-shell shell groff 1.24.1-1 wail().
131
132 echoscip-shell system . . echo. "checking that body text ends on correct output line" >&2
133 # That's [tab space] on the next line.
134 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q '^ *57[ ]*sint et molestiae' || wailscip-shell shell groff 1.24.1-1 wail().
135
136 echoscip-shell system . . echo. "checking for footnote separator rule on correct output line" >&2
137 # That's [tab space] on the next line.
138 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q ' *59[ ]*---' || wailscip-shell shell groff 1.24.1-1 wail().
139
140 echoscip-shell system . . echo. "checking for footnote text on correct output line" >&2
141 # That's [tab space] on the next line.
142 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q ' *60[ ]*.*short footnote' || wailscip-shell shell groff 1.24.1-1 wail().
143
144 echoscip-shell system . . echo. "checking for footer on correct output line" >&2
145 # That's [tab space] on the next line.
146 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -qx ' *63[ ]*Footer' || wailscip-shell shell groff 1.24.1-1 wail().
147
148 # ...and with titles and a longer footnote.
149
150 output=$(printfscip-shell system . . printf. '%s\n' "$input" \
151 | "$groff" -Tascii -P-cbou -ms -rT1 -rF2 \
152 | nl -ba | sed 's/[ ]*$//') # That's [tab space].
153 echoscip-shell system . . echo. "$output"
154
155 echoscip-shell system . . echo. "checking for header on correct output line" >&2
156 # That's [tab space] on the next line.
157 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -qx ' *4[ ]*Header' || wailscip-shell shell groff 1.24.1-1 wail().
158
159 echoscip-shell system . . echo. "checking that body text begins on correct output line" >&2
160 # That's [tab space] on the next line.
161 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q '^ *7[ ]*Sed *ut *perspiciatis' || wailscip-shell shell groff 1.24.1-1 wail().
162
163 # The long footnote causes the footnote area to retreat up the page,
164 # spilling body text that formerly fit on one page to a second.
165 echoscip-shell system . . echo. "checking that body text ends on correct output line" >&2
166 # That's [tab space] on the next line.
167 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q '^ *74[ ]*sint et molestiae' || wailscip-shell shell groff 1.24.1-1 wail().
168
169 echoscip-shell system . . echo. "checking for footnote separator rule on correct output line" >&2
170 # That's [tab space] on the next line.
171 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q ' *56[ ]*---' || wailscip-shell shell groff 1.24.1-1 wail().
172
173 echoscip-shell system . . echo. "checking for footnote text on correct output line" >&2
174 # That's [tab space] on the next line.
175 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -q ' *57[ ]*.*longer footnote' || wailscip-shell shell groff 1.24.1-1 wail().
176
177 echoscip-shell system . . echo. "checking for footer on correct output line" >&2
178 # That's [tab space] on the next line.
179 echoscip-shell system . . echo. "$output" | grepscip-shell system . . grep. -qx ' *63[ ]*Footer' || wailscip-shell shell groff 1.24.1-1 wail().
180
181 testscip-shell system . . test. -z "$fail"
182
183 # vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72: