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 finalround
);
40 sub other
; # forward declaration
46 print
"$n bottles of beer on the wall ";
47 print
"$n bottles of beer\n";
48 print
"Take one down, pass it around, ";
50 print
"$n bottles of beer on the wall.\n";
55 print
"Go to the store, buy some more\n";
56 print
"99 bottles of beer on the wall.\n");
63 Beer
- subroutine to output fragment of a drinking song
67 use Beer qw
(round finalround
);
70 for (my
$i = 99; $i > 0; $i--) {
85 ' <Beer.perl
>Beer-correct.perl
88 git config
"$1" "$2" &&
89 test_when_finished
"git config --unset $1"
92 test_expect_funcname
() {
94 test_expect_code
1 git
diff --no-index -U1 \
95 "Beer.$lang" "Beer-correct.$lang" >diff &&
96 grep "^@@.*@@ $1" diff
99 for p
in bibtex cpp csharp fortran html java objc pascal perl php python ruby tex
101 test_expect_success
"builtin $p pattern compiles" '
102 echo "*.java diff=$p" >.gitattributes &&
103 test_expect_code 1 git diff --no-index \
104 Beer.java Beer-correct.java 2>msg &&
108 test_expect_success
"builtin $p wordRegex pattern compiles" '
109 echo "*.java diff=$p" >.gitattributes &&
110 test_expect_code 1 git diff --no-index --word-diff \
111 Beer.java Beer-correct.java 2>msg &&
117 test_expect_success
'default behaviour' '
118 rm -f .gitattributes &&
119 test_expect_funcname "public class Beer\$"
122 test_expect_success
'set up .gitattributes declaring drivers to test' '
123 cat >.gitattributes <<-\EOF
129 test_expect_success
'preset java pattern' '
130 test_expect_funcname "public static void main("
133 test_expect_success
'preset perl pattern' '
134 test_expect_funcname "sub round {\$" perl
137 test_expect_success
'perl pattern accepts K&R style brace placement, too' '
138 test_expect_funcname "sub finalround\$" perl
141 test_expect_success
'perl pattern is not distracted by sub within POD' '
142 test_expect_funcname "=head" perl
145 test_expect_success
'perl pattern gets full line of POD header' '
146 test_expect_funcname "=head1 SYNOPSIS\$" perl
149 test_expect_success
'perl pattern is not distracted by forward declaration' '
150 test_expect_funcname "package Beer;\$" perl
153 test_expect_success
'custom pattern' '
154 test_config diff.java.funcname "!static
157 test_expect_funcname "int special;\$"
160 test_expect_success
'last regexp must not be negated' '
161 test_config diff.java.funcname "!static" &&
162 test_expect_code 128 git diff --no-index Beer.java Beer-correct.java 2>msg &&
163 grep ": Last expression must not be negated:" msg
166 test_expect_success
'pattern which matches to end of line' '
167 test_config diff.java.funcname "Beer\$" &&
168 test_expect_funcname "Beer\$"
171 test_expect_success
'alternation in pattern' '
172 test_config diff.java.funcname "Beer$" &&
173 test_config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
174 test_expect_funcname "public static void main("