Wrap.pl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # Copyright (C) 2003-2017 Free Software Foundation, Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2, or (at your option)
  6. # any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. use Automake::Wrap qw/wrap makefile_wrap/;
  16. my $failed = 0;
  17. sub test_wrap
  18. {
  19. my ($in, $exp_out) = @_;
  20. my $out = &wrap (@$in);
  21. if ($out ne $exp_out)
  22. {
  23. print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n";
  24. ++$failed;
  25. }
  26. }
  27. sub test_makefile_wrap
  28. {
  29. my ($in, $exp_out) = @_;
  30. my $out = &makefile_wrap (@$in);
  31. if ($out ne $exp_out)
  32. {
  33. print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n";
  34. ++$failed;
  35. }
  36. }
  37. my @tests = (
  38. [["HEAD:", "NEXT:", "CONT", 13, "v" ,"a", "l", "ue", "s", "values"],
  39. "HEAD:v aCONT
  40. NEXT:l ueCONT
  41. NEXT:sCONT
  42. NEXT:values
  43. "],
  44. [["rule: ", "\t", " \\", 20, "dep1" ,"dep2", "dep3", "dep4", "dep5",
  45. "dep06", "dep07", "dep08"],
  46. "rule: dep1 dep2 \\
  47. \tdep3 dep4 \\
  48. \tdep5 dep06 \\
  49. \tdep07 \\
  50. \tdep08
  51. "],
  52. [["big header:", "big continuation:", " END", 5, "diag1", "diag2", "diag3"],
  53. "big header:diag1 END
  54. big continuation:diag2 END
  55. big continuation:diag3
  56. "],
  57. [["big header:", "cont: ", " END", 16, "word1", "word2"],
  58. "big header: END
  59. cont: word1 END
  60. cont: word2
  61. "],
  62. [["big header:", "", " END", 16, "w1", "w2 ", "w3"],
  63. "big header: END
  64. w1 w2 w3
  65. "]);
  66. my @makefile_tests = (
  67. [["target:"],
  68. "target:
  69. "],
  70. [["target:", "\t"],
  71. "target:
  72. "],
  73. [["target:", "\t", "prereq1", "prereq2"],
  74. "target: prereq1 prereq2
  75. "],
  76. [["target: ", "\t", "this is a long list of prerequisites ending in space",
  77. "so that there is no need for another space before the backslash",
  78. "unlike in the second line"],
  79. "target: this is a long list of prerequisites ending in space \\
  80. \tso that there is no need for another space before the backslash \\
  81. \tunlike in the second line
  82. "]);
  83. test_wrap (@{$_}) foreach @tests;
  84. test_makefile_wrap (@{$_}) foreach @makefile_tests;
  85. exit $failed;
  86. ### Setup "GNU" style for perl-mode and cperl-mode.
  87. ## Local Variables:
  88. ## perl-indent-level: 2
  89. ## perl-continued-statement-offset: 2
  90. ## perl-continued-brace-offset: 0
  91. ## perl-brace-offset: 0
  92. ## perl-brace-imaginary-offset: 0
  93. ## perl-label-offset: -2
  94. ## cperl-indent-level: 2
  95. ## cperl-brace-offset: 0
  96. ## cperl-continued-brace-offset: 0
  97. ## cperl-label-offset: -2
  98. ## cperl-extra-newline-before-brace: t
  99. ## cperl-merge-trailing-else: nil
  100. ## cperl-continued-statement-offset: 2
  101. ## End: