aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/AssertInIntro.java
blob: 395eaa0d4d11512dd781f629b612db22e0b60579 (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
import org.aspectj.testing.Tester;

public class AssertInIntro {

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

    static void turnOnAssertions() {
	ClassLoader cl = AssertInIntro.class.getClassLoader();
	cl.setClassAssertionStatus("C", false);
	cl.setClassAssertionStatus("A", true);
    }

    static void runTests() {
	boolean failed = false;
	try {
	    C.foo();
	} catch (AssertionError e) {
	    failed = true;
	}
	Tester.check(failed, "introduced assertions improperly off");

	failed = false;
	try {
	    C.goo();
	} catch (AssertionError e) {
	    failed = true;
	}
	Tester.check(!failed, "non-introduced assertions improperly on");
    }
}

class C {
    static void goo() {
	assert false;
    }
}

aspect A {
    static void C.foo() {
	assert false;
    }
}