55conditionals.t 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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. [ 'not_set',
  7. '@ifset a
  8. Flag a is set.
  9. @end ifset
  10. '],
  11. ['comment_on_ifset_line',
  12. '@set x
  13. @ifset x@c
  14. Y1
  15. @end ifset
  16. @ifset x@c comm
  17. Y2
  18. @end ifset
  19. @ifset x@c@ggg
  20. Y3
  21. @end ifset
  22. @ifset x @c
  23. Y4
  24. @end ifset
  25. @ifset x @c comm
  26. Y5
  27. @end ifset
  28. @ifset x @c@ggg
  29. Y6
  30. @end ifset
  31. '],
  32. ['nested_ignore',
  33. '@ignore
  34. @ignore
  35. @end ignore
  36. @ignore
  37. @end iftex
  38. @ifinfo
  39. @end ignore
  40. @ignore
  41. @end ifclear
  42. @ifclear
  43. @end ignore
  44. '],
  45. ['empty_set_in_ifset',
  46. '@set a
  47. @ifset a
  48. a is set to:|@value{a}|.
  49. @end ifset'
  50. ],
  51. ['empty_set_in_ifclear',
  52. '@set a
  53. @ifclear a
  54. a is set to:|@value{a}|.
  55. @end ifclear'
  56. ],
  57. ['consecutive_conditionals',
  58. '@ifinfo
  59. in ifinfo
  60. @end ifinfo
  61. @iftex
  62. in iftex
  63. @end iftex
  64. @set b
  65. @ifclear b
  66. in ifclear
  67. @end ifclear
  68. @ifset a
  69. in ifset
  70. @end ifset
  71. '],
  72. ['ifnot_format_conditional',
  73. '@ifnottex
  74. not tex
  75. @end ifnottex
  76. After.'],
  77. ['many_conditionals',
  78. '@html
  79. This is html text.
  80. @end html
  81. @ifhtml
  82. This is ifhtml text.
  83. @end ifhtml
  84. @ifnothtml
  85. This is ifnothtml text.
  86. @end ifnothtml
  87. @ifinfo
  88. This is ifinfo text.
  89. @end ifinfo
  90. @ifnotinfo
  91. This is ifnotinfo text.
  92. @end ifnotinfo
  93. @tex
  94. This is tex text.
  95. @end tex
  96. @iftex
  97. This is iftex text.
  98. @end iftex
  99. @ifnottex
  100. This is ifnottex text.
  101. @end ifnottex
  102. ', { 'expanded_formats' => ['info', 'html'] }],
  103. ['commands_in_ifset',
  104. '
  105. @ifset notset
  106. @definfoenclose
  107. @documentencoding ISO-8859-1
  108. @end ifsettruc
  109. open {
  110. @end ifset
  111. @ifset notset
  112. @example
  113. @copying
  114. @itemize
  115. @table
  116. @bye
  117. @end ifset
  118. '],
  119. ['ifset_in_command',
  120. '
  121. @file{
  122. @ifset x
  123. xset
  124. @end ifset
  125. @ifclear x
  126. xclear
  127. @end ifclear
  128. }
  129. '],
  130. ['ignored_in_ifset',
  131. '
  132. @ifset notset
  133. @ignore
  134. @end ifset
  135. @end ignore
  136. text
  137. @end ifset
  138. @ifset notset
  139. @verbatim
  140. @end ifset
  141. @end verbatim
  142. @end ifset
  143. @ifset notset
  144. @verb{%
  145. @end ifset
  146. %}
  147. @end ifset
  148. '],
  149. ['empty_ifset_in_ifset_no_set',
  150. '
  151. @ifset notset
  152. @verbatim
  153. @ifset
  154. @end verbatim
  155. @end ifset
  156. '],
  157. ['ifclear_in_ifset',
  158. '
  159. @ifset a
  160. @ifclear ok - ok, ignored
  161. @end junky - ok, ignored
  162. @end ifset
  163. @c WRONG - missing @end ifset.
  164. '],
  165. ['ifclear_in_ifset_set',
  166. '
  167. @set a
  168. @ifset a
  169. @ifclear ok @c - ok, ignored
  170. @end junky - ok, ignored
  171. @end ifset
  172. @c WRONG - missing @end ifset.
  173. '],
  174. ['nested_ifset_ifclear',
  175. '
  176. @macro conditionals{}
  177. @ifset somevar
  178. @ifset anothervar
  179. Both somevar and anothervar are set.
  180. @end ifset
  181. @ifclear anothervar
  182. Somevar is set, anothervar is not.
  183. @end ifclear
  184. @end ifset
  185. @end macro
  186. @set somevar
  187. @set anothervar
  188. @conditionals{}
  189. @set somevar
  190. @clear anothervar
  191. @conditionals{}
  192. @clear somevar
  193. @set anothervar
  194. @conditionals{}
  195. @clear somevar
  196. @clear anothervar
  197. @conditionals{}
  198. '],
  199. ['end_ifset_in_format',
  200. '
  201. @set notset
  202. @ifset notset
  203. @ignore
  204. @end ifset
  205. @end ignore
  206. text
  207. @end ifset
  208. @ifset notset
  209. @verbatim
  210. @end ifset
  211. @end verbatim
  212. @end ifset
  213. @ifset notset
  214. @verb{%
  215. @end ifset
  216. %}
  217. @end ifset
  218. '],
  219. ['empty_ifset_in_ifset_set',
  220. '
  221. @set notset
  222. @ifset notset
  223. @verbatim
  224. @ifset
  225. @end verbatim
  226. @end ifset
  227. '],
  228. ['macro_in_ifset',
  229. '
  230. @macro truc {}
  231. truc
  232. @end macro
  233. @ifset a
  234. @unmacro truc
  235. @macro truc{}
  236. in ifset
  237. @end macro
  238. @end ifset
  239. @truc{}
  240. '],
  241. ['macro_in_ifset_set',
  242. '
  243. @set a
  244. @macro truc {}
  245. truc
  246. @end macro
  247. @ifset a
  248. @unmacro truc
  249. @macro truc{}
  250. in ifset
  251. @end macro
  252. @end ifset
  253. @truc{}
  254. '],
  255. ['empty_ifclear',
  256. '@ifclear
  257. Something
  258. @end ifclear
  259. '],
  260. ['empty_ifset',
  261. '@ifset
  262. Something
  263. @end ifset
  264. '],
  265. ['bad_ifset_argument',
  266. '@ifset a|b
  267. Ra&b
  268. @end ifset
  269. '],
  270. ['bad_ifclear_argument',
  271. '
  272. @ifclear #something
  273. R#something
  274. @end ifclear
  275. '],
  276. ['ignore_not_closed',
  277. '@ignore
  278. This is ignored
  279. '],
  280. ['info_ifplaintext',
  281. '
  282. @ifplaintext
  283. this text will only appear in plain text.
  284. @end ifplaintext
  285. ', {'expanded_formats' => ['info']}
  286. ],
  287. ['plaintext_ifinfo',
  288. '
  289. @ifinfo
  290. this text will appear only in Info and plain text.
  291. @end ifinfo
  292. ', {'expanded_formats' => ['plaintext']}
  293. ],
  294. ['ifnotinfo_exception',
  295. '@ifnotinfo
  296. in ifnotinfo
  297. @end ifnotinfo
  298. ', {'expanded_formats' => ['plaintext']}
  299. ],
  300. ['info_ifinfo_ifnotplaintext',
  301. '@ifinfo
  302. @ifnotplaintext
  303. This will be in Info, but not plain text.
  304. @end ifnotplaintext
  305. @end ifinfo
  306. ', {'expanded_formats' => ['info']}
  307. ],
  308. ['plaintext_ifinfo_ifnotplaintext',
  309. '@ifinfo
  310. @ifnotplaintext
  311. This will be in Info, but not plain text.
  312. @end ifnotplaintext
  313. @end ifinfo
  314. ', {'expanded_formats' => ['plaintext']}
  315. ],
  316. ['text_on_conditional_line_expanded',
  317. '@ifnothtml text following ifnothtml,
  318. a
  319. @end ifnothtml
  320. '
  321. ],
  322. ['text_on_conditional_line',
  323. '@ifnothtml text following ifnothtml,
  324. a
  325. @end ifnothtml
  326. ', {'expanded_formats' => ['html']}
  327. ],
  328. ['additional_space_in_end_conditional',
  329. '@ifnothtml
  330. not html
  331. @end ifnothtml
  332. ', {'expanded_formats' => ['html']}
  333. ],
  334. ['additional_space_in_end_conditional_expanded',
  335. '@ifnothtml
  336. not html
  337. @end ifnothtml
  338. '],
  339. ['superfluous_argument_to_end',
  340. '@ifnothtml
  341. not html
  342. @end ifnothtml superfluous
  343. '],
  344. ['conditional_not_closed',
  345. '@ifhtml
  346. in ifhtml
  347. '],
  348. ['end_conditional_not_at_line_begining',
  349. '@ifhtml
  350. inhtml
  351. @end ifhtml
  352. '],
  353. ['command_conditionals',
  354. '@ifset txicommandconditionals
  355. Good, the txicommandconditionals variable was set.
  356. @end ifset
  357. @ifcommanddefined nodexyz
  358. Bad, @@nodexyz is defined.
  359. @end ifcommanddefined
  360. @ifcommandnotdefined nodexyz
  361. Good, @@nodexyz is not defined.
  362. @end ifcommandnotdefined
  363. @ifcommanddefined node
  364. Good, @@node is defined.
  365. @end ifcommanddefined
  366. @ifcommandnotdefined node
  367. Bad, @@node is not defined.
  368. @end ifcommandnotdefined
  369. @ifcommanddefined mathcode
  370. Unfortunately, @@mathcode is defined.
  371. @end ifcommanddefined
  372. @ifcommandnotdefined mathcode
  373. Happily, @@mathcode is not defined.
  374. @end ifcommandnotdefined
  375. '],
  376. ['command_conditionals_user_defined',
  377. '@macro truc
  378. machin
  379. @end macro
  380. @defindex auth
  381. @definfoenclose infoencl, :,:
  382. @alias strongalias = strong
  383. @ifcommanddefined truc
  384. @@macro truc is defined.
  385. @end ifcommanddefined
  386. @ifcommandnotdefined truc
  387. @@macro truc is wrongly not defined
  388. @end ifcommandnotdefined
  389. @ifcommanddefined authindex
  390. index command @@authindex is defined.
  391. @end ifcommanddefined
  392. @ifcommandnotdefined authindex
  393. index command @@authindex is wrongly not defined
  394. @end ifcommandnotdefined
  395. @ifcommanddefined infoencl
  396. definfoenclose @@infoencl is defined.
  397. @end ifcommanddefined
  398. @ifcommandnotdefined infoencl
  399. definfoenclose @@infoencl is wrongly not defined
  400. @end ifcommandnotdefined
  401. @ifcommanddefined strongalias
  402. strongalias @@alias is defined.
  403. @end ifcommanddefined
  404. @ifcommandnotdefined strongalias
  405. strongalias @@alias is wrongly not defined
  406. @end ifcommandnotdefined
  407. '],
  408. );
  409. for my $test (@test_cases) {
  410. if (!defined $test->[2]->{'expanded_formats'}) {
  411. $test->[2]->{'expanded_formats'} = [];
  412. }
  413. }
  414. our ($arg_test_case, $arg_generate, $arg_debug);
  415. run_all ('conditionals', \@test_cases, $arg_test_case,
  416. $arg_generate, $arg_debug);