test_tree_copy.t 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 => 3; }
  8. use Texinfo::Parser;
  9. use Texinfo::Convert::Texinfo;
  10. use Data::Dumper;
  11. #use Text::Diff;
  12. ok(1, "modules loading");
  13. my $text = '@setfilename some@@file.ext
  14. @node top
  15. @top in @code{top}
  16. @set truc blah@@@
  17. @menu
  18. Something
  19. * chapter:: description
  20. * name: other chapter.
  21. * lone node::
  22. @end menu
  23. @node chapter
  24. @chapter chap
  25. @part part
  26. @node other chapter, lone node, chapter, Top
  27. @chapter other chap
  28. @node lone node, ,other chapter, Top
  29. @vtable @code
  30. @item item
  31. @end vtable
  32. @multitable @columnfractions 0.8 0.2
  33. @end multitable
  34. @multitable {trc} {bidule}
  35. @item truc @tab bidule
  36. @end multitable
  37. @deffn a {b} c d
  38. @end deffn
  39. @float label, type
  40. @caption{float caption}
  41. @end float
  42. @listoffloats type
  43. @acronym{ABC, a b ccc}.
  44. @cindex cindex
  45. @printindex cp
  46. @quotation trc
  47. @author an authoe
  48. @author second
  49. T
  50. @end quotation
  51. ';
  52. my $tree = Texinfo::Parser::parse_texi_text(undef, $text);
  53. my $reference_associations = {};
  54. my $copy = Texinfo::Common::copy_tree($tree, undef);
  55. my $texi_tree = Texinfo::Convert::Texinfo::convert($tree);
  56. is ($text, $texi_tree, "tree to texi and original match");
  57. my $texi_copy = Texinfo::Convert::Texinfo::convert($copy);
  58. is ($texi_copy, $texi_tree, "tree and copy to texi match");
  59. #{
  60. # local $Data::Dumper::Purity = 1;
  61. # local $Data::Dumper::Indent = 1;
  62. # print STDERR Data::Dumper->Dump([$copy]);
  63. #}
  64. 1;