summaryrefslogtreecommitdiffstats
path: root/tests/base/test116/Driver.java
blob: b1dc67d7d299654fd7abd2eb3a58d89af882e9b6 (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
import org.aspectj.testing.Tester;

public class Driver {
  public static void main(String[] args) { test(); }

  public static void test() {
    Class c = new Class();
    
    c.l();
    c.l(2);
    c.m(3);

    Tester.checkEqual(Aspect.c1, 3, "Aspect.c1");
    Tester.checkEqual(Aspect.c2, 2, "Aspect.c2");
    Tester.checkEqual(Aspect.c3, 1, "Aspect.c3");
    Tester.checkEqual(Aspect.c4, 2, "Aspect.c4");
  }
}

class Class {
  
  public void l()      throws Error {
      //System.out.println("public void l()    throws Error");
    //throw(new Error ());
  }

  void l(int x)              {
      //System.out.println("       void l(int)");
  }

  public void m(int x) throws Error {
      //System.out.println("public void m(int) throws Error");
    // throw(new Error ());
  }

}

aspect Aspect {
  static int c1, c2, c3, c4 = 0;

   before(): target(Class) && call(void *(..)) { 
      //System.out.println("before Class.*(..)"); 
      c1++;
  }

   before(int x): target(Class) && call(void *(int))&& args(x) { 
      //System.out.println("before Class.*(int)"); 
      c2++;
  }

   before(int x): target(Class) && call(public void *(int)) && args(x){ 
      //System.out.println("before public Class.*(int)"); 
      c3++;
  }

   before(): target(Class) && call(void *(..) throws Error) { 
      //System.out.println("before Class.*(..)  throws Error"); 
      c4++;
  }
}