automatic_menus.t 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. use strict;
  2. use Test::More;
  3. BEGIN {
  4. require Texinfo::ModulePath;
  5. Texinfo::ModulePath::init(undef, undef, 'updirs' => 2);
  6. }
  7. BEGIN { plan tests => 5; }
  8. use Texinfo::Parser qw(parse_texi_text);
  9. use Texinfo::Transformations;
  10. use Texinfo::Convert::Texinfo;
  11. use Data::Dumper;
  12. ok(1);
  13. sub test($$$)
  14. {
  15. my $in = shift;
  16. my $out = shift;
  17. my $name = shift;
  18. my $parser = Texinfo::Parser::parser();
  19. my $tree = $parser->parse_texi_text($in);
  20. $parser->Texinfo::Structuring::associate_internal_references();
  21. my $sectioning = $parser->Texinfo::Structuring::sectioning_structure($tree);
  22. $parser->Texinfo::Transformations::complete_tree_nodes_menus($tree);
  23. my $texi_result = Texinfo::Convert::Texinfo::convert($tree);
  24. if (!defined($out)) {
  25. print STDERR " --> $name:\n$texi_result";
  26. } else {
  27. is ($texi_result, $out, $name);
  28. }
  29. }
  30. test('@node Top
  31. @top top
  32. @node chap
  33. @chapter chap
  34. ', '@node Top
  35. @top top
  36. @menu
  37. * chap::
  38. @end menu
  39. @node chap
  40. @chapter chap
  41. ', 'simple');
  42. test('@node Top
  43. @top top
  44. @menu
  45. * chap::
  46. * (manual)chap2::
  47. @end menu
  48. @node chap
  49. @chapter chap
  50. @node chap2
  51. @chapter chap2
  52. ', '@node Top
  53. @top top
  54. @menu
  55. * chap::
  56. * (manual)chap2::
  57. * chap2::
  58. @end menu
  59. @node chap
  60. @chapter chap
  61. @node chap2
  62. @chapter chap2
  63. ', 'menu completed after');
  64. test('@node Top
  65. @top top
  66. @menu
  67. * chap2::
  68. @end menu
  69. @node chap
  70. @chapter chap
  71. @node chap2
  72. @chapter chap2
  73. ', '@node Top
  74. @top top
  75. @menu
  76. * chap::
  77. * chap2::
  78. @end menu
  79. @node chap
  80. @chapter chap
  81. @node chap2
  82. @chapter chap2
  83. ', 'menu completed before');
  84. test('@node Top
  85. @top top
  86. @node nchap1
  87. @chapter nchap1
  88. @node nchap2
  89. @chapter nchap2
  90. @part
  91. @node pnchap1
  92. @chapter pnchap1
  93. @node pnchap2
  94. @chapter pnchap2
  95. @node napp
  96. @appendix app
  97. @node nsapp
  98. @section sapp
  99. @node anchap1
  100. @chapter achap1
  101. @part p2
  102. @node apnchap1
  103. @chapter apchap1
  104. ', '@node Top
  105. @top top
  106. @menu
  107. * nchap1::
  108. * nchap2::
  109. * pnchap1::
  110. * pnchap2::
  111. * napp::
  112. * anchap1::
  113. * apnchap1::
  114. @end menu
  115. @node nchap1
  116. @chapter nchap1
  117. @node nchap2
  118. @chapter nchap2
  119. @part
  120. @node pnchap1
  121. @chapter pnchap1
  122. @node pnchap2
  123. @chapter pnchap2
  124. @node napp
  125. @appendix app
  126. @menu
  127. * nsapp::
  128. @end menu
  129. @node nsapp
  130. @section sapp
  131. @node anchap1
  132. @chapter achap1
  133. @part p2
  134. @node apnchap1
  135. @chapter apchap1
  136. ', 'parts');