index_before_item.t 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. use strict;
  2. BEGIN {
  3. require Texinfo::ModulePath;
  4. Texinfo::ModulePath::init(undef, undef, 'updirs' => 2);
  5. }
  6. use Test::More;
  7. BEGIN { plan tests => 6; }
  8. use Texinfo::Parser qw(parse_texi_text);
  9. use Texinfo::Common qw(move_index_entries_after_items_in_tree);
  10. use Texinfo::Convert::Texinfo;
  11. use DebugTexinfo::DebugTree;
  12. ok(1);
  13. sub run_test($$$)
  14. {
  15. my $in = shift;
  16. my $out = shift;
  17. my $name = shift;
  18. my $tree = parse_texi_text(undef, $in);
  19. #print STDERR DebugTexinfo::DebugTree::convert(undef, $tree)."\n";
  20. my $corrected_tree = move_index_entries_after_items_in_tree($tree);
  21. my $texi_result = Texinfo::Convert::Texinfo::convert($corrected_tree);
  22. if (!defined($out)) {
  23. print STDERR " --> $name:\n$texi_result";
  24. } else {
  25. is ($texi_result, $out, $name);
  26. }
  27. }
  28. run_test ('@itemize
  29. @c comment
  30. @cindex index entry
  31. @item first
  32. in item
  33. @c comment before index entry
  34. @cindex index in paragraph
  35. @item second
  36. @cindex index before comment
  37. @c comment between index entries
  38. @cindex after comment
  39. @item
  40. third
  41. @end itemize
  42. ', '@itemize
  43. @c comment
  44. @item
  45. @cindex index entry
  46. first
  47. in item
  48. @c comment before index entry
  49. @item
  50. @cindex index in paragraph
  51. second
  52. @item
  53. @cindex index before comment
  54. @c comment between index entries
  55. @cindex after comment
  56. third
  57. @end itemize
  58. ', 'entries before items');
  59. run_test ('@example
  60. @enumerate
  61. @cindex idx
  62. @item it
  63. @cindex ttt
  64. @c comment
  65. @item
  66. two
  67. @c c
  68. @cindex gg
  69. @item
  70. @end itemize
  71. @end example
  72. ','@example
  73. @enumerate
  74. @item
  75. @cindex idx
  76. it
  77. @item
  78. @cindex ttt
  79. @c comment
  80. two
  81. @c c
  82. @item
  83. @cindex gg
  84. ', 'in example');
  85. run_test('
  86. @itemize
  87. @cindex gg
  88. @item
  89. @item
  90. @item
  91. @end itemize
  92. ', '
  93. @itemize
  94. @item
  95. @item
  96. @item
  97. @cindex gg
  98. @end itemize
  99. ', 'empty_items');
  100. run_test('
  101. @itemize
  102. @cindex gg
  103. @item
  104. @c comment
  105. @item
  106. @cindex inter
  107. @item
  108. @c comment
  109. @item
  110. @cindex c
  111. @item
  112. in item
  113. @end itemize
  114. ', '
  115. @itemize
  116. @item
  117. @item
  118. @item
  119. @item
  120. @item
  121. @cindex gg
  122. @c comment
  123. @cindex inter
  124. @c comment
  125. @cindex c
  126. in item
  127. @end itemize
  128. ', 'only comments and index entries in items');
  129. run_test('@itemize i
  130. @c comment in itemize
  131. @item e--mph item
  132. @end itemize
  133. ', '@itemize i
  134. @c comment in itemize
  135. @item e--mph item
  136. @end itemize
  137. ', 'only comment');