Skip to content

Commit 8d96e72

Browse files
trastgitster
authored andcommitted
t4034: bulk verify builtin word regex sanity
The builtin word regexes should be tested with some simple examples against simple issues. Do this in bulk. Mainly due to a lack of language knowledge and inspiration, most of the test cases (cpp, csharp, java, objc, pascal, php, python, ruby) are directly based off a C operator precedence table to verify that all operators are split correctly. This means that they are probably incomplete or inaccurate except for 'cpp' itself. Still, they are good enough to already have uncovered a typo in the python and ruby patterns. 'fortran' is based on my anecdotal knowledge of the DO10I parsing rules, and thus probably useless. The rest (bibtex, html, tex) are an ad-hoc test of what I consider important splits in those languages. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent adf872e commit 8d96e72

File tree

37 files changed

+668
-0
lines changed

37 files changed

+668
-0
lines changed

t/t4034-diff-words.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,4 +331,19 @@ test_expect_success '--word-diff=none' '
331331
332332
'
333333

334+
word_diff_for_language () {
335+
cp "$TEST_DIRECTORY/t4034/$1/pre" \
336+
"$TEST_DIRECTORY/t4034/$1/post" \
337+
"$TEST_DIRECTORY/t4034/$1/expect" . &&
338+
echo "* diff=$1" >.gitattributes &&
339+
word_diff --color-words && cp output output.$1
340+
}
341+
342+
for lang_dir in $TEST_DIRECTORY/t4034/*; do
343+
lang=${lang_dir#$TEST_DIRECTORY/t4034/}
344+
test_expect_success "diff driver '$lang' has sane word regex" "
345+
word_diff_for_language $lang
346+
"
347+
done
348+
334349
test_done

t/t4034/bibtex/expect

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<BOLD>diff --git a/pre b/post<RESET>
2+
<BOLD>index 95cd55b..ddcba9b 100644<RESET>
3+
<BOLD>--- a/pre<RESET>
4+
<BOLD>+++ b/post<RESET>
5+
<CYAN>@@ -1,9 +1,10 @@<RESET>
6+
@article{aldous1987uie,<RESET>
7+
title={{Ultimate instability of exponential back-off protocol for acknowledgment-based transmission control of random access communication channels}},<RESET>
8+
author={Aldous, <RED>D.<RESET><GREEN>David<RESET>},
9+
journal={Information Theory, IEEE Transactions on},<RESET>
10+
volume={<RED>33<RESET><GREEN>Bogus.<RESET>},
11+
number={<RED>2<RESET><GREEN>4<RESET>},
12+
pages={219--223},<RESET>
13+
year=<GREEN>1987,<RESET>
14+
<GREEN> note={This is in fact a rather funny read since ethernet works well in practice. The<RESET> {<RED>1987<RESET><GREEN>\em pre} reference is the right one, however.<RESET>}<RED>,<RESET>
15+
}<RESET>

t/t4034/bibtex/post

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@article{aldous1987uie,
2+
title={{Ultimate instability of exponential back-off protocol for acknowledgment-based transmission control of random access communication channels}},
3+
author={Aldous, David},
4+
journal={Information Theory, IEEE Transactions on},
5+
volume={Bogus.},
6+
number={4},
7+
pages={219--223},
8+
year=1987,
9+
note={This is in fact a rather funny read since ethernet works well in practice. The {\em pre} reference is the right one, however.}
10+
}

t/t4034/bibtex/pre

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@article{aldous1987uie,
2+
title={{Ultimate instability of exponential back-off protocol for acknowledgment-based transmission control of random access communication channels}},
3+
author={Aldous, D.},
4+
journal={Information Theory, IEEE Transactions on},
5+
volume={33},
6+
number={2},
7+
pages={219--223},
8+
year={1987},
9+
}

t/t4034/cpp/expect

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<BOLD>diff --git a/pre b/post<RESET>
2+
<BOLD>index 23d5c8a..7e8c026 100644<RESET>
3+
<BOLD>--- a/pre<RESET>
4+
<BOLD>+++ b/post<RESET>
5+
<CYAN>@@ -1,19 +1,19 @@<RESET>
6+
Foo() : x(0<RED>&&1<RESET><GREEN>&42<RESET>) { <GREEN>bar(x);<RESET> }
7+
cout<<"Hello World<RED>!<RESET><GREEN>?<RESET>\n"<<endl;
8+
<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>'
9+
[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET>
10+
!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET>
11+
<RED>a<RESET><GREEN>y<RESET>
12+
<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET>
13+
<RED>a<RESET><GREEN>y<RESET>
14+
<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET>
15+
<RED>a<RESET><GREEN>y<RESET>
16+
<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b<RESET>
17+
<RED>a<RESET><GREEN>y<RESET>
18+
<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET>
19+
<RED>a<RESET><GREEN>y<RESET>
20+
<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b<RESET>
21+
<RED>a<RESET><GREEN>y<RESET>
22+
<GREEN>x<RESET>&<RED>b<RESET>
23+
<RED>a<RESET><GREEN>y<RESET>
24+
<GREEN>x<RESET>^<RED>b<RESET>
25+
<RED>a<RESET><GREEN>y<RESET>
26+
<GREEN>x<RESET>|<RED>b<RESET>
27+
<RED>a<RESET><GREEN>y<RESET>
28+
<GREEN>x<RESET>&&<RED>b<RESET>
29+
<RED>a<RESET><GREEN>y<RESET>
30+
<GREEN>x<RESET>||<RED>b<RESET>
31+
<RED>a<RESET><GREEN>y<RESET>
32+
<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z
33+
<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET>
34+
<RED>a<RESET><GREEN>y<RESET>
35+
<GREEN>x<RESET>,y
36+
<RED>a<RESET><GREEN>x<RESET>::<RED>b<RESET><GREEN>y<RESET>

t/t4034/cpp/post

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Foo() : x(0&42) { bar(x); }
2+
cout<<"Hello World?\n"<<endl;
3+
(1) (-1e10) (0xabcdef) 'y'
4+
[x] x->y x.y
5+
!x ~x x++ x-- x*y x&y
6+
x*y x/y x%y
7+
x+y x-y
8+
x<<y x>>y
9+
x<y x<=y x>y x>=y
10+
x==y x!=y
11+
x&y
12+
x^y
13+
x|y
14+
x&&y
15+
x||y
16+
x?y:z
17+
x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y
18+
x,y
19+
x::y

t/t4034/cpp/pre

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Foo():x(0&&1){}
2+
cout<<"Hello World!\n"<<endl;
3+
1 -1e10 0xabcdef 'x'
4+
[a] a->b a.b
5+
!a ~a a++ a-- a*b a&b
6+
a*b a/b a%b
7+
a+b a-b
8+
a<<b a>>b
9+
a<b a<=b a>b a>=b
10+
a==b a!=b
11+
a&b
12+
a^b
13+
a|b
14+
a&&b
15+
a||b
16+
a?b:z
17+
a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b
18+
a,y
19+
a::b

t/t4034/csharp/expect

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<BOLD>diff --git a/pre b/post<RESET>
2+
<BOLD>index 9106d63..dd5f421 100644<RESET>
3+
<BOLD>--- a/pre<RESET>
4+
<BOLD>+++ b/post<RESET>
5+
<CYAN>@@ -1,18 +1,18 @@<RESET>
6+
Foo() : x(0<RED>&&1<RESET><GREEN>&42<RESET>) { <GREEN>bar(x);<RESET> }
7+
cout<<"Hello World<RED>!<RESET><GREEN>?<RESET>\n"<<endl;
8+
<GREEN>(<RESET>1<GREEN>) (<RESET>-1e10<GREEN>) (<RESET>0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>y<RESET>'
9+
[<RED>a<RESET><GREEN>x<RESET>] <RED>a<RESET><GREEN>x<RESET>-><RED>b a<RESET><GREEN>y x<RESET>.<RED>b<RESET><GREEN>y<RESET>
10+
!<RED>a<RESET><GREEN>x<RESET> ~<RED>a a<RESET><GREEN>x x<RESET>++ <RED>a<RESET><GREEN>x<RESET>-- <RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>&<RED>b<RESET>
11+
<RED>a<RESET><GREEN>y<RESET>
12+
<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>%<RED>b<RESET>
13+
<RED>a<RESET><GREEN>y<RESET>
14+
<GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET>
15+
<RED>a<RESET><GREEN>y<RESET>
16+
<GREEN>x<RESET><<<RED>b a<RESET><GREEN>y x<RESET>>><RED>b<RESET>
17+
<RED>a<RESET><GREEN>y<RESET>
18+
<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET>
19+
<RED>a<RESET><GREEN>y<RESET>
20+
<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>!=<RED>b<RESET>
21+
<RED>a<RESET><GREEN>y<RESET>
22+
<GREEN>x<RESET>&<RED>b<RESET>
23+
<RED>a<RESET><GREEN>y<RESET>
24+
<GREEN>x<RESET>^<RED>b<RESET>
25+
<RED>a<RESET><GREEN>y<RESET>
26+
<GREEN>x<RESET>|<RED>b<RESET>
27+
<RED>a<RESET><GREEN>y<RESET>
28+
<GREEN>x<RESET>&&<RED>b<RESET>
29+
<RED>a<RESET><GREEN>y<RESET>
30+
<GREEN>x<RESET>||<RED>b<RESET>
31+
<RED>a<RESET><GREEN>y<RESET>
32+
<GREEN>x<RESET>?<RED>b<RESET><GREEN>y<RESET>:z
33+
<RED>a<RESET><GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>+=<RED>b a<RESET><GREEN>y x<RESET>-=<RED>b a<RESET><GREEN>y x<RESET>*=<RED>b a<RESET><GREEN>y x<RESET>/=<RED>b a<RESET><GREEN>y x<RESET>%=<RED>b a<RESET><GREEN>y x<RESET><<=<RED>b a<RESET><GREEN>y x<RESET>>>=<RED>b a<RESET><GREEN>y x<RESET>&=<RED>b a<RESET><GREEN>y x<RESET>^=<RED>b a<RESET><GREEN>y x<RESET>|=<RED>b<RESET>
34+
<RED>a<RESET><GREEN>y<RESET>
35+
<GREEN>x<RESET>,y

t/t4034/csharp/post

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Foo() : x(0&42) { bar(x); }
2+
cout<<"Hello World?\n"<<endl;
3+
(1) (-1e10) (0xabcdef) 'y'
4+
[x] x->y x.y
5+
!x ~x x++ x-- x*y x&y
6+
x*y x/y x%y
7+
x+y x-y
8+
x<<y x>>y
9+
x<y x<=y x>y x>=y
10+
x==y x!=y
11+
x&y
12+
x^y
13+
x|y
14+
x&&y
15+
x||y
16+
x?y:z
17+
x=y x+=y x-=y x*=y x/=y x%=y x<<=y x>>=y x&=y x^=y x|=y
18+
x,y

t/t4034/csharp/pre

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Foo():x(0&&1){}
2+
cout<<"Hello World!\n"<<endl;
3+
1 -1e10 0xabcdef 'x'
4+
[a] a->b a.b
5+
!a ~a a++ a-- a*b a&b
6+
a*b a/b a%b
7+
a+b a-b
8+
a<<b a>>b
9+
a<b a<=b a>b a>=b
10+
a==b a!=b
11+
a&b
12+
a^b
13+
a|b
14+
a&&b
15+
a||b
16+
a?b:z
17+
a=b a+=b a-=b a*=b a/=b a%=b a<<=b a>>=b a&=b a^=b a|=b
18+
a,y

0 commit comments

Comments
 (0)