summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2014-03-21 22:07:16 +0100
committerJunio C Hamano <gitster@pobox.com>2014-03-21 15:02:19 -0700
commit2d08413ba1ce0a1940e97a5a8af5faf40ab8d178 (patch)
tree7e3de158ee47b06eb7322ebdc72bf516c5f36a58
parentbfa7d01413bd02b5b3675ef0e96f764064a13ce8 (diff)
downloadgit-2d08413ba1ce0a1940e97a5a8af5faf40ab8d178.tar.gz
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>
-rwxr-xr-xt/t4018-diff-funcname.sh88
-rw-r--r--t/t4018/perl-skip-end-of-heredoc8
-rw-r--r--t/t4018/perl-skip-forward-decl10
-rw-r--r--t/t4018/perl-skip-sub-in-pod18
-rw-r--r--t/t4018/perl-sub-definition4
-rw-r--r--t/t4018/perl-sub-definition-kr-brace4
6 files changed, 44 insertions, 88 deletions
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index b467d9eb57..c94a5f49d2 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -29,69 +29,6 @@ public class Beer
}
EOF
sed 's/beer\\/beer,\\/' <Beer.java >Beer-correct.java
-cat >Beer.perl <<\EOT
-package Beer;
-
-use strict;
-use warnings;
-use parent qw(Exporter);
-our @EXPORT_OK = qw(round finalround);
-
-sub other; # forward declaration
-
-# hello
-
-sub round {
- my ($n) = @_;
- print "$n bottles of beer on the wall ";
- print "$n bottles of beer\n";
- print "Take one down, pass it around, ";
- $n = $n - 1;
- print "$n bottles of beer on the wall.\n";
-}
-
-sub finalround
-{
- print "Go to the store, buy some more\n";
- print "99 bottles of beer on the wall.\n");
-}
-
-sub withheredocument {
- print <<"EOF"
-decoy here-doc
-EOF
- # some lines of context
- # to pad it out
- print "hello\n";
-}
-
-__END__
-
-=head1 NAME
-
-Beer - subroutine to output fragment of a drinking song
-
-=head1 SYNOPSIS
-
- use Beer qw(round finalround);
-
- sub song {
- for (my $i = 99; $i > 0; $i--) {
- round $i;
- }
- finalround;
- }
-
- song;
-
-=cut
-EOT
-sed -e '
- s/hello/goodbye/
- s/beer\\/beer,\\/
- s/more\\/more,\\/
- s/song;/song();/
-' <Beer.perl >Beer-correct.perl
test_expect_funcname () {
lang=${2-java}
@@ -139,7 +76,6 @@ done
test_expect_success 'set up .gitattributes declaring drivers to test' '
cat >.gitattributes <<-\EOF
*.java diff=java
- *.perl diff=perl
EOF
'
@@ -147,30 +83,6 @@ test_expect_success 'preset java pattern' '
test_expect_funcname "public static void main("
'
-test_expect_success 'preset perl pattern' '
- test_expect_funcname "sub round {\$" perl
-'
-
-test_expect_success 'perl pattern accepts K&R style brace placement, too' '
- test_expect_funcname "sub finalround\$" perl
-'
-
-test_expect_success 'but is not distracted by end of <<here document' '
- test_expect_funcname "sub withheredocument {\$" perl
-'
-
-test_expect_success 'perl pattern is not distracted by sub within POD' '
- test_expect_funcname "=head" perl
-'
-
-test_expect_success 'perl pattern gets full line of POD header' '
- test_expect_funcname "=head1 SYNOPSIS\$" perl
-'
-
-test_expect_success 'perl pattern is not distracted by forward declaration' '
- test_expect_funcname "package Beer;\$" perl
-'
-
test_expect_success 'custom pattern' '
test_config diff.java.funcname "!static
!String
diff --git a/t/t4018/perl-skip-end-of-heredoc b/t/t4018/perl-skip-end-of-heredoc
new file mode 100644
index 0000000000..c22d39b256
--- /dev/null
+++ b/t/t4018/perl-skip-end-of-heredoc
@@ -0,0 +1,8 @@
+sub RIGHTwithheredocument {
+ print <<"EOF"
+decoy here-doc
+EOF
+ # some lines of context
+ # to pad it out
+ print "ChangeMe\n";
+}
diff --git a/t/t4018/perl-skip-forward-decl b/t/t4018/perl-skip-forward-decl
new file mode 100644
index 0000000000..a98cb8bdad
--- /dev/null
+++ b/t/t4018/perl-skip-forward-decl
@@ -0,0 +1,10 @@
+package RIGHT;
+
+use strict;
+use warnings;
+use parent qw(Exporter);
+our @EXPORT_OK = qw(round finalround);
+
+sub other; # forward declaration
+
+# ChangeMe
diff --git a/t/t4018/perl-skip-sub-in-pod b/t/t4018/perl-skip-sub-in-pod
new file mode 100644
index 0000000000..e39f02462e
--- /dev/null
+++ b/t/t4018/perl-skip-sub-in-pod
@@ -0,0 +1,18 @@
+=head1 NAME
+
+Beer - subroutine to output fragment of a drinking song
+
+=head1 SYNOPSIS_RIGHT
+
+ use Beer qw(round finalround);
+
+ sub song {
+ for (my $i = 99; $i > 0; $i--) {
+ round $i;
+ }
+ finalround;
+ }
+
+ ChangeMe;
+
+=cut
diff --git a/t/t4018/perl-sub-definition b/t/t4018/perl-sub-definition
new file mode 100644
index 0000000000..a507d1f645
--- /dev/null
+++ b/t/t4018/perl-sub-definition
@@ -0,0 +1,4 @@
+sub RIGHT {
+ my ($n) = @_;
+ print "ChangeMe";
+}
diff --git a/t/t4018/perl-sub-definition-kr-brace b/t/t4018/perl-sub-definition-kr-brace
new file mode 100644
index 0000000000..330b3df114
--- /dev/null
+++ b/t/t4018/perl-sub-definition-kr-brace
@@ -0,0 +1,4 @@
+sub RIGHT
+{
+ print "ChangeMe\n";
+}