Git fork

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>

authored by

Johannes Sixt and committed by
Junio C Hamano
2d08413b bfa7d014

+44 -88
-88
t/t4018-diff-funcname.sh
··· 29 29 } 30 30 EOF 31 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 95 32 96 33 test_expect_funcname () { 97 34 lang=${2-java} ··· 139 76 test_expect_success 'set up .gitattributes declaring drivers to test' ' 140 77 cat >.gitattributes <<-\EOF 141 78 *.java diff=java 142 - *.perl diff=perl 143 79 EOF 144 80 ' 145 81 146 82 test_expect_success 'preset java pattern' ' 147 83 test_expect_funcname "public static void main(" 148 - ' 149 - 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 84 ' 173 85 174 86 test_expect_success 'custom pattern' '
+8
t/t4018/perl-skip-end-of-heredoc
··· 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 + }
+10
t/t4018/perl-skip-forward-decl
··· 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
+18
t/t4018/perl-skip-sub-in-pod
··· 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
+4
t/t4018/perl-sub-definition
··· 1 + sub RIGHT { 2 + my ($n) = @_; 3 + print "ChangeMe"; 4 + }
+4
t/t4018/perl-sub-definition-kr-brace
··· 1 + sub RIGHT 2 + { 3 + print "ChangeMe\n"; 4 + }