aboutsummaryrefslogtreecommitdiffstats
path: root/tests/base/test141/Driver.java
blob: 0bf61f906a8d4abdd29ba907a487104b8ad04f9e (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
// thisResultObject for primitives
// I think this is a bad test.  Is there a way to do this?  -eh

import org.aspectj.testing.Tester;

public class Driver {
    public static void test() {
        C1 c1 = new C1();

        c1.getInteger();
        c1.getDouble();
        c1.getVoid();
        c1.getString();
        c1.getBoolean();
    }

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

class C1 {
    int getInteger() {
        return 1;
    }

    double getDouble() {
        return 3.14;
    }

    void getVoid() {
    }

    String getString() {
        return "Hello World";
    }

    boolean getBoolean() {
        return true;
    }
}

aspect A1 {
    // don't advise the finalize reception, or weird interactions with GC can happen
     after() returning (Object result): 
            target(C1) && call(* *()) && !call(void finalize()) {
        if (result == null) {
            Tester.checkEqual(thisJoinPoint.getSignature().getName(), 
                               "getVoid", 
                               "void method");
        } 
        else {
            String resultClassName = result.getClass().getName();

            Tester.checkEqual("java.lang." + 
                                 thisJoinPoint.getSignature().getName().substring(3),
                               resultClassName, 
                               "result object type");
        }
    }
}