t4018: convert perl pattern tests to the new infrastructure

There is one subtlety: The old test case 'perl pattern gets full line of POD header' does not have its own new test case, but the feature is tested nevertheless by placing the RIGHT tag at the end of the expected hunk header in t4018/perl-skip-sub-in-pod. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Mar 21, 2014 at 22:07 UTC 2d08413ba1ce0a1940e97a5a8af5faf40ab8d178
6 files changed +44 -88
t/t4018-diff-funcname.sh
-88
@@ -29,69 +29,6 @@ public class Beer
29 }
30 EOF
31 sed 's/beer\\/beer,\\/' <Beer.java >Beer-correct.java
32 -cat >Beer.perl <<\EOT
33 -package Beer;
34 -
35 -use strict;
36 -use warnings;
37 -use parent qw(Exporter);
38 -our @EXPORT_OK = qw(round finalround);
39 -
40 -sub other; # forward declaration
41 -
42 -# hello
43 -
44 -sub round {
45 - my ($n) = @_;
46 - print "$n bottles of beer on the wall ";
47 - print "$n bottles of beer\n";
48 - print "Take one down, pass it around, ";
49 - $n = $n - 1;
50 - print "$n bottles of beer on the wall.\n";
51 -}
52 -
53 -sub finalround
54 -{
55 - print "Go to the store, buy some more\n";
56 - print "99 bottles of beer on the wall.\n");
57 -}
58 -
59 -sub withheredocument {
60 - print <<"EOF"
61 -decoy here-doc
62 -EOF
63 - # some lines of context
64 - # to pad it out
65 - print "hello\n";
66 -}
67 -
68 -__END__
69 -
70 -=head1 NAME
71 -
72 -Beer - subroutine to output fragment of a drinking song
73 -
74 -=head1 SYNOPSIS
75 -
76 - use Beer qw(round finalround);
77 -
78 - sub song {
79 - for (my $i = 99; $i > 0; $i--) {
80 - round $i;
81 - }
82 - finalround;
83 - }
84 -
85 - song;
86 -
87 -=cut
88 -EOT
89 -sed -e '
90 - s/hello/goodbye/
91 - s/beer\\/beer,\\/
92 - s/more\\/more,\\/
93 - s/song;/song();/
94 -' <Beer.perl >Beer-correct.perl
32
33 test_expect_funcname () {
34 lang=${2-java}
@@ -139,7 +76,6 @@ done
76 test_expect_success 'set up .gitattributes declaring drivers to test' '
77 cat >.gitattributes <<-\EOF
78 *.java diff=java
142 - *.perl diff=perl
79 EOF
80 '
81
@@ -147,30 +83,6 @@ test_expect_success 'preset java pattern' '
83 test_expect_funcname "public static void main("
84 '
85
150 -test_expect_success 'preset perl pattern' '
151 - test_expect_funcname "sub round {\$" perl
152 -'
153 -
154 -test_expect_success 'perl pattern accepts K&R style brace placement, too' '
155 - test_expect_funcname "sub finalround\$" perl
156 -'
157 -
158 -test_expect_success 'but is not distracted by end of <<here document' '
159 - test_expect_funcname "sub withheredocument {\$" perl
160 -'
161 -
162 -test_expect_success 'perl pattern is not distracted by sub within POD' '
163 - test_expect_funcname "=head" perl
164 -'
165 -
166 -test_expect_success 'perl pattern gets full line of POD header' '
167 - test_expect_funcname "=head1 SYNOPSIS\$" perl
168 -'
169 -
170 -test_expect_success 'perl pattern is not distracted by forward declaration' '
171 - test_expect_funcname "package Beer;\$" perl
172 -'
173 -
86 test_expect_success 'custom pattern' '
87 test_config diff.java.funcname "!static
88 !String
t/t4018/perl-skip-end-of-heredoc new
+8
@@ -0,0 +1,8 @@
1 +sub RIGHTwithheredocument {
2 + print <<"EOF"
3 +decoy here-doc
4 +EOF
5 + # some lines of context
6 + # to pad it out
7 + print "ChangeMe\n";
8 +}
t/t4018/perl-skip-forward-decl new
+10
@@ -0,0 +1,10 @@
1 +package RIGHT;
2 +
3 +use strict;
4 +use warnings;
5 +use parent qw(Exporter);
6 +our @EXPORT_OK = qw(round finalround);
7 +
8 +sub other; # forward declaration
9 +
10 +# ChangeMe
t/t4018/perl-skip-sub-in-pod new
+18
@@ -0,0 +1,18 @@
1 +=head1 NAME
2 +
3 +Beer - subroutine to output fragment of a drinking song
4 +
5 +=head1 SYNOPSIS_RIGHT
6 +
7 + use Beer qw(round finalround);
8 +
9 + sub song {
10 + for (my $i = 99; $i > 0; $i--) {
11 + round $i;
12 + }
13 + finalround;
14 + }
15 +
16 + ChangeMe;
17 +
18 +=cut
t/t4018/perl-sub-definition new
+4
@@ -0,0 +1,4 @@
1 +sub RIGHT {
2 + my ($n) = @_;
3 + print "ChangeMe";
4 +}
t/t4018/perl-sub-definition-kr-brace new
+4
@@ -0,0 +1,4 @@
1 +sub RIGHT
2 +{
3 + print "ChangeMe\n";
4 +}