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
34 git config "$1" "$2" &&
35 test_when_finished "git config --unset $1"
38 test_expect_funcname () {
39 test_expect_code 1 git diff --no-index \
40 Beer.java Beer-correct.java >diff &&
41 grep "^@@.*@@ $1" diff
44 for p in bibtex cpp csharp fortran html java objc pascal perl php python ruby tex
46 test_expect_success "builtin $p pattern compiles" '
47 echo "*.java diff=$p" >.gitattributes &&
48 test_expect_code 1 git diff --no-index \
49 Beer.java Beer-correct.java 2>msg &&
53 test_expect_success "builtin $p wordRegex pattern compiles" '
54 echo "*.java diff=$p" >.gitattributes &&
55 test_expect_code 1 git diff --no-index --word-diff \
56 Beer.java Beer-correct.java 2>msg &&
62 test_expect_success 'default behaviour' '
63 rm -f .gitattributes &&
64 test_expect_funcname "public class Beer\$"
67 test_expect_success 'set up .gitattributes declaring drivers to test' '
68 echo "*.java diff=java" >.gitattributes
71 test_expect_success 'preset java pattern' '
72 test_expect_funcname "public static void main("
75 test_expect_success 'custom pattern' '
76 test_config diff.java.funcname "!static
79 test_expect_funcname "int special;\$"
82 test_expect_success 'last regexp must not be negated' '
83 test_config diff.java.funcname "!static" &&
84 test_expect_code 128 git diff --no-index Beer.java Beer-correct.java 2>msg &&
85 grep ": Last expression must not be negated:" msg
88 test_expect_success 'pattern which matches to end of line' '
89 test_config diff.java.funcname "Beer\$" &&
90 test_expect_funcname "Beer\$"
93 test_expect_success 'alternation in pattern' '
94 test_config diff.java.funcname "Beer$" &&
95 test_config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
96 test_expect_funcname "public static void main("