10menu.t 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  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 $simple_menu_text = '
  6. Before menu.
  7. @menu
  8. comment
  9. * menu entry name : node. description
  10. * node name:: description new
  11. * other entry: node,
  12. * last::
  13. description next line
  14. still description
  15. new comment
  16. * last node entry ::
  17. @end menu
  18. After menu.
  19. ';
  20. my @test_cases = (
  21. ['menu_title_before_entries',
  22. '@node Top
  23. @menu
  24. Horizontal space
  25. * subnode::
  26. @end menu
  27. @node subnode
  28. '],
  29. ['simple', $simple_menu_text],
  30. ['simple_no_menu', $simple_menu_text, {'SHOW_MENU' => 0}, {'SHOW_MENU' => 0}],
  31. ['menu_entry_node',
  32. '@menu
  33. * (f)a1::
  34. * (f)a2::
  35. * (f)a3:: d
  36. * (f)@@a@:::
  37. @end menu
  38. '],
  39. ['menu_entry_node_comments',
  40. '@menu
  41. * (f)a1c::@c c
  42. * (f)a2c:: @c c
  43. * (f)a3c:: d@c c
  44. * (f) a4 :: @c c
  45. @end menu
  46. '],
  47. ['menu_entry_name',
  48. '@menu
  49. * a: (f)b
  50. * a: (f)b1.c,
  51. * a: (f)b2.c,
  52. * a: (f)b3.c, d
  53. * a: (f)b1..
  54. * a : (f) b2 ..
  55. * a.n: (f)b3.. d
  56. * a: (f)b1.c.
  57. * a: (f)b2.c.
  58. * a: (f)b3.c. d
  59. @end menu
  60. '],
  61. ['menu_entry_name_comment',
  62. '@menu
  63. * a: (f)b@c c
  64. * a: (f)b @c c
  65. * a: (f)b1c.c,@c c
  66. * a: (f)b2c.c, @c c
  67. * a: (f)b3c.c, d@c c
  68. @end menu
  69. '],
  70. ['comment_on_menu_line',
  71. '@node Top
  72. @menu @c
  73. * first::
  74. @end menu
  75. @chapter first
  76. @node first
  77. '],
  78. ['invalid_info_menu_entry',
  79. '@node Top
  80. @menu
  81. * (f)@asis{a:}::
  82. * @asis{name:}: (f)node.
  83. * name: (f)@asis{node. }. d
  84. * name: (f)@asis{node,n}. d2
  85. * name: (f)@asis{node n}. d3
  86. @end menu
  87. '],
  88. ['no_colon_in_menu',
  89. '@node Top
  90. @menu
  91. * a
  92. @end menu
  93. '],
  94. ['detailmenu',
  95. '
  96. @menu
  97. * Copying Conditions:: Your rights.
  98. @detailmenu
  99. * detailmenu::
  100. @end detailmenu
  101. @end menu
  102. '],
  103. ['detailmenu_in_description',
  104. '
  105. @menu
  106. * Copying Conditions:: Your rights.
  107. @detailmenu
  108. * detailmenu::
  109. @end detailmenu
  110. @end menu
  111. '],
  112. ['entry_after_detailmenu',
  113. '@node Top
  114. @menu
  115. @detailmenu
  116. * second::
  117. @end detailmenu
  118. Menu comment
  119. * first::
  120. @detailmenu
  121. * second::
  122. @end detailmenu
  123. * second::
  124. @end menu
  125. @node first
  126. @node second
  127. '],
  128. ['detailmenu_on_subnodes',
  129. '@node Top
  130. @top top
  131. @menu
  132. * chapter::
  133. * chapter 2::
  134. @detailmenu
  135. * section::
  136. @end detailmenu
  137. @detailmenu
  138. Chap 2
  139. * section chap 2::
  140. * unnumberedsec::
  141. @end detailmenu
  142. @end menu
  143. @node chapter
  144. @chapter chapter
  145. @menu
  146. * section::
  147. @end menu
  148. @node section
  149. @section section
  150. @node chapter 2
  151. @chapter chapter 2
  152. @menu
  153. * section chap 2::
  154. * unnumberedsec::
  155. @end menu
  156. @node section chap 2
  157. @section section chap 2
  158. @node unnumberedsec
  159. @unnumberedsec unnumberedsec
  160. '],
  161. ['detailmenu_unknown_node',
  162. '@node Top
  163. @menu
  164. @detailmenu
  165. * unknown::
  166. @end detailmenu
  167. @end menu
  168. '],
  169. ['reference_to_external_manual',
  170. '
  171. @node Top
  172. @menu
  173. * (info)::
  174. @end menu
  175. '],
  176. ['menu_entry_no_entry',
  177. '@menu
  178. * a1:
  179. * a2:
  180. * a1c:@c c
  181. * a2c: @c c
  182. * a4@b{a}:
  183. * a5@b{b}: @c c
  184. @end menu
  185. '],
  186. ['menu_entry_no_entry_location',
  187. '@menu
  188. * (manual):: begin description
  189. * not an entry ?
  190. * (manual):: an entry
  191. in description
  192. * and here ?
  193. with text.
  194. * (last manual)::
  195. @end menu
  196. '],
  197. ['example_in_menu_comment',
  198. '@menu
  199. * entry::
  200. @example
  201. in
  202. example
  203. @end example
  204. menu comment.
  205. @end menu
  206. '],
  207. ['dash_in_menu',
  208. '
  209. @menu
  210. * entry---in: (manual)n---ode. description --- in.
  211. comment --- in.
  212. @end menu
  213. '],
  214. ['example_in_menu_description',
  215. '@node Top
  216. @top top
  217. @menu
  218. * (manual)::
  219. @example
  220. in
  221. example
  222. @end example
  223. @end menu
  224. '],
  225. ['block_commands_in_menu_description',
  226. '@node Top
  227. @top top
  228. @menu
  229. * (manual)::
  230. @itemize
  231. @item in item
  232. @end itemize
  233. @table @asis
  234. @item table item
  235. Text.
  236. @end table
  237. @html
  238. <b> in html </b>
  239. @end html
  240. @verbatim
  241. @end verbatim
  242. @end menu
  243. '],
  244. ['verb_in_menu_description',
  245. '@node Top
  246. @top top
  247. @menu
  248. * (manual)::
  249. @verb{: in verb
  250. :}
  251. @end menu
  252. '],
  253. ['inlineraw_in_menu_description',
  254. '@node Top
  255. @top top
  256. @menu
  257. * (manual)::
  258. @inlineraw{html, in inline raw
  259. end inlineraw}
  260. @end menu
  261. '],
  262. ['sc_in_menu',
  263. '
  264. @node Top
  265. @menu
  266. * @sc{value}:@sc{node}. @sc{descrip tion}
  267. @sc{menu comment}
  268. @example
  269. * @sc{menu-example value}:(dir)@sc{menu-example node}. @sc{menu-example descrip tion}
  270. @sc{menu-example comment}
  271. @end example
  272. @end menu
  273. @node @sc{node}
  274. @example
  275. @menu
  276. * @sc{example value}:(dir)@sc{example node}. @sc{example descrip tion}
  277. @sc{example comment}
  278. @end menu
  279. @end example
  280. '],
  281. ['formats_in_menu',
  282. '@node Top
  283. @menu
  284. * (gcc):: text
  285. @table @asis
  286. @item item
  287. * table line::
  288. @end table
  289. * (info)::
  290. @verbatim
  291. some @ verb{x atim
  292. * texinfo:: in @ verbatim
  293. @end verbatim
  294. * (manual2):: %
  295. @html
  296. <i></i>
  297. @end html
  298. Log$
  299. * (truc):: @acronym{description
  300. * acronym::}
  301. @example
  302. * subsubsection::
  303. Menu comment
  304. @end example
  305. @end menu
  306. '],
  307. ['menu_in_example',
  308. '@node Top
  309. @example
  310. @menu
  311. * (entry)::
  312. @cartouche
  313. in cartouche in description in menu in example
  314. @end cartouche
  315. @cartouche
  316. in cartouche in menu comment in menu in example
  317. @end cartouche
  318. * (node) menu:: a node in menu
  319. * a menu name:(other) node.
  320. @end menu
  321. @end example
  322. '],
  323. ['menu_pointing_to_anchor',
  324. '@node Top
  325. @top top
  326. Text
  327. @anchor{An anchor}
  328. @menu
  329. * An anchor:: menu entry pointing to the anchor.
  330. @end menu
  331. ']
  332. );
  333. my @test_invalid = (
  334. ['bad_beginning',
  335. '@menu
  336. *
  337. *
  338. *something::
  339. *@code{in code}::
  340. @end menu'
  341. ],
  342. ['menu_no_closed_after_empty_line',
  343. '@menu
  344. * (manual_in_menu):: desc2
  345. '],
  346. ['menu_no_closed_in_description',
  347. '@menu
  348. * (manual_in_menu):: desc'
  349. ],
  350. ['menu_no_closed_in_entry',
  351. '@menu
  352. * a1:'
  353. ],
  354. ['menu_no_closed_entry_beginning',
  355. '@menu
  356. * node'
  357. ],
  358. ['menu_no_closed_star',
  359. '@menu
  360. * '
  361. ],
  362. ['direntry_dircategory_after_first_node',
  363. '@node Top
  364. @top direntry direcategory after first node
  365. @dircategory Cat
  366. @direntry
  367. * in text: (in_text). in text
  368. @end direntry
  369. '],
  370. ['menu_in_deffn',
  371. '@node Top
  372. @deffn a b c
  373. @menu
  374. * (mynode)::
  375. @end menu
  376. @end deffn
  377. '],
  378. ['multiple_menus',
  379. '@node Top
  380. @menu
  381. * (a)a::
  382. @end menu
  383. @menu
  384. * (b)b::
  385. @end menu
  386. '],
  387. ['empty_menu_entry_name',
  388. '@node Top
  389. @menu
  390. * : (vvv). fff
  391. * :aaa,
  392. @end menu
  393. @node aaa
  394. ']
  395. );
  396. foreach my $test (@test_cases) {
  397. $test->[3]->{'SHOW_MENU'} = 1 if (!defined($test->[3]->{'SHOW_MENU'}));
  398. push @{$test->[2]->{'test_formats'}}, 'plaintext';
  399. push @{$test->[2]->{'test_formats'}}, 'html';
  400. push @{$test->[2]->{'test_formats'}}, 'xml';
  401. }
  402. our ($arg_test_case, $arg_generate, $arg_debug);
  403. run_all ('menu', [@test_cases, @test_invalid], $arg_test_case,
  404. $arg_generate, $arg_debug);