summaryrefslogtreecommitdiffstats
path: root/tests/new/ExpandedDotDotPattern.java
blob: 34531abdda891ca3637ff12fd91c07ae1385c115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import org.aspectj.testing.Tester;

public class ExpandedDotDotPattern {
    public static void main(String[] args) {
	new A().foo();
	new B().foo(3);
	new C().foo(3, 3);
	new D().foo(3, 3, 3);
	new E().foo(3, 3, 3, 3);
	new F().foo(3, 3, 3, 3, 3);
	Tester.checkEqual(A.count, 1 + 1 + 1 + 1 + 1, "not enough 0-ary");
	Tester.checkEqual(B.count, 0 + 2 + 3 + 4 + 5, "not enough 1-ary");
	Tester.checkEqual(C.count, 0 + 1 + 4 + 7 + 11, "not enough 2-ary");
	Tester.checkEqual(D.count, 0 + 1 + 3 + 8 + 15, "not enough 3-ary");
	Tester.checkEqual(E.count, 0 + 1 + 3 + 7 + 16, "not enough 4-ary");
	Tester.checkEqual(F.count, 0 + 1 + 3 + 7 + 15, "not enough 5-ary");
    }
}

interface I {
    void inc();
}

class A implements I {
    static int count = 0;
    public void inc() { count++; }
    void foo() {}
}
class B implements I {
    static int count = 0;
    public void inc() { count++; }
    void foo(int a) {}
}
class C implements I {
    static int count = 0;
    public void inc() { count++; }
    void foo(int a, int b) {}
}
class D implements I {
    static int count = 0;
    public void inc() { count++; }
    void foo(int a, int b, int c) {}
}
class E implements I {
    static int count = 0;
    public void inc() { count++; }
    void foo(int a, int b, int c, int d) {}
}
class F implements I {
    static int count = 0;
    public void inc() { count++; }
    void foo(int a, int b, int c, int d, int e) {}
}    


aspect Aspect {
    // zero
    before(I i): this(i) && execution(void foo()) {
	System.out.println(thisJoinPoint); 
        i.inc();
    }

    // one
    before(I i): this(i) && execution(void foo( ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int)) {
	System.out.println("(int)" + thisJoinPoint); 
	i.inc();
    }

    // two
    before(I i): this(i) && execution(void foo( ..,  ..)) { 
	System.out.println("(.., ..)" + thisJoinPoint); 
	i.inc(); 
    }

    before(I i): this(i) && execution(void foo(int,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo( .., int)) { 
	System.out.println("(.., int)" + thisJoinPoint); 
	i.inc();
    }

    before(I i): this(i) && execution(void foo(int, int)) { i.inc(); }

    // three
    before(I i): this(i) && execution(void foo( ..,  ..,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo( ..,  .., int)) { i.inc(); }

    before(I i): this(i) && execution(void foo( .., int,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo( .., int, int)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int,  ..,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int,  .., int)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int, int,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int, int, int)) { i.inc(); }

    // four

    before(I i): this(i) && execution(void foo( ..,  ..,  ..,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo( ..,  ..,  .., int)) { i.inc(); }

    before(I i): this(i) && execution(void foo( ..,  .., int,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo( ..,  .., int, int)) { i.inc(); }

    before(I i): this(i) && execution(void foo( .., int,  ..,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo( .., int,  .., int)) { i.inc(); }

    before(I i): this(i) && execution(void foo( .., int, int,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo( .., int, int, int)) { i.inc(); }


    before(I i): this(i) && execution(void foo(int,  ..,  ..,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int,  ..,  .., int)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int,  .., int,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int,  .., int, int)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int, int,  ..,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int, int,  .., int)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int, int, int,  ..)) { i.inc(); }

    before(I i): this(i) && execution(void foo(int, int, int, int)) { i.inc(); }

}