Skip to content

Commit 1cf9384

Browse files
j6tgitster
authored andcommitted
t4034/cpp: actually test that operator tokens are not split
8d96e72 (t4034: bulk verify builtin word regex sanity, 2010-12-18) added many tests with the intent to verify that operators consisting of more than one symbol are kept together. These are tested by probing a transition from, e.g., a!=b to x!=y, which results in the word-diff [-a-]{+x+}!=[-b-]{+y+} But that proves only that the letters and operators are separate tokens. To prove that != is an unseparable token, we have to probe a transition from, e.g., a=b to a!=b having a word-diff a[-=-]{+!=+}b that proves that the ! is not separate from the =. In the post-image, add to or remove from operators a character that turns it into another valid operator. Change the identifiers used around operators such that the diff algorithm does not have an incentive to match, e.g., a<b in one spot in the pre-image with a<b elsewhere in the post-image. Adjust the expected output to match the new differences. Notice that there are some undesirable tokenizations around e, ., and -. This will be addressed in a later change. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 106298f commit 1cf9384

File tree

3 files changed

+39
-60
lines changed

3 files changed

+39
-60
lines changed

t/t4034/cpp/expect

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
<BOLD>diff --git a/pre b/post<RESET>
2-
<BOLD>index 23d5c8a..7e8c026 100644<RESET>
2+
<BOLD>index c5672a2..4229868 100644<RESET>
33
<BOLD>--- a/pre<RESET>
44
<BOLD>+++ b/post<RESET>
5-
<CYAN>@@ -1,19 +1,19 @@<RESET>
5+
<CYAN>@@ -1,16 +1,16 @@<RESET>
66
Foo() : x(0<RED>&&1<RESET><GREEN>&42<RESET>) { <GREEN>bar(x);<RESET> }
77
cout<<"Hello World<RED>!<RESET><GREEN>?<RESET>\n"<<endl;
88
<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>
9+
[a] b<RED>-><RESET><GREEN>->*<RESET>v d<RED>.e<RESET><GREEN>.*e<RESET>
10+
<GREEN>~<RESET>!a <GREEN>!<RESET>~b c<RED>++<RESET><GREEN>+<RESET> d<RED>--<RESET><GREEN>-<RESET> e*<GREEN>*<RESET>f g<RED>&<RESET><GREEN>&&<RESET>h
11+
a<RED>*<RESET><GREEN>*=<RESET>b c<RED>/<RESET><GREEN>/=<RESET>d e<RED>%<RESET><GREEN>%=<RESET>f
12+
a<RED>+<RESET><GREEN>++<RESET>b c<RED>-<RESET><GREEN>--<RESET>d
13+
a<RED><<<RESET><GREEN><<=<RESET>b c<RED>>><RESET><GREEN>>>=<RESET>d
14+
a<RED><<RESET><GREEN><=<RESET>b c<RED><=<RESET><GREEN><<RESET>d e<RED>><RESET><GREEN>>=<RESET>f g<RED>>=<RESET><GREEN>><RESET>h
15+
a<RED>==<RESET><GREEN>!=<RESET>b c<RED>!=<RESET><GREEN>=<RESET>d
16+
a<RED>^<RESET><GREEN>^=<RESET>b c<RED>|<RESET><GREEN>|=<RESET>d e<RED>&&<RESET><GREEN>&=<RESET>f
17+
a<RED>||<RESET><GREEN>|<RESET>b
18+
a?<GREEN>:<RESET>b
19+
a<RED>=<RESET><GREEN>==<RESET>b c<RED>+=<RESET><GREEN>+<RESET>d <RED>e-=f<RESET><GREEN>e-f<RESET> g<RED>*=<RESET><GREEN>*<RESET>h i<RED>/=<RESET><GREEN>/<RESET>j k<RED>%=<RESET><GREEN>%<RESET>l m<RED><<=<RESET><GREEN><<<RESET>n o<RED>>>=<RESET><GREEN>>><RESET>p q<RED>&=<RESET><GREEN>&<RESET>r s<RED>^=<RESET><GREEN>^<RESET>t u<RED>|=<RESET><GREEN>|<RESET>v
20+
a,b<RESET>
21+
a<RED>::<RESET><GREEN>:<RESET>b

t/t4034/cpp/post

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
Foo() : x(0&42) { bar(x); }
22
cout<<"Hello World?\n"<<endl;
33
(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
4+
[a] b->*v d.*e
5+
~!a !~b c+ d- e**f g&&h
6+
a*=b c/=d e%=f
7+
a++b c--d
8+
a<<=b c>>=d
9+
a<=b c<d e>=f g>h
10+
a!=b c=d
11+
a^=b c|=d e&=f
12+
a|b
13+
a?:b
14+
a==b c+d e-f g*h i/j k%l m<<n o>>p q&r s^t u|v
15+
a,b
16+
a:b

t/t4034/cpp/pre

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
Foo():x(0&&1){}
22
cout<<"Hello World!\n"<<endl;
33
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
4+
[a] b->v d.e
5+
!a ~b c++ d-- e*f g&h
6+
a*b c/d e%f
7+
a+b c-d
8+
a<<b c>>d
9+
a<b c<=d e>f g>=h
10+
a==b c!=d
11+
a^b c|d e&&f
1512
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
13+
a?b
14+
a=b c+=d e-=f g*=h i/=j k%=l m<<=n o>>=p q&=r s^=t u|=v
15+
a,b
1916
a::b

0 commit comments

Comments
 (0)