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