Skip to content

Commit 2d08413

Browse files
j6tgitster
authored andcommitted
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>
1 parent bfa7d01 commit 2d08413

File tree

6 files changed

+44
-88
lines changed

6 files changed

+44
-88
lines changed

t/t4018-diff-funcname.sh

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -29,69 +29,6 @@ public class Beer
2929
}
3030
EOF
3131
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
9532

9633
test_expect_funcname () {
9734
lang=${2-java}
@@ -139,38 +76,13 @@ done
13976
test_expect_success 'set up .gitattributes declaring drivers to test' '
14077
cat >.gitattributes <<-\EOF
14178
*.java diff=java
142-
*.perl diff=perl
14379
EOF
14480
'
14581

14682
test_expect_success 'preset java pattern' '
14783
test_expect_funcname "public static void main("
14884
'
14985

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-
17486
test_expect_success 'custom pattern' '
17587
test_config diff.java.funcname "!static
17688
!String

t/t4018/perl-skip-end-of-heredoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sub RIGHT {
2+
my ($n) = @_;
3+
print "ChangeMe";
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sub RIGHT
2+
{
3+
print "ChangeMe\n";
4+
}

0 commit comments

Comments
 (0)