03coverage_braces.t 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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 $two_footnotes_in_nodes_text =
  6. '@node Top
  7. @top 2 footnotes in 2 nodes
  8. A@footnote{Footnote Top/1
  9. para2}
  10. B@footnote{Footnote Top/2
  11. para2}
  12. @menu
  13. * chapter::
  14. @end menu
  15. @node chapter
  16. @chapter chapter
  17. C@footnote{Footnote chapter/1
  18. para2}
  19. D@footnote{Footnote chapter/2
  20. para2}
  21. ';
  22. my @test_cases = (
  23. ['simple', '@b{in b}.'],
  24. ['empty_second_email_argument', '@email{ a@@b.c, }'],
  25. ['email_possibilities',
  26. '@email{--a,--b}
  27. @email{,--b}
  28. @email{--a}
  29. '],
  30. ['abbr_acronym',
  31. '@acronym{--a,an accronym}
  32. @acronym{--a}
  33. @acronym{--a,an accronym @comma{} @enddots{}}
  34. @abbr{@\'E--a. @comma{}A., @\'Etude--@comma{} @b{Autonome} }
  35. @abbr{@\'E--a. @comma{}A.}
  36. '],
  37. ['recursive_acronym',
  38. '@acronym{GNU, @acronym{GNU}\'s Not Unix}
  39. '],
  40. ['uref_url',
  41. '@uref{--a,--b}
  42. @uref{--c}
  43. @uref{,--d}
  44. @uref{--e,--f,--g}
  45. @uref{,--h,--i}
  46. @uref{--j,,--k}
  47. @uref{,,--l}
  48. @url{--m,--n}
  49. @url{--o,--p,--q}
  50. '],
  51. ['empty_commands',
  52. '@titlefont{}
  53. @uref{} @abbr{} @email{} @code{}@footnote{} @~{} @dotless{} @verb{;;}
  54. '],
  55. ['nested', 'type the characters @kbd{l o g o u t @key{RET}}.'],
  56. ['nested_args', '@xref{@@ @samp{in samp}, descr @b{in b}, S@~{e}ction,
  57. @cite{manual}}.'],
  58. ['verb_in_xref',
  59. '@node Top
  60. @xref{Top, @verb{*with
  61. verb
  62. ggg *}}.
  63. '],
  64. ['nested_in_sc',
  65. '@sc{@sc{aaa @~n @aa{} @TeX{} @~{@aa{}} @footnote{In footnote}, @abbr{ABr, expl},
  66. @verb{:in verb:}}}
  67. ', {'test_formats' => ['docbook']}],
  68. ['ref_in_style_command', '@samp{@ref{(manula)other node}}.'],
  69. ['uref_in_ref',
  70. '@ref{(file)node, cross ref with uref @uref{href://http/myhost.com/index.html,uref1}, title with uref2 @uref{href://http/myhost.com/index2.html,uref2}, info file with uref3 @uref{href://http/myhost.com/index3.html,uref3}, printed manual with uref4 @uref{href://http/myhost.com/index4.html,uref4}}
  71. '],
  72. ['too_much_args', '@abbr{AZE, A truc Z b, E eep}'],
  73. ['inforef_too_much_args',
  74. '@node chapter
  75. @inforef{chapter, cross ref name, file name, spurious arg}
  76. '],
  77. ['footnote', 'text@footnote{in footnote.
  78. @r{in footnote r}. } after footnote.'],
  79. ['space_in_footnote','text@footnote{ in footnote.}'],
  80. ['footnote_ending_on_empty_line','text@footnote{ in footnote.
  81. }'],
  82. ['heading_in_footnote',
  83. 'T@footnote{
  84. AAA
  85. @heading H1
  86. @cindex ind e
  87. BBB
  88. }
  89. '],
  90. ['footnote_no_node',
  91. '@top top
  92. F@footnote{In footnote}.
  93. '],
  94. ['space_in_image','@image{ a ,bb, cc,dd ,e }. @image{ f }.'],
  95. ['space_command_in_image', '@image{f--ile,,,@ } @image{f--ile,,,@:}'],
  96. ['end_line_in_anchor',
  97. '@anchor{an
  98. anchor}
  99. '],
  100. ['space_in_anchor',
  101. '@anchor{ anchor name }.
  102. '],
  103. ['ctrl',
  104. '
  105. @ctrl{A}
  106. With @ctrl{B}.
  107. '],
  108. ['test_w',
  109. '@w{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbb bbbbb bbb b b b b b b b b b bb .
  110. ccc dddd}.
  111. a a a a a a a a a a a a a a a a a a a a a a a a a a a a @w{b a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
  112. @w{}
  113. @w{ a rr
  114. ggg.}
  115. AA@w{}bbb.
  116. FF@w{d}nnn.
  117. aa@w{ f f}ggg.
  118. aa2@w{ f f }ggg2.
  119. aa3 @w{ f f }ggg3.
  120. aa4 @w{ f f } ggg4.
  121. aa5 @w{} ggg5.
  122. aa6 @w{}ggg6.
  123. aa6@w{} ggg6.
  124. aaf @w{ } bbb.
  125. begin and end quotations: @w{@t{`@w{}`@dots{}\'@w{}\'}}. This
  126. convention should be followed in Texinfo files. TeX converts
  127. two single quotes to left- and right-hand doubled.
  128. '],
  129. ['test_image',
  130. '@macro files-char
  131. @image{f@@i--le@/.@. a@@<"%@@@verb{: < & @ % " :} ,,,,ext@@i--le@/.@. a@@<"%@@@verb{: < & @ % " :}}
  132. In text @image{f@@i--le@/.@. a@@<"%@@@verb{: < & @ % " :} ,1in, 1cm, alt @b{@^{@dotless{i}}--le@/.@.} a@*<"%@@@verb{: < & @ % " :} ,ext@@i--le@/.@. a@@<"%@@@verb{: < & @ % " :}}.
  133. @end macro
  134. @copying
  135. Text in copying.
  136. @files-char{}
  137. @end copying
  138. @node Top
  139. @files-char{}
  140. Insertcopying
  141. @insertcopying
  142. @example
  143. @files-char{}
  144. @end example
  145. @float Image, Image with commands
  146. @files-char{}
  147. @caption{@files-char{}}
  148. @end float
  149. @listoffloats Image
  150. ', {'test_formats' => ['html']} ],
  151. ['format_on_first_footnote_line',
  152. 'Texte@footnote{@quotation
  153. in quotation on the first footnote line
  154. @end quotation
  155. }.
  156. Last text @footnote{@example
  157. in example
  158. @end example
  159. }
  160. '],
  161. ['kbd',
  162. 'kbd: @code{in kbd}.
  163. kbd in code: @code{in first @kbd{in nested kbd}}.
  164. kbd in kbd: @kbd{in top kbd @kbd{in nested kbd}}.
  165. kbd in @@example:
  166. @example
  167. in example
  168. @code{in example in kbd}.
  169. @end example
  170. kbd in @@format:
  171. @format
  172. in format
  173. @code{in format in kbd}.
  174. @end format
  175. '],
  176. ['two_footnotes_in_nodes',
  177. $two_footnotes_in_nodes_text,
  178. , {'test_formats' => ['html', 'info']} ],
  179. # FIXME no footnotes text in HTML...
  180. ['two_footnotes_in_nodes_separate',
  181. '@footnotestyle separate
  182. '.$two_footnotes_in_nodes_text,
  183. , {'test_formats' => ['html', 'info']} ],
  184. ['form_feed_in_brace_commands',
  185. '@option{ aa} @anchor{aa} something @email{ aaa, fff}@footnote{
  186. f1 } @footnote{ gg jj}.
  187. ', {'test_formats' => ['xml']}]
  188. );
  189. my @test_invalid = (
  190. ['no_brace', '@TeX and @code code and @footnote footnote ',
  191. {'test_formats' => ['html_text']}
  192. ],
  193. ['no_brace_space_end_line',
  194. '@code {c}.
  195. @TeX
  196. text
  197. @code
  198. Arg.'
  199. ],
  200. ['empty_line_in_anchor',
  201. '@anchor{an
  202. anchor}
  203. '],
  204. ['unmatched_brace','@samp{Closing} @samp{ @} without opening macro }.}'],
  205. ['brace_opened_no_command','anchor{truc@} @anchor{truc}.
  206. @bye'],
  207. ['caption_not_closed',
  208. '@float Text
  209. @caption{Not closed caption
  210. The caption is closed as soon as @@end float is encountered, since
  211. as much as possible is closed in order to find the @@float beginning.
  212. @end float
  213. @bye
  214. '],
  215. ['code_not_closed','@code{in code'],
  216. ['anchor_not_closed',
  217. '@anchor{my anchor
  218. '],
  219. ['footnote_not_closed',
  220. 'AAA@footnote{ in footnote
  221. Second paragraph.
  222. '],
  223. ['math_not_closed','@math{\delta + 2'],
  224. ['math_bracketed_not_closed','@math{{x^i}\over{\tan '],
  225. ['math_bracketed_inside_not_closed','@math{{x^i}\over{\tan}'],
  226. ['math_bracketed_not_closed_next_line',
  227. '@math{aa {
  228. '],
  229. ['unknown_command_with_braces',
  230. 'Unknown thing @thing{}
  231. Unknown macro @unknown{ first paragraph
  232. second paragraph}
  233. @unknown2{ first paragraph
  234. second paragraph
  235. third}
  236. '],
  237. ['footnote_in_command_not_closed',
  238. 'aaa@code{in code@footnote{in footnote'],
  239. ['empty_images',
  240. '@image{}
  241. @image{ ,aa,bb,cc ,dd}
  242. @image{,,,@ }
  243. @image{,,,@:}
  244. '],
  245. ['empty_ref',
  246. '
  247. @ref{} @xref{,,something}. @inforef{ }
  248. @inforef{ , arg}.
  249. '],
  250. ['ref_empty_node',
  251. '
  252. @ref{,,,manual} @ref{,,, , Manual} @inforef{,,imanual}
  253. @xref{ , Bidule, Truc, file, Printed}.
  254. ']
  255. );
  256. our ($arg_test_case, $arg_generate, $arg_debug);
  257. foreach my $test (@test_cases) {
  258. push @{$test->[2]->{'test_formats'}}, 'plaintext';
  259. push @{$test->[2]->{'test_formats'}}, 'html_text';
  260. }
  261. run_all ('coverage_braces', [@test_cases, @test_invalid], $arg_test_case,
  262. $arg_generate, $arg_debug);
  263. 1;