blob: 55680f04121b86ff40e50fcc43d6f59a78697f24 (
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
|
/*******************************************************************************
* Copyright (c) 2004 IBM
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
*
* Contributors:
* Andy Clement - initial API and implementation
*******************************************************************************/
package org.aspectj.systemtest.ajc150;
import org.aspectj.testing.XMLBasedAjcTestCase;
import junit.framework.Test;
/**
* Enums, the rules/tests:
*
* 1. cannot make ITDC on an enum
* 2. cannot make ITDM or ITDF on an enum
* 3. cannot use declare parents to change the super type of an enum
* 4. cannot use decp to make an enum type implement an interface
* 5. cannot use decp to dec java.lang.Enum as the parent of any type
* 6. cannot extend set of values in an enum via an ITD like construct
* 7. Compilation error if you explicitly identify an Enum type.
* 8. Lint warning if a non-explicit type pattern would match an enum type.
*
*/
public class Enums extends XMLBasedAjcTestCase {
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(Enums.class);
}
protected java.net.URL getSpecFile() {
return getClassResource("ajc150.xml");
}
// Cannot make ITDC on an enum
public void test001_itdcsOnEnumNotAllowed() {
runTest("cant itd constructor on enum");
}
// Cannot make ITDM or ITDF on an enum
public void test002_itdFieldOrMethodOnEnumNotAllowed() {
runTest("cant itd field or method on enum");
}
// Deals with the cases where an explicit type is specified and it is an enum type
public void test003_decpOnEnumNotAllowed_errors() {
runTest("declare parents and enums");
}
//Deals with the cases where an wild type pattern is specified and it hits an enum type
public void test004_decpOnEnumNotAllowed_xlints() {
runTest("wildcard enum match in itd");
}
// CompilationResult cR = binaryWeave("testcode.jar","EnumAspect04.aj",0,2,false);
// IMessage msg = (IMessage)cR.getWarningMessages().get(0);
// assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg,
// msg.toString().indexOf("matches a declare parents type pattern")!=-1);
// msg = (IMessage)cR.getWarningMessages().get(1);
// assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg,
// msg.toString().indexOf("matches a declare parents type pattern")!=-1);
// verifyWeavingMessagesOutput(cR,new String[]{});
// }
}
|