09indices.t 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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. ['wrong_synindex',
  7. '@defindex aaa
  8. @synindex aaa aaa'],
  9. ['recursive_synindex',
  10. '@defindex aaa
  11. @defindex bbb
  12. @synindex aaa bbb
  13. @synindex bbb aaa'],
  14. ['complex_recursive_synindex',
  15. '@node Top
  16. @defindex aaa
  17. @defindex bbb
  18. @defindex ccc
  19. @defindex ddd
  20. @defindex eee
  21. @synindex aaa bbb
  22. @synindex bbb aaa
  23. @synindex ccc aaa
  24. @synindex ddd bbb
  25. @eeeindex e before synindex
  26. @synindex eee ddd
  27. @synindex bbb eee
  28. @cccindex c index
  29. @bbbindex b entry
  30. @aaaindex a entry
  31. @dddindex d index
  32. @eeeindex e index
  33. bbb
  34. @printindex bbb
  35. aaa
  36. @printindex aaa
  37. ccc
  38. @printindex ccc
  39. ddd
  40. @printindex ddd
  41. eee
  42. @printindex eee
  43. '],
  44. ['unknown_index_entry',
  45. '@someindex someindex entry.
  46. '],
  47. ['unknown_then_known_index_entry',
  48. '@someindex someindex entry.
  49. @defindex some
  50. @someindex someindex entry.
  51. '],
  52. ['unknown_printindex',
  53. '@printindex bidule'],
  54. ['unknown_synindex',
  55. '@synindex c truc'],
  56. ['print_merged_index',
  57. '@syncodeindex fn cp
  58. @node Top
  59. @printindex fn'],
  60. ['printindex_before_document',
  61. '
  62. @printindex cp
  63. '],
  64. );
  65. my $index_in_footnote_text = '@node Top
  66. @menu
  67. * First::
  68. @end menu
  69. Top node@footnote{in footnote
  70. @cindex index entry in footnote
  71. Blah
  72. Blih
  73. @cindex counting entry
  74. }
  75. @node First
  76. @printindex cp
  77. ';
  78. my @test_formatted = (
  79. ['double_index_entry',
  80. '@node Top
  81. @cindex aaa
  82. Text
  83. @cindex aaa
  84. @menu
  85. * other node::
  86. @end menu
  87. @node other node,,,Top
  88. @cindex aaa
  89. @printindex cp
  90. '],
  91. ['ftable_vtable',
  92. '
  93. @node Top
  94. @ftable @emph
  95. @item function1
  96. @itemx function2x
  97. Text
  98. @item fun3
  99. @end ftable
  100. @vtable @emph
  101. @item var1 @error{}
  102. @itemx varx2
  103. Text
  104. @item var3
  105. @end vtable
  106. @findex function1
  107. @printindex fn
  108. @printindex vr
  109. '],
  110. ['index_entries_locations',
  111. '
  112. @node Top
  113. Initial paragraph.
  114. Paragraph
  115. @cindex entry in paragraph
  116. end paragraph.
  117. @cindex entry at end of paragraph.
  118. New paragraph.
  119. @cindex Entry before paragraph
  120. Another paragraph.
  121. @cindex lone entry
  122. Last paragraph.
  123. @printindex cp
  124. '],
  125. ['syncode_index_print_both',
  126. '@syncodeindex fn cp
  127. @node Top
  128. @cindex c---oncept
  129. @findex f---un
  130. Print fn
  131. @printindex fn
  132. Print vr
  133. @printindex cp
  134. '],
  135. ['index_entry_before_node',
  136. '@node Top
  137. @menu
  138. * first::
  139. * second::
  140. @end menu
  141. @node first,second,,Top
  142. Para.
  143. @cindex lone entry
  144. @node second,,first,Top
  145. @printindex cp
  146. '],
  147. ['printindex_with_space_before',
  148. '@node Top
  149. @cindex index
  150. Text.
  151. @printindex cp
  152. '],
  153. ['image_lines_count',
  154. '@node Top
  155. @image{count_image}
  156. @cindex index entry
  157. @printindex cp
  158. '],
  159. ['image_text_lines_count',
  160. '@node Top
  161. @image{count_image_text}
  162. @cindex index entry
  163. @printindex cp
  164. '],
  165. ['empty_index_entry',
  166. '@node Top
  167. @deffn {} { }
  168. @end deffn
  169. @printindex fn
  170. '],
  171. ['empty_cindex_entry',
  172. '@node Top
  173. @cindex
  174. '],
  175. ['empty_string_index_entry',
  176. '@node Top
  177. @findex @w{}
  178. @ftable @code
  179. @item @w{}
  180. @end ftable
  181. @defun {@w{}} {} {}
  182. @defunx {@w{}} {} {}
  183. @end defun
  184. @printindex fn
  185. '],
  186. ['printindex_index_entry_in_copying',
  187. '@copying
  188. @findex Copying this document
  189. @defun fun arg
  190. @defunx xf arg
  191. Defun
  192. @end defun
  193. @ftable @asis
  194. @item ftable item
  195. @itemx xftable xitem
  196. @end ftable
  197. @printindex fn
  198. @end copying
  199. @node Top
  200. @top top
  201. Top.
  202. @insertcopying
  203. @menu
  204. * chapter::
  205. @end menu
  206. @node chapter
  207. @chapter Chapter
  208. @insertcopying
  209. @printindex fn
  210. '],
  211. ['printindex_index_entry_in_copying_no_insertcopying',
  212. '@copying
  213. @findex Copying this document
  214. @defun fun arg
  215. @defunx xf arg
  216. Defun
  217. @end defun
  218. @ftable @asis
  219. @item ftable item
  220. @itemx xftable xitem
  221. @end ftable
  222. @printindex fn
  223. @end copying
  224. @node Top
  225. @top top
  226. Top.
  227. @menu
  228. * chapter::
  229. @end menu
  230. @node chapter
  231. @chapter Chapter
  232. @printindex fn
  233. '],
  234. ['index_entry_before_first_node',
  235. '
  236. @cindex before nodes
  237. @node Top
  238. @printindex cp
  239. '],
  240. ['index_entry_in_footnote',
  241. '@node Top
  242. Top node@footnote{in footnote
  243. @cindex index entry in footnote
  244. }
  245. @printindex cp
  246. '],
  247. ['index_entry_in_footnote_separate',
  248. '@footnotestyle separate
  249. '.$index_in_footnote_text
  250. ],
  251. ['index_entry_in_footnote_different_node_end',
  252. $index_in_footnote_text
  253. ],
  254. ['printindex_index_entry_in_copying_in_footnote',
  255. '@copying
  256. Copying@footnote{
  257. In footnote
  258. @cindex Copying this document
  259. }.
  260. @printindex cp
  261. @end copying
  262. @node Top
  263. @top top
  264. Top.
  265. @insertcopying
  266. @menu
  267. * chapter::
  268. @end menu
  269. @node chapter
  270. @chapter Chapter
  271. @insertcopying
  272. '],
  273. ['double_syncodeindex',
  274. '@syncodeindex cp fn
  275. @syncodeindex cp fn
  276. @node Top
  277. @cindex cindex entry
  278. @findex findex entry
  279. @printindex fn
  280. @printindex cp
  281. '],
  282. ['syncodeindex_to_plain',
  283. '@syncodeindex ky cp
  284. @node Top
  285. @kindex --k1
  286. @vindex --v
  287. @cindex --c
  288. cp index.
  289. @printindex cp
  290. vr index.
  291. @printindex vr
  292. '],
  293. ['def_syn_indices',
  294. '
  295. @syncodeindex cp fn
  296. @node Top
  297. definedx truc
  298. @defindex truc
  299. after
  300. @trucindex index truc
  301. @defcodeindex codeidx
  302. @codeidxindex a @var{index entry} t@~e @^{@dotless{i}}
  303. @cindex cindex entry
  304. @syncodeindex ky pg
  305. @kindex truc kindex
  306. @pindex pindex codeidx
  307. @synindex truc cp
  308. @defindex abc
  309. @defindex defg
  310. @synindex abc defg
  311. @synindex defg ky
  312. @defgindex defg index entry
  313. @abcindex abc index entry
  314. pg
  315. @printindex pg
  316. ky
  317. @printindex ky
  318. truc
  319. @printindex truc
  320. value truc
  321. @printindex truc
  322. cp
  323. @printindex cp
  324. value cp
  325. @printindex cp
  326. defg
  327. @printindex defg
  328. abc
  329. @printindex abc
  330. fn
  331. @printindex fn
  332. '],
  333. ['default_cp_index_and_one_letter_syncodeindex',
  334. '@node Top
  335. @syncodeindex cp fn
  336. @cindex --cindex
  337. @cpindex --cpindex
  338. @printindex fn
  339. '],
  340. ['same_index_entry_merged_indices',
  341. '@syncodeindex vr fn
  342. @node Top
  343. @top
  344. Text.
  345. @deffn Command mmm-mode @var{arg}
  346. Toggle the state of MMM Mode.
  347. @end deffn
  348. @defvar mmm-mode
  349. This variable represents MMM Mode.
  350. @end defvar
  351. @printindex fn
  352. '],
  353. ['explicit_sort_key',
  354. '@node Top
  355. @top
  356. @defindex SK
  357. @SKindex @sortas{A} bbbbbbb (first)
  358. @SKindex @sortas{B} aaaaaaa (second)
  359. @SKindex @sortas{0} zero sort key
  360. @SKindex @b{aaa @sortas{invalid nesting}}
  361. in a reuglar para @sortas{foo}. @code{inside another @sortas{command}}.
  362. @sortas{and cmd @b{inside}}.
  363. @url{and cmd @sortas{inside}}.
  364. @printindex SK
  365. ']
  366. );
  367. sub encoding_index_text($)
  368. {
  369. my $eacutes = shift;
  370. return
  371. '
  372. @node Top
  373. @top top
  374. @cindex '."$eacutes
  375. ".'@cindex @"{i} @"{i}@"{i}@"{i}
  376. @cindex @^i @^i@^i@^i@^i
  377. @cindex a
  378. @cindex b
  379. @cindex c
  380. @cindex d
  381. @cindex e
  382. @cindex f
  383. @cindex g
  384. @cindex h
  385. @cindex i
  386. @cindex j
  387. @cindex k
  388. @cindex l
  389. @cindex m
  390. @cindex n
  391. @cindex o
  392. @cindex p
  393. @cindex q
  394. @cindex r
  395. @cindex s
  396. @cindex t
  397. @cindex u
  398. @cindex v
  399. @cindex w
  400. @cindex x
  401. @cindex y
  402. @cindex z
  403. @cindex A
  404. @cindex B
  405. @cindex @l{}
  406. @cindex @L{}
  407. @cindex @dotless{i} @dotless{i} (dotless)
  408. @cindex @^{@dotless{i}} @^{@dotless{i}} (dotless)
  409. @cindex @ss{}
  410. @cindex @euro{}
  411. @cindex @AE{}
  412. @cindex @exclamdown{}
  413. @cindex @TH{}
  414. @cindex @DH{}
  415. @cindex @textdegree{}
  416. @cindex 0
  417. @cindex 9
  418. @cindex @quotedblleft{}
  419. @cindex @geq{}
  420. @cindex @comma{}
  421. @cindex ``
  422. @cindex `
  423. @cindex \'
  424. @cindex \'\'
  425. @cindex "
  426. @cindex @@
  427. @cindex --
  428. @cindex ---
  429. @printindex cp
  430. ';
  431. }
  432. my @file_tests = (
  433. ['encoding_index_ascii',
  434. '
  435. @setfilename encoding_index_ascii.info
  436. @documentencoding us-ascii
  437. '.encoding_index_text('@\'e @\'e'), {}, {'ENABLE_ENCODING' => 0}
  438. ],
  439. # \x{e9} is e with a acute
  440. ['encoding_index_latin1',
  441. '
  442. @setfilename encoding_index_latin1.info
  443. @documentencoding iso-8859-1
  444. '.encoding_index_text("\x{e9} \x{e9}"), {}, {'ENABLE_ENCODING' => 0}
  445. ],
  446. ['encoding_index_utf8',
  447. '
  448. @setfilename encoding_index_utf8.info
  449. @documentencoding utf-8
  450. '.encoding_index_text("\x{e9} \x{e9}"), {}, {'ENABLE_ENCODING' => 0}
  451. ],
  452. ['encoding_index_ascii_enable_encoding',
  453. '
  454. @setfilename encoding_index_ascii_enable_encoding.info
  455. @documentencoding us-ascii
  456. '.encoding_index_text('@\'e @\'e'), {}, {'ENABLE_ENCODING' => 1}
  457. ],
  458. # \x{e9} is e with a acute
  459. ['encoding_index_latin1_enable_encoding',
  460. '
  461. @setfilename encoding_index_latin1_enable_encoding.info
  462. @documentencoding iso-8859-1
  463. '.encoding_index_text("\x{e9} \x{e9}"), {}, {'ENABLE_ENCODING' => 1}
  464. ],
  465. ['encoding_index_utf8_enable_encoding',
  466. '
  467. @setfilename encoding_index_utf8_enable_encoding.info
  468. @documentencoding utf-8
  469. '.encoding_index_text("\x{e9} \x{e9}"), {}, {'ENABLE_ENCODING' => 1}
  470. ],
  471. );
  472. foreach my $test (@test_formatted) {
  473. push @{$test->[2]->{'test_formats'}}, 'info';
  474. push @{$test->[2]->{'test_formats'}}, 'plaintext';
  475. push @{$test->[2]->{'test_formats'}}, 'html_text';
  476. }
  477. foreach my $test (@file_tests) {
  478. push @{$test->[2]->{'test_formats'}}, 'file_html';
  479. push @{$test->[2]->{'test_formats'}}, 'file_plaintext';
  480. push @{$test->[2]->{'test_formats'}}, 'file_info';
  481. }
  482. our ($arg_test_case, $arg_generate, $arg_debug);
  483. run_all ('indices', [@test_cases, @test_formatted, @file_tests],
  484. $arg_test_case, $arg_generate, $arg_debug);