16raw.t 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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. [ 'nested_macros', '@macro truc { arg, ex}
  7. in macro \arg\
  8. @macro othermacro
  9. other macro
  10. @end macro
  11. @macro
  12. @end macro
  13. @end macro
  14. '],
  15. ['misc_raw','
  16. @html
  17. in html <br> @end html
  18. @tex in tex
  19. @end tex
  20. @verbatim
  21. in v---erbatim`` <>
  22. in verbatim2
  23. @end verbatim
  24. ',
  25. {'expanded_formats' => ['tex', 'html']}
  26. ],
  27. ['misc_raw_comments','
  28. @html @c comment space
  29. in html @end html@c comment no space
  30. @tex in tex
  31. @end tex @c comment after end tex
  32. @verbatim
  33. in verbatim @c in verbatim
  34. in verbatim2
  35. @end verbatim
  36. ',
  37. {'expanded_formats' => ['tex', 'html']}
  38. ],
  39. ['raw_in_para',
  40. 'para
  41. @verbatim
  42. in verbatim
  43. @end verbatim
  44. para b html
  45. @html
  46. in html
  47. @end html
  48. in para
  49. para b tex
  50. @tex
  51. in tex1
  52. in tex2
  53. @end tex
  54. End.
  55. ',
  56. {'expanded_formats' => ['tex', 'html']}
  57. ],
  58. ['raw_in_example',
  59. '@example
  60. @html
  61. in html
  62. @end html
  63. @end example
  64. @example
  65. @html
  66. Some html <code>some code</code>.
  67. @end html
  68. @tex
  69. $$
  70. \chi^2 = \sum_{i=1}^N
  71. \left(y_i - (a + b x_i)
  72. \over \sigma_i\right)^2
  73. $$
  74. @end tex
  75. @end example
  76. ',
  77. {'expanded_formats' => ['tex', 'html']}
  78. ],
  79. ['braces_in_tex',
  80. '
  81. @tex
  82. $$
  83. \chi^2 = \sum_{i=1}^N
  84. \left(y_i - (a + b x_i)
  85. \over \sigma_i\right)^2
  86. $$
  87. @end tex
  88. @example
  89. @tex
  90. $$
  91. \chi^2 = \sum_{i=1}^N
  92. \left(y_i - (a + b x_i)
  93. \over \sigma_i\right)^2
  94. $$
  95. @end tex
  96. @end example
  97. ',
  98. {'expanded_formats' => ['tex']}
  99. ],
  100. ['lone_braces_in_html',
  101. '@html
  102. }
  103. @end html
  104. @html
  105. {
  106. @end html
  107. ',
  108. {'expanded_formats' => ['html']}
  109. ],
  110. ['verbatim_and_verbatiminclude',
  111. '@verbatim
  112. In verbatim @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbb
  113. @end verbatim
  114. Text before
  115. @verbatim
  116. in verbatime
  117. @end verbatim
  118. Text after
  119. @quotation
  120. In quotation
  121. @verbatim
  122. In verbatim in quotation
  123. In verbatim @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbb
  124. @end verbatim
  125. @end quotation
  126. Before
  127. @verbatim
  128. In verbatim test text
  129. @end verbatim
  130. After
  131. @verbatiminclude verb.txt
  132. @quotation
  133. In quotation include
  134. @verbatiminclude verb.txt
  135. @end quotation
  136. Before include
  137. @verbatiminclude verb.txt
  138. After
  139. @example
  140. In example
  141. @verbatim
  142. In verbatim in example
  143. In verbatim @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbb
  144. @end verbatim
  145. @end example
  146. @quotation
  147. In quotation with spaces
  148. @verbatim
  149. In verbatim in quotation with spaces
  150. In verbatim @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbb
  151. @end verbatim
  152. @end quotation
  153. @quotation
  154. In quotation
  155. @verbatim
  156. In verbatim in quotation
  157. @end verbatim
  158. in quotation after end verbaatim
  159. @end quotation
  160. '],
  161. ['raw_commands_and_end_of_lines',
  162. '
  163. @html
  164. Surrounded by empty lines.
  165. @end html
  166. Block commands on a line
  167. @html
  168. in block
  169. in block l2
  170. @end html
  171. end commands on a line.
  172. Before the opening command @html
  173. in block
  174. @end html
  175. end commands on a line.
  176. Before the opening command @html
  177. in block
  178. @end html after the closing command.
  179. Before the opening command @html
  180. in block
  181. @end html
  182. . A symbol on a line.
  183. Before the opening command @html
  184. in block
  185. @end html. A symbol after the closing command.
  186. @tex
  187. Surrounded by empty lines.
  188. @end tex
  189. Block commands on a line
  190. @tex
  191. in block
  192. @end tex
  193. end commands on a line.
  194. Before the opening command @tex
  195. in block
  196. @end tex
  197. end commands on a line.
  198. Before the opening command @tex
  199. in block
  200. @end tex after the closing command.
  201. Before the opening command @tex
  202. in block
  203. @end tex
  204. . A symbol on a line.
  205. Before the opening command @tex
  206. in block
  207. @end tex. A symbol after the closing command.
  208. @verbatim
  209. Surrounded by empty lines.
  210. @end verbatim
  211. Block commands on a line
  212. @verbatim
  213. in block
  214. @end verbatim
  215. end commands on a line.
  216. Before the opening command @verbatim
  217. in block
  218. @end verbatim
  219. end commands on a line.
  220. Before the opening command @verbatim
  221. in block
  222. @end verbatim after the closing command.
  223. Before the opening command @verbatim
  224. in block
  225. @end verbatim
  226. . A symbol on a line.
  227. Before the opening command @verbatim
  228. in block
  229. @end verbatim. A symbol after the closing command.
  230. ',
  231. {'expanded_formats' => ['tex', 'html']}
  232. ],
  233. ['inlinefmt',
  234. 'A @inlinefmt{plaintext, plaintext `` @lbracechar{} } a. Now html
  235. @inlinefmt{html, in <i>@acronym{HTML}</i>}.
  236. '],
  237. ['inlineraw',
  238. 'A @inlineraw{plaintext, plaintext `` @lbracechar{} } a. Now html
  239. @inlineraw{html, in <i>@acronym{HTML}</i>}.
  240. '],
  241. ['inline_in_example',
  242. '@example
  243. A @inlineraw{plaintext, plaintext
  244. `` @lbracechar{} } a.
  245. @inlinefmt{plaintext, `` }.
  246. Now html
  247. @inlineraw{html,
  248. in <i>@acronym{HTML}</i>}.
  249. @end example
  250. ',
  251. {'expanded_formats' => ['plaintext', 'html']}
  252. ],
  253. ['raw_in_style',
  254. '@code{
  255. @html
  256. in html
  257. @end html
  258. }'],
  259. ['raw_expanded_in_style',
  260. '@code{
  261. @html
  262. in html
  263. @end html
  264. }',{'expanded_formats' => ['html']}, {'expanded_formats' => ['html']}
  265. ],
  266. ['verbatim_in_brace_command',
  267. '@samp{
  268. @verbatim
  269. in verbatim
  270. @end verbatim
  271. }
  272. '],
  273. );
  274. my @test_invalid = (
  275. ['raw_not_closed',
  276. '@html
  277. This is some html
  278. <address> my address </address>
  279. '],
  280. ['tex_not_closed',
  281. '@tex
  282. This is some \LaTeX{}
  283. ',
  284. {'expanded_formats' => ['tex']}
  285. ],
  286. ['verbatim_not_closed',
  287. '@verbatim
  288. some verbatim @
  289. @macro
  290. '],
  291. ['inlineraw_with_empty_line',
  292. 'A @inlineraw{plaintext, plaintext ``
  293. @lbracechar{} } a. Now html
  294. @inlineraw{html, in
  295. <i>@acronym{HTML}</i>}.
  296. '],
  297. ['inlinefmt_with_empty_line',
  298. 'A @inlinefmt{plaintext, plaintext ``
  299. @lbracechar{} } a. Now html
  300. @inlinefmt{html, in
  301. <i>@acronym{HTML}</i>}.
  302. '],
  303. ['inline_missing_first_arg',
  304. '@inlinefmt{ , aaa}. @inlineraw{, bbb}.
  305. '],
  306. ['beginning_and_end_on_line',
  307. '
  308. @tex in tex @end tex
  309. ',
  310. {'expanded_formats' => ['tex']}
  311. ],
  312. );
  313. my %html_tests = (
  314. 'raw_in_style' => 1,
  315. 'raw_expanded_in_style' => 1,
  316. 'verbatim_in_style' => 1,
  317. 'raw_in_example' => 1,
  318. 'lone_braces_in_html' => 1,
  319. );
  320. foreach my $test (@test_cases) {
  321. $test->[2]->{'test_formats'} = ['plaintext'];
  322. if ($html_tests{$test->[0]}) {
  323. push @{$test->[2]->{'test_formats'}}, 'html_text';
  324. }
  325. }
  326. our ($arg_test_case, $arg_generate, $arg_debug);
  327. run_all ('raw', [@test_cases, @test_invalid], $arg_test_case,
  328. $arg_generate, $arg_debug);