08misc_commands.t 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. use strict;
  2. use File::Spec;
  3. BEGIN { if (defined($ENV{'top_srcdir'})) {unshift @INC, File::Spec->catdir($ENV{'top_srcdir'}, 'tp');} }
  4. require 't/test_utils.pl';
  5. my @test_cases = (
  6. ['simple', '@defindex idx'],
  7. ['many_lines', 'pagesizes @pagesizes 200mm,150mm following @@pagesizes arg
  8. afourpaper @afourpaper on line following afourpaper
  9. smallbook @smallbook on line following smallbook
  10. headings @headings on line following headings
  11. oddfooting @oddfooting on line following oddfooting
  12. everyheading @everyheading on line following everyheading
  13. everyfooting @everyfooting on line following everyfooting
  14. evenheading @evenheading on line following evenheading
  15. evenfooting @evenfooting on line following evenfooting
  16. oddheading @oddheading on line following
  17. need @need 0.1 on line following
  18. need @need 0.1
  19. setchapternewpage @setchapternewpage on line following setchapternewpage
  20. raisesections @raisesections on line following raisesections
  21. lowersections @lowersections on line following lowersections
  22. kbdinputstyle code @kbdinputstyle code something
  23. afourpaper @afourpaper on line following afourpaper
  24. afourlatex @afourlatex on line following afourlatex
  25. afourwide @afourwide on line following afourwide
  26. paragraphindent asis @paragraphindent asis
  27. paragraphindent 0 @paragraphindent 0
  28. paragraphindent none @paragraphindent none
  29. paragraphindent 4 @paragraphindent 4
  30. firstparagraphindent none @firstparagraphindent none
  31. exampleindent 6 @exampleindent 6 on line following exampleindent
  32. exampleindent 6 @exampleindent 6
  33. footnotestyle @footnotestyle end
  34. footnotestyle @footnotestyle separate
  35. documentencoding @documentencoding US-ascii encoding name
  36. @documentencoding ISO-8859-1
  37. frenchspacing @frenchspacing on
  38. frenchspacing @frenchspacing off
  39. fonttextsize @fonttextsize 10
  40. everyheadingmarks @everyheadingmarks bottom on line following everyheadingmarks
  41. @allowcodebreaks false
  42. @allowcodebreaks true
  43. Text line followed by finalout on the same line and another below @finalout
  44. @finalout
  45. Text line after the finalout followed by a fianlout @finalout
  46. Text line after the text line followed by the finalout.
  47. Test text after finalout
  48. @finalout a word after finalout
  49. Line after finalout
  50. '],
  51. ['also_not_line',
  52. '
  53. page @page
  54. noindent @noindent refill @refill something
  55. @noindent noindent at beginning of line
  56. @noindent
  57. noindent on the preceding line
  58. @noindent noindent after space at beginning of line
  59. @page page at beginning of line
  60. @page
  61. After page on its own line.
  62. page @page
  63. noindent @noindent refill @refill
  64. novalidate @novalidate something
  65. @subheading special
  66. Only valid between iftex:
  67. vskip @vskip
  68. cropmarks @cropmarks
  69. exdent @exdent line after exdent
  70. '],
  71. ['sp',
  72. '
  73. Text line followed on the same line and another below @sp 1
  74. @sp 2
  75. Text line after the sp followed by a sp @sp 1
  76. Text line after the text line followed by the sp.
  77. @ifnottex
  78. @sp 2 a number after sp
  79. @end ifnottex
  80. '],
  81. ['clickstyle',
  82. '@clickstyle @result
  83. A @click{} (result).
  84. '],
  85. ['bye',
  86. '@bye
  87. '],
  88. ['text_before_and_after_bye',
  89. 'Before bye @bye on bye line
  90. after bye
  91. '],
  92. ['invalid_clickstyle',
  93. '
  94. @clickstyle @result on the same line
  95. A @click{} (result on the same line).
  96. @clickstyle @nocmd
  97. A @click{} (nocmd).
  98. @clickstyle something
  99. A @click{} (something).
  100. '],
  101. ['contents','
  102. first @@contents @contents line following first content
  103. second @@contents @contents line following second content
  104. Third content on the following line on his own
  105. @contents
  106. Line following contents
  107. shortcontents @shortcontents eol
  108. shortcontents @shortcontents eol
  109. summarycontents @summarycontents line following summarycontents
  110. '],
  111. ['invalid_kbdinputstyle',
  112. 'kbdinputstyle @kbdinputstyle wrong arg on line following kbdinputstyle
  113. '],
  114. ['kbdinputstyle',
  115. '@macro codekbdmacro
  116. @code{in code out of example @code{in nested code}}.
  117. @kbd{kbd out of example}.
  118. @code{kbd @kbd{in code}}.
  119. in example
  120. @example
  121. @code{in code in example @code{in nested code}}.
  122. @kbd{kbd in example}.
  123. @code{kbd @kbd{in code} in example}.
  124. @end example
  125. @end macro
  126. @@kbdinputstyle code
  127. @kbdinputstyle code
  128. @codekbdmacro{}
  129. @@kbdinputstyle example
  130. @kbdinputstyle example
  131. @codekbdmacro{}
  132. @@kbdinputstyle distinct
  133. @kbdinputstyle distinct
  134. @codekbdmacro{}
  135. '],
  136. ['index_entries',
  137. '@cindex cindex entry
  138. @defindex truc
  139. @trucindex index truc
  140. '],
  141. ['command_line_in_paragraph',
  142. 'documentlanguage on its line
  143. @documentlanguage en
  144. line following documentlanguage
  145. '],
  146. ['bad_documentlanguage',
  147. '
  148. documentlanguage @documentlanguage en
  149. @documentlanguage en @documentlanguage en
  150. @documentlanguage en after documentlanguage
  151. '],
  152. ['empty_documentencoding',
  153. '@documentencoding
  154. '],
  155. ['invalid_documentencoding',
  156. '@c this one is valid
  157. @documentencoding us-ascii@asis{}
  158. @documentencoding latin1@asis{a}
  159. @documentencoding YS-ASCII
  160. @@documentencoding @documentencoding bad encoding name
  161. @documentencoding 1
  162. @documentencoding %
  163. @documentencoding @@
  164. @documentencoding AAA@TeX{}
  165. @documentencoding BBB@\'e
  166. '],
  167. ['defindex_too_much_args',
  168. '@defindex chose machin'
  169. ],
  170. ['synindex_too_much_args',
  171. '@syncodeindex cp fn truc
  172. '],
  173. ['command_not_closed_in_documentencoding',
  174. '@documentencoding @strong{'],
  175. ['text_before_line_command',
  176. 'before title @title the title
  177. i@node LD Version Scripts
  178. --- @chapter LD Version Scripts
  179. ddd @contents
  180. @quotation
  181. aaa @author quotation author
  182. quotation
  183. @end quotation
  184. '],
  185. ['author_outside_titlepage_quotation',
  186. '@author Some One
  187. '],
  188. ['double_exdent',
  189. '@example
  190. Example Hoho.
  191. @example
  192. Nested Other line
  193. @exdent @exdent double exdented nested other line
  194. @end example
  195. @end example
  196. '],
  197. );
  198. my @converted_test_cases = (
  199. ['setfilename',
  200. '@setfilename file_comment@c comment
  201. @setfilename file_and_spaces
  202. @setfilename file_space_comment @c comment
  203. @setfilename @ @verb{: name :}@
  204. '],
  205. ['definfoenclose',
  206. '
  207. definfoenclose phoo,//,\\ @definfoenclose phoo,//,\\
  208. @phoo{bar}
  209. definfoenclose phi,:,: @definfoenclose phi,:,:
  210. @phi{bar}
  211. @strong{very strong}
  212. @definfoenclose strong,(strong:,:)
  213. @strong{ is it really strong? }
  214. '],
  215. ['definfoenclose_with_empty_arg',
  216. '
  217. @definfoenclose headword, , :
  218. My @headword{something}.
  219. '],
  220. ['no_empty_line_between_headings',
  221. '@top Top
  222. @subheading Subheading
  223. @chapter Chapter
  224. @section Section
  225. '],
  226. ['comments_in_text',
  227. '
  228. @c lone comment
  229. Text line followed by a comment on the same line and another below @c comment
  230. @c comment
  231. Text line after the comment followed by a comment @comment c
  232. Text line after the text line followed by the comment.
  233. Comment at the end of the line @c comment
  234. '],
  235. ['noindent_indent',
  236. '
  237. @indent
  238. First para
  239. @noindent
  240. qsddsqkdsqkkmljsqjsqodmmdsqdsmqj dqs sdq sqd sdq dsq sdq sqd sqd sdq sdq
  241. qsd dsq sdq dsq dssdq sdq sdq sdq dsq sdq dsq dsq sdq dsq sdqsd q
  242. @noindent noindent in para.
  243. @indent unneeded indent
  244. '],
  245. ['indent_in_quotation',
  246. '@quotation
  247. @indent
  248. indent in quotation
  249. @end quotation
  250. '],
  251. ['noindent_after_smallexample',
  252. 'To obtain.
  253. @smallexample
  254. $ wget \'http://savannah.gnu.org/cgi-bin/viewcvs/config/config/config.guess?rev=HEAD&content-type=text/plain\'
  255. $ wget \'http://savannah.gnu.org/cgi-bin/viewcvs/config/config/config.sub?rev=HEAD&content-type=text/plain\'
  256. @end smallexample
  257. @noindent
  258. Less recent versions are also present.
  259. '],
  260. ['noindent_in_paragraph',
  261. 'Begin para
  262. @noindent
  263. after noindent.
  264. Begin para2
  265. @noindent
  266. after noindent2.
  267. '],
  268. ['empty_center',
  269. '@center
  270. '],
  271. ['empty_center_with_arg',
  272. '@center @w{}
  273. '],
  274. ['ref_in_center',
  275. '@node Top
  276. @center @ref{Top}
  277. @center @ref{Top, ,title
  278. very long}
  279. '],
  280. ['footnote_in_center',
  281. '@center Centered text with a footnote@footnote{This footnote
  282. shows an important feature of the centered text.
  283. @example
  284. @table @asis
  285. @item item
  286. line
  287. @end table
  288. @end example
  289. } and text after the footnote.
  290. '],
  291. ['test_allowcodebreaks',
  292. '@node Top
  293. @macro testallowcodebreakspara {nr}
  294. Out of code --- out-of-code.
  295. @code{1aaa} @code{2aaa-} @code{-3bbb} @code{4aaa-bbb}
  296. @code{ 5aaa-bb} @code{6aaa-bb } @code{ccc 7aaa-bbb} @code{ccc 8aaa-bbb ddd}
  297. @code{9aaa-bbb rrr_vv}
  298. @samp{fff-- --- minus@minus{}b aa-tt@\'eff_gg aa@r{r-oman}
  299. anc-hor@anchor{A node\nr\}}
  300. @end macro
  301. @macro testallowcodebreaksexample{}
  302. @example
  303. @code{in-example}
  304. @end example
  305. @end macro
  306. Before first allowcodebreaks
  307. @testallowcodebreakspara{0}
  308. @testallowcodebreaksexample{}
  309. @allowcodebreaks false
  310. After false
  311. @testallowcodebreakspara{1}
  312. @testallowcodebreaksexample{}
  313. In w:
  314. @w{@testallowcodebreakspara{w}
  315. }
  316. @example
  317. @w{@code{in-example}}
  318. @end example
  319. @allowcodebreaks true
  320. After true
  321. @testallowcodebreakspara{2}
  322. @testallowcodebreaksexample{}
  323. '],
  324. ['incorrect_allowcodebreaks_argument',
  325. '@allowcodebreaks _arg
  326. @code{b a}
  327. '],
  328. ['codequoteundirected_codequotebacktick',
  329. '@macro quotes
  330. ``simple-double--three---four----\'\' `simple\' quotedblleft: @quotedblleft{} @*
  331. code: @code{``simple-double--three---four----\'\' `simple\' quotedblleft: @quotedblleft{}} @*
  332. asis: @asis{``simple-double--three---four----\'\' `simple\' quotedblleft: @quotedblleft{}} @*
  333. strong: @strong{``simple-double--three---four----\'\' `simple\' quotedblleft: @quotedblleft{}} @*
  334. kbd: @kbd{``simple-double--three---four----\'\' `simple\' quotedblleft: @quotedblleft{}} @*
  335. samp: @samp{``simple-double--three---four----\'\' `simple\' quotedblleft: @quotedblleft{}} @*
  336. @end macro
  337. @macro allquotes
  338. @quotes{}
  339. @example
  340. @@codequoteundirected on
  341. @@codequotebacktick on
  342. @end example
  343. @codequoteundirected
  344. @codequotebacktick
  345. @quotes{}
  346. @example
  347. @@codequoteundirected off
  348. @@codequotebacktick off
  349. @end example
  350. @codequoteundirected off
  351. @codequotebacktick off
  352. @quotes{}
  353. @end macro
  354. @copying
  355. @allquotes{}
  356. @end copying
  357. @titlepage
  358. Titlepage
  359. @insertcopying
  360. @end titlepage
  361. @node Top
  362. @top test quotes
  363. @allquotes{}
  364. @example
  365. @allquotes{}
  366. @end example
  367. '],
  368. ['comment_space_command_on_line',
  369. '@settitle Settitle @ @c settittle
  370. @node Top @comment @node Top
  371. @top top element@ @comment @top
  372. @frenchspacing on @c comment frenchspacing
  373. @cindex index entry @ @c index entry
  374. @heading Heading @ @c heading
  375. @printindex cp @c printindex
  376. @float Text, label
  377. float
  378. @end float @c end
  379. @listoffloats Text @ @c listoffloats
  380. @bye @c bye
  381. '],
  382. ['command_in_heading_footing',
  383. '@everyheading something @thispage @thischapternum
  384. In text @thispage @thischapternum text.
  385. '],
  386. ['vskip',
  387. '@vskip 0pt plus 1filll
  388. ']
  389. );
  390. my %info_tests = (
  391. 'comment_space_command_on_line' => 1,
  392. 'setfilename' => 1,
  393. );
  394. my %xml_tests = (
  395. 'definfoenclose_with_empty_arg' => 1,
  396. 'vskip' => 1,
  397. );
  398. my %docbook_tests = (
  399. 'setfilename' => 1,
  400. 'definfoenclose' => 1,
  401. 'no_empty_line_between_headings' => 1,
  402. 'comments_in_text' => 1,
  403. 'noindent_indent' => 1,
  404. 'empty_center' => 1,
  405. 'ref_in_center' => 1,
  406. 'footnote_in_center' => 1,
  407. 'codequoteundirected_codequotebacktick' => 1,
  408. 'comment_space_command_on_line' => 1,
  409. 'command_in_heading_footing' => 1,
  410. );
  411. foreach my $test (@converted_test_cases) {
  412. push @{$test->[2]->{'test_formats'}}, 'plaintext';
  413. push @{$test->[2]->{'test_formats'}}, 'html_text';
  414. if ($docbook_tests{$test->[0]}) {
  415. push @{$test->[2]->{'test_formats'}}, 'docbook';
  416. }
  417. if ($info_tests{$test->[0]}) {
  418. push @{$test->[2]->{'test_formats'}}, 'info';
  419. push @{$test->[2]->{'test_formats'}}, 'xml';
  420. }
  421. if ($xml_tests{$test->[0]}) {
  422. push @{$test->[2]->{'test_formats'}}, 'xml';
  423. }
  424. }
  425. our ($arg_test_case, $arg_generate, $arg_debug);
  426. run_all ('misc_commands', [@test_cases, @converted_test_cases], $arg_test_case,
  427. $arg_generate, $arg_debug);