3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='Test custom diff function name patterns'
16 public static void main
(String args
[])
19 for(int x
= 99; x
> 0; x--
)
21 System.out.print
(x
+ " bottles of beer on the wall "
22 + x
+ " bottles of beer\n"
23 + "Take one down, pass it around, " + (x
- 1)
24 + " bottles of beer on the wall.\n");
26 System.out.print
("Go to the store, buy some more,\n"
27 + "99 bottles of beer on the wall.\n");
31 sed 's/beer\\/beer,\\/' <Beer.java
>Beer-correct.java
37 use parent qw
(Exporter
);
38 our @EXPORT_OK
= qw
(round
);
42 print
"$n bottles of beer on the wall ";
43 print
"$n bottles of beer\n";
44 print
"Take one down, pass it around, ";
46 print
"$n bottles of beer on the wall.\n";
53 Beer
- subroutine to output fragment of a drinking song
60 for (my
$i = 99; $i > 0; $i--) {
72 ' <Beer.perl
>Beer-correct.perl
75 git config
"$1" "$2" &&
76 test_when_finished
"git config --unset $1"
79 test_expect_funcname
() {
81 test_expect_code
1 git
diff --no-index -U1 \
82 "Beer.$lang" "Beer-correct.$lang" >diff &&
83 grep "^@@.*@@ $1" diff
86 for p
in bibtex cpp csharp fortran html java objc pascal perl php python ruby tex
88 test_expect_success
"builtin $p pattern compiles" '
89 echo "*.java diff=$p" >.gitattributes &&
90 test_expect_code 1 git diff --no-index \
91 Beer.java Beer-correct.java 2>msg &&
95 test_expect_success
"builtin $p wordRegex pattern compiles" '
96 echo "*.java diff=$p" >.gitattributes &&
97 test_expect_code 1 git diff --no-index --word-diff \
98 Beer.java Beer-correct.java 2>msg &&
104 test_expect_success
'default behaviour' '
105 rm -f .gitattributes &&
106 test_expect_funcname "public class Beer\$"
109 test_expect_success
'set up .gitattributes declaring drivers to test' '
110 cat >.gitattributes <<-\EOF
116 test_expect_success
'preset java pattern' '
117 test_expect_funcname "public static void main("
120 test_expect_success
'preset perl pattern' '
121 test_expect_funcname "sub round {\$" perl
124 test_expect_success
'perl pattern is not distracted by sub within POD' '
125 test_expect_funcname "=head" perl
128 test_expect_success
'perl pattern gets full line of POD header' '
129 test_expect_funcname "=head1 SYNOPSIS\$" perl
132 test_expect_success
'custom pattern' '
133 test_config diff.java.funcname "!static
136 test_expect_funcname "int special;\$"
139 test_expect_success
'last regexp must not be negated' '
140 test_config diff.java.funcname "!static" &&
141 test_expect_code 128 git diff --no-index Beer.java Beer-correct.java 2>msg &&
142 grep ": Last expression must not be negated:" msg
145 test_expect_success
'pattern which matches to end of line' '
146 test_config diff.java.funcname "Beer\$" &&
147 test_expect_funcname "Beer\$"
150 test_expect_success
'alternation in pattern' '
151 test_config diff.java.funcname "Beer$" &&
152 test_config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
153 test_expect_funcname "public static void main("