|
|
@@ -9,7 +9,10 @@ package net.ranides.assira.reflection;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.lang.reflect.Parameter;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
+import java.util.TreeMap;
|
|
|
import net.ranides.test.mockup.reflection.ForClassTraits;
|
|
|
+import org.junit.Ignore;
|
|
|
import org.junit.Test;
|
|
|
import static net.ranides.assira.junit.NewAssert.*;
|
|
|
import static net.ranides.assira.reflection.IAttributes.*;
|
|
|
@@ -32,10 +35,10 @@ public class IAttributeTest {
|
|
|
|
|
|
@Test
|
|
|
public void testType() {
|
|
|
- IAttributes ex1 = of(DECLARED, PUBLIC);
|
|
|
- IAttributes ex2 = of(DECLARED, PRIVATE);
|
|
|
- IAttributes ex3 = of(DECLARED, PACKAGE, STATIC, ABSTRACT, INTERFACE);
|
|
|
- IAttributes ex4 = of(DECLARED, PACKAGE, FINAL);
|
|
|
+ IAttributes ex1 = of(DECLARED, PUBLIC, RESOLVED);
|
|
|
+ IAttributes ex2 = of(DECLARED, PRIVATE, RESOLVED);
|
|
|
+ IAttributes ex3 = of(DECLARED, PACKAGE, STATIC, ABSTRACT, INTERFACE, RESOLVED);
|
|
|
+ IAttributes ex4 = of(DECLARED, PACKAGE, FINAL, RESOLVED);
|
|
|
|
|
|
assertEquals(ex1, of(ForClassTraits.PUBLIC));
|
|
|
assertEquals(ex2, of(ForClassTraits.PRIVATE));
|
|
|
@@ -46,7 +49,7 @@ public class IAttributeTest {
|
|
|
@Test
|
|
|
public void testTypeParameterized() {
|
|
|
IAttributes ex1 = of(DECLARED, PACKAGE, PARAMETERIZED);
|
|
|
- IAttributes ex2 = of(DECLARED, PACKAGE);
|
|
|
+ IAttributes ex2 = of(DECLARED, PACKAGE, RESOLVED);
|
|
|
|
|
|
assertEquals(ex1, of(ForClassTraits.PARAMS));
|
|
|
assertEquals(ex2, of(ForClassTraits.NO_PARAMS));
|
|
|
@@ -105,6 +108,32 @@ public class IAttributeTest {
|
|
|
assertEquals(ex2, of($param(ForMethodUtils.MCP.class, "fun6", 2)));
|
|
|
assertEquals(ex1, of($param(ForMethodUtils.MCP.class, "fun7", 0)));
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testResolved() {
|
|
|
+ IAttributes ex1 = of(DECLARED, RESOLVED);
|
|
|
+
|
|
|
+ assertTrue(ex1.contains(RESOLVED));
|
|
|
+ assertTrue(ex1.contains(DECLARED));
|
|
|
+
|
|
|
+ assertFalse(ex1.contains(PRIVATE));
|
|
|
+ assertFalse(ex1.contains(PROTECTED));
|
|
|
+ assertFalse(ex1.contains(PACKAGE));
|
|
|
+ assertFalse(ex1.contains(PUBLIC));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Ignore("manual")
|
|
|
+ @Test
|
|
|
+ public void dumpMask() {
|
|
|
+ Map<Integer, IAttribute> map = new TreeMap<>();
|
|
|
+ for(IAttribute attr : IAttribute.values()) {
|
|
|
+ map.put(attr.mask, attr);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (IAttribute attr : map.values()) {
|
|
|
+ System.out.printf("%08x %s%n", attr.mask, attr.name());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private static Method $method(Class<?> type, String name) {
|
|
|
return IClass.typeinfo(type).methods().require(DECLARED).require(name).first().get().reflective();
|