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