Commit | Line | Data |
---|---|---|
34e49164 C |
1 | @ rule1 @ |
2 | identifier C; | |
3 | @@ | |
4 | int C(int i) { | |
5 | ... | |
6 | if(C()) { ... } | |
7 | ... | |
8 | + if(UnitTest()) { | |
9 | + int c; | |
10 | + C(); | |
11 | + } | |
12 | } | |
13 | ||
14 | ||
15 | @@ | |
16 | identifier TestMethod; | |
17 | expression name; | |
18 | statement S1,S2; | |
19 | identifier rule1.C; | |
20 | // if put identifier name; then cocci does not help | |
21 | // to say that there is a partial match :( | |
22 | @@ | |
23 | ||
24 | // int C(int i) { | |
25 | // ... | |
26 | // UnitTestEntry(name); | |
27 | // if(TestMethod()) { ... } | |
28 | // ... | |
29 | // if(UnitTest()) { | |
30 | // int c; | |
31 | // ... | |
32 | //+ c = C(); | |
33 | //+ Console.WriteLine("invoking test", name); | |
34 | //+ c.TestMethod(); | |
35 | // } | |
36 | // } | |
37 | ||
38 | ||
39 | // int C(int i) { | |
40 | // <... UnitTestEntry(...); ...> | |
41 | // UnitTestEntry(name); | |
42 | // if(TestMethod()) { ... } | |
43 | // <... UnitTestEntry(...); ...> | |
44 | // } | |
45 | ||
46 | // or simply (does not work ) | |
47 | ||
48 | // int C(int i) { | |
49 | // <... | |
50 | // UnitTestEntry(name); | |
51 | // if(TestMethod()) { ... } | |
52 | // ...> | |
53 | // } | |
54 | ||
55 | // or | |
56 | ||
57 | int C(int i) { | |
58 | // <... UnitTestEntry(name); if(TestMethod()) { ... } ...> | |
59 | // <... UnitTestEntry(...); if(...) { ... } ...> | |
60 | <... S1 ...> | |
61 | UnitTestEntry(name); if(TestMethod()) { ... } | |
62 | <... S2 ...> | |
63 | // <... UnitTestEntry(...); if(...) { ... } ...> | |
64 | // <... UnitTestEntry(name); if(TestMethod()) { ... } ...> | |
65 | } | |
66 | ||
67 | @@ | |
68 | identifier rule1.C; | |
69 | @@ | |
70 | int C(int i) { | |
71 | ... | |
72 | if(UnitTest()) { | |
73 | int c; | |
74 | ... | |
75 | + c = C(); | |
76 | + Console.WriteLine("invoking test", name); | |
77 | + c.TestMethod(); | |
78 | } | |
79 | } |