Explorar o código

unit-test (fight with jacoco)

ranides %!s(int64=10) %!d(string=hai) anos
pai
achega
4b8d7549a3

+ 1 - 1
assira.asm/pom.xml

@@ -4,7 +4,7 @@
     <parent>
         <groupId>net.ranides</groupId>
         <artifactId>assira.common</artifactId>
-        <version>2.0.0</version>
+        <version>2.0.1</version>
     </parent>
     <groupId>net.ranides</groupId>
     <artifactId>assira.asm</artifactId>

+ 392 - 443
assira/src/test/java/net/ranides/assira/reflection/impl/AClassesTest.java

@@ -1,443 +1,392 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.reflection.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Predicate;
-import net.ranides.assira.TestFiles;
-import net.ranides.assira.annotations.Meta;
-import net.ranides.assira.generic.TypeToken;
-import net.ranides.assira.reflection.IClass;
-import net.ranides.assira.reflection.IClasses;
-import net.ranides.assira.reflection.mockup.ForClassTraits;
-import org.junit.Test;
-import static net.ranides.assira.junit.NewAssert.*;
-import static net.ranides.assira.reflection.IAttribute.*;
-import net.ranides.assira.reflection.IElement;
-import net.ranides.assira.reflection.IMethod;
-import net.ranides.assira.reflection.IMethods;
-import net.ranides.assira.reflection.mockup.ForMemberTraits;
-import net.ranides.assira.reflection.mockup.ForMethodUtils;
-import static net.ranides.assira.reflection.mockup.ForIClass.*;
-import net.ranides.assira.text.Charsets;
-import net.ranides.assira.text.IOStrings;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public class AClassesTest {
-    
-    private static final Predicate<IElement> JACOCO = m -> m.name().startsWith("$jacoco");
-    
-    @Test
-    public void testNames() {
-        IClasses ic = new AClasses(new IClass[]{STRING, INTEGER, NUMBER, T_INTERFACE});
-        
-        List<String> names = Arrays.asList(
-            "java.lang.String", 
-            "java.lang.Integer", 
-            "java.lang.Number", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface"
-        );
-        
-        assertEquals(names, ic.names());
-    }
-    
-    @Test
-    public void testRequire() {
-        
-        List<String> exp1 = Arrays.asList(
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
-        );
-        List<String> exp2 = Arrays.asList(
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
-        );
-        List<String> exp3 = Arrays.asList(
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface"
-        );
-        List<String> exp4 = Arrays.asList(
-            "java.lang.String", "java.lang.Integer"
-        );
-        List<String> exp5 = Arrays.asList(
-            "java.lang.String"
-        );
-        List<String> exp6 = Arrays.asList(
-            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean",
-            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean2"
-        );
-        
-        assertEquals(exp1, iclist().require(Meta.Immutable.class).names());
-        
-        assertEquals(exp1, iclist().require(ANNOTATED_1.annotations()).names());
-        assertEquals(exp2, iclist().require(ANNOTATED_2.annotations()).names());
-        
-        assertEquals(exp3, iclist().require(INTERFACE).names());
-        
-        assertEquals(exp4, iclist().require(collect(PUBLIC, FINAL)).names());
-        
-        IMethod m = STRING.methods().require("valueOf").first();
-        assertEquals(exp5, iclist().require(m).names());
-
-        IClasses ic2 = new AClasses(new IClass[]{INTEGER, BEAN_1, BEAN_2});
-        IMethod m2 = BEAN_1.methods().require("getName1").first();
-        assertEquals(exp6, ic2.require(m2).names());
-
-    }
-    
-    @Test
-    public void testDiscard() {
-        
-        List<String> exp1 = Arrays.asList(
-            "java.lang.String", 
-            "java.lang.Integer", 
-            "java.lang.Number", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface"
-        );
-        List<String> exp2 = Arrays.asList(
-            "java.lang.String", 
-            "java.lang.Integer", 
-            "java.lang.Number", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface",
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1"
-        );
-        List<String> exp3 = Arrays.asList(
-            "java.lang.Number", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
-        );
-        List<String> exp4 = Arrays.asList(
-            "java.lang.Number", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
-        );
-        List<String> exp5 = Arrays.asList(
-            "java.lang.Integer", 
-            "java.lang.Number", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1", 
-            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
-        );
-        List<String> exp6 = Arrays.asList(
-            "java.lang.Integer"
-        );
-        List<String> exp7 = Arrays.asList(
-            "java.lang.String", "java.lang.Integer", "java.lang.Number"
-        );
-        
-        assertEquals(exp1, iclist().discard(Meta.Immutable.class).names());
-        assertEquals(exp2, iclist().discard(Meta.Unsafe.class).names());
-        
-        assertEquals(exp1, iclist().discard(ANNOTATED_1.annotations()).names());
-        assertEquals(exp1, iclist().discard(ANNOTATED_2.annotations()).names());
-        
-        assertEquals(exp3, iclist().discard(FINAL).names());
-        
-        assertEquals(exp4, iclist().discard(collect(PUBLIC,FINAL)).names());
-        
-        IMethod m = STRING.methods().require("valueOf").first();
-        assertEquals(exp5, iclist().discard(m).names());
-
-        IClasses ic2 = new AClasses(new IClass[]{INTEGER, BEAN_1, BEAN_2});
-        IMethod m2 = BEAN_1.methods().require("getName1").first();
-        assertEquals(exp6, ic2.discard(m2).names());
-        
-        assertEquals(exp7, iclist().discard(n -> n.name().startsWith("net.")).names());
-        
-
-    }
-    
-    @Test
-    public void testFields() {
-        List<String> exp1 = Arrays.asList(
-            "CASE_INSENSITIVE_ORDER", 
-            "MIN_VALUE", 
-            "MAX_VALUE", 
-            "TYPE", 
-            "SIZE", 
-            "BYTES"
-        );
-        List<String> exp2 = Arrays.asList(
-            "serialVersionUID",
-            "serialVersionUID",
-            "serialVersionUID",
-            "serialVersionUID",
-            "value",
-            "value",
-            "serialPersistentFields",
-            "hash"
-        );
-        List<String> exp3 = Arrays.asList(
-            "serialVersionUID", 
-            "serialVersionUID", 
-            "serialVersionUID", 
-            "this$0", 
-            "this$0",
-            "value", 
-            "value", 
-            "sizeTable", 
-            "serialPersistentFields", 
-            "hash", 
-            "digits", 
-            "DigitTens", 
-            "DigitOnes", 
-            "TYPE", 
-            "SIZE", 
-            "MIN_VALUE", 
-            "MAX_VALUE", 
-            "CASE_INSENSITIVE_ORDER", 
-            "BYTES"
-        );
-//        iclist().fields().require(PRIVATE).each(System.out::println);
-        
-        assertEquivalent(exp1, iclist().fields().names());
-        assertEquivalent(exp2, iclist().fields().require(PRIVATE).discard(JACOCO).names());
-        assertEquivalent(exp3, iclist().fields().require(DECLARED).discard(JACOCO).names());
-    }
-    
-    @Test
-    public void testConstructors() throws IOException {
-        List<String> exp1 = IOStrings.readLines(TestFiles.CONSTRUCT_1, Charsets.UTF8);
-        List<String> exp2 = IOStrings.readLines(TestFiles.CONSTRUCT_2, Charsets.UTF8);
-        List<String> exp3 = IOStrings.readLines(TestFiles.CONSTRUCT_3, Charsets.UTF8);
-        List<String> exp4 = IOStrings.readLines(TestFiles.CONSTRUCT_4, Charsets.UTF8);
-        List<String> exp5 = IOStrings.readLines(TestFiles.CONSTRUCT_5, Charsets.UTF8);
-        
-//        print(iclist().constructors());
-//        print(iclist().constructors().require(PUBLIC));
-//        print(iclist().constructors().require(DECLARED));
-//        print(iclist().constructors().require(PRIVATE));
-//        print(iclist().constructors().require(PROTECTED));
-//        print(iclist().constructors().require(PACKAGE));
-        
-        assertMethods(exp1, iclist().constructors());
-        assertMethods(exp1, iclist().constructors().require(PUBLIC));
-        assertMethods(exp2, iclist().constructors().require(DECLARED));
-        assertMethods(exp3, iclist().constructors().require(PRIVATE));
-        assertMethods(exp4, iclist().constructors().require(PROTECTED));
-        assertMethods(exp5, iclist().constructors().require(PACKAGE));
-    }
-    
-    @Test
-    public void testMethods() throws IOException {
-        List<String> exp1 = IOStrings.readLines(TestFiles.METHODS_1, Charsets.UTF8);
-        List<String> exp2 = IOStrings.readLines(TestFiles.METHODS_2, Charsets.UTF8);
-        List<String> exp3 = IOStrings.readLines(TestFiles.METHODS_3, Charsets.UTF8);
-        List<String> exp4 = IOStrings.readLines(TestFiles.METHODS_4, Charsets.UTF8);
-        List<String> exp5 = IOStrings.readLines(TestFiles.METHODS_5, Charsets.UTF8);
-        
-//        print(iclist().methods());
-//        print(iclist().methods().require(PUBLIC));
-//        print(iclist().methods().require(DECLARED));
-//        print(iclist().methods().require(PRIVATE));
-//        print(iclist().methods().require(PROTECTED));
-//        print(iclist().methods().require(PACKAGE));
-        
-        assertMethods(exp1, iclist().methods());
-        assertMethods(exp1, iclist().methods().require(PUBLIC));
-        assertMethods(exp2, iclist().methods().require(DECLARED).discard(JACOCO));
-        assertMethods(exp3, iclist().methods().require(PRIVATE).discard(JACOCO));
-        assertMethods(exp4, iclist().methods().require(PROTECTED));
-        assertMethods(exp5, iclist().methods().require(PACKAGE));
-    }
-    
-    @Test
-    public void testParent() {
-        List<String> exp = Arrays.asList(
-            "java.lang.Object",
-            "java.lang.Number",
-            "java.lang.Object",
-            "net.ranides.assira.reflection.mockup.ForMethodUtils$Root",
-            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean",
-            "$NULL"
-        );
-//        print(iclist2().parent());
-        assertClasses(exp, iclist2().parent());
-    }
-    
-    @Test
-    public void testParents() {
-        IClass[] array = new IClass[]{
-            STRING,
-            INTEGER,
-            NUMBER, 
-            IClass.typeinfo(ForMethodUtils.A.class),
-            BEAN_2,
-            INT,
-            IClass.typefor(new ArrayList<Float>() {}),
-            IClass.typefor(new ArrayList<Float>())
-            
-        };
-        List<String> exp1 = Arrays.asList(
-            "java.lang.Object",
-            "java.lang.Number",
-            "java.lang.Object",
-            "java.lang.Object",
-            "net.ranides.assira.reflection.mockup.ForMethodUtils$Root",
-            "java.lang.Object",
-            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean",
-            "java.lang.Object",
-            "java.util.ArrayList<java.lang.Float>",
-            "java.util.AbstractList<java.lang.Float>",
-            "java.util.AbstractCollection<java.lang.Float>",
-            "java.lang.Object",
-            "java.util.AbstractList<E>",
-            "java.util.AbstractCollection<E>",
-            "java.lang.Object"
-        );
-        List<String> exp2 = Arrays.asList(
-            "java.lang.Object",
-            "java.lang.Number",
-            "java.lang.Object",
-            "net.ranides.assira.reflection.mockup.ForMethodUtils$Root",
-            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean",
-            "java.util.ArrayList<java.lang.Float>",
-            "java.util.AbstractList<E>"
-        );
-//        print(new AClasses(array).parents());
-//        print(new AClasses(array).parents().require(DECLARED));
-        assertClasses(exp1, new AClasses(array).parents());
-        assertClasses(exp2, new AClasses(array).parents().require(DECLARED));
-    }
-    
-    @Test
-    public void testInterfaces() {
-        Class<?>[] array = new Class<?>[]{
-            String.class,
-            Integer.class,
-            Number.class, 
-            ForMethodUtils.A.class,
-            ForMemberTraits.Bean2.class,
-            int.class
-        };
-        List<String> exp1 = Arrays.asList(
-            "java.io.Serializable",
-            "java.lang.Comparable<T>",
-            "java.lang.CharSequence",
-            "java.lang.Comparable<T>",
-            "java.io.Serializable",
-            "java.io.Serializable"
-        );
-        List<String> exp2 = Arrays.asList(
-            "java.io.Serializable",
-            "java.lang.Comparable<T>",
-            "java.lang.CharSequence",
-            "java.lang.Comparable<T>",
-            "java.io.Serializable"
-        );
-//        print(IClasses.typeinfo(array).interfaces());
-//        print(IClasses.typeinfo(array).interfaces().require(DECLARED));
-        assertClasses(exp1, IClasses.typeinfo(array).interfaces());
-        assertClasses(exp2, IClasses.typeinfo(array).interfaces().require(DECLARED));
-    }
-    
-    @Test
-    public void testOuter() {
-        List<String> exp = Arrays.asList(
-            "$NULL",
-            "$NULL",
-            "$NULL",
-            "net.ranides.assira.reflection.mockup.ForMethodUtils",
-            "net.ranides.assira.reflection.mockup.ForMemberTraits<Q>",
-            "$NULL"
-        );
-//        print(iclist2().outer());
-        assertClasses(exp, iclist2().outer());
-    }
-    
-    @Test
-    public void testInner() {
-        List<String> exp = Arrays.asList(
-            "java.lang.String$CaseInsensitiveComparator",
-            "java.lang.Integer$IntegerCache"
-        );
-//        print(iclist2().inner());
-        assertClasses(exp, iclist2().inner());
-    }
-    
-    @Test
-    public void testRaw() {
-        IClass[] array = new IClass[]{STRING, INTEGER, NUMBER, T_INTERFACE, ANNOTATED_1, new TypeToken<List<String>>(){}};
-        List<Class<?>> exp = Arrays.asList(
-            String.class, 
-            Integer.class, 
-            Number.class, 
-            ForClassTraits.INTERFACE, 
-            ForClassTraits.CAnnotated1.class,
-            List.class
-        );
-        assertEquals(exp, new AClasses(array).raw().list());
-        assertEquals(exp, new AClasses(array).reflective().list());
-    }
-
-    @Test
-    public void testSubClass() {
-        IClasses a = IClasses.typeinfo(CharSequence.class, Number.class, Integer.class);
-        IClasses b = IClasses.typeinfo(String.class, Integer.class, Integer.class);
-        IClasses c = IClasses.typeinfo(String.class, Integer.class, int.class);
-        
-        assertTrue( b.isSubclass(a) );
-        assertFalse( c.isSubclass(a) );
-        assertTrue( a.isSuper(b) );
-        
-        assertTrue( a.isInstance("", 41.5, 7) );
-        assertTrue( b.isInstance("", 41, 7) );
-        assertTrue( c.isInstance("", 41, 7) );
-        
-        assertFalse( c.isInstance("", 41, 7.0) );
-        assertFalse( c.isInstance("", 41.0, 7) );
-        
-    }
-    
-    private static AClasses iclist() {
-        return new AClasses(new IClass[]{STRING, INTEGER, NUMBER, T_INTERFACE, ANNOTATED_1, ANNOTATED_2});
-    }
-    
-    private static IClasses iclist2() {
-        return IClasses.typeinfo(new Class<?>[]{
-            String.class, 
-            Integer.class, 
-            Number.class, 
-            ForMethodUtils.A.class,
-            ForMemberTraits.Bean2.class,
-            int.class
-        });
-    }
-    
-    private static void print(IMethods methods) {
-        System.out.printf(">>>>%n");
-        methods.each(c -> {
-            System.out.printf("    %s%n", asText(c));
-        });
-    }
-    
-    private static void print(IClasses methods) {
-        System.out.printf(">>>>%n");
-        methods.each(c -> {
-            System.out.printf("   \"%s\",%n", c);
-        });
-    }
-    
-    private static void assertMethods(List<String> expected, IMethods methods) {
-        assertEquivalent(expected, methods.list(m -> asText(m)));
-    }
-    
-    private static void assertClasses(List<String> expected, IClasses classes) {
-        assertEquivalent(expected, classes.list(m -> m.toString()));
-    }
-    
-    private static String asText(IMethod m) {
-        return m.name() + " " + m.arguments().types();
-    }
-    
-}
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import net.ranides.assira.TestFiles;
+import net.ranides.assira.annotations.Meta;
+import net.ranides.assira.generic.TypeToken;
+import net.ranides.assira.reflection.IClass;
+import net.ranides.assira.reflection.IClasses;
+import net.ranides.assira.reflection.mockup.ForClassTraits;
+import org.junit.Test;
+import static net.ranides.assira.junit.NewAssert.*;
+import static net.ranides.assira.reflection.IAttribute.*;
+import net.ranides.assira.reflection.IMethod;
+import net.ranides.assira.reflection.IMethods;
+import net.ranides.assira.reflection.mockup.ForMemberTraits;
+import net.ranides.assira.reflection.mockup.ForMethodUtils;
+import static net.ranides.assira.reflection.mockup.ForIClass.*;
+import net.ranides.assira.reflection.mockup.TestReflective;
+import net.ranides.assira.text.Charsets;
+import net.ranides.assira.text.IOStrings;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public class AClassesTest {
+    
+    @Test
+    public void testNames() {
+        IClasses ic = new AClasses(new IClass[]{STRING, INTEGER, NUMBER, T_INTERFACE});
+        
+        List<String> names = Arrays.asList(
+            "java.lang.String", 
+            "java.lang.Integer", 
+            "java.lang.Number", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface"
+        );
+        
+        TestReflective.assertEquals(names, ic.names());
+    }
+    
+    @Test
+    public void testRequire() {
+        
+        List<String> exp1 = Arrays.asList(
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
+        );
+        List<String> exp2 = Arrays.asList(
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
+        );
+        List<String> exp3 = Arrays.asList(
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface"
+        );
+        List<String> exp4 = Arrays.asList(
+            "java.lang.String", "java.lang.Integer"
+        );
+        List<String> exp5 = Arrays.asList(
+            "java.lang.String"
+        );
+        List<String> exp6 = Arrays.asList(
+            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean",
+            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean2"
+        );
+        
+        TestReflective.assertEquals(exp1, iclist().require(Meta.Immutable.class).names());
+        
+        TestReflective.assertEquals(exp1, iclist().require(ANNOTATED_1.annotations()).names());
+        TestReflective.assertEquals(exp2, iclist().require(ANNOTATED_2.annotations()).names());
+        
+        TestReflective.assertEquals(exp3, iclist().require(INTERFACE).names());
+        
+        TestReflective.assertEquals(exp4, iclist().require(collect(PUBLIC, FINAL)).names());
+        
+        IMethod m = STRING.methods().require("valueOf").first();
+        TestReflective.assertEquals(exp5, iclist().require(m).names());
+
+        IClasses ic2 = new AClasses(new IClass[]{INTEGER, BEAN_1, BEAN_2});
+        IMethod m2 = BEAN_1.methods().require("getName1").first();
+        TestReflective.assertEquals(exp6, ic2.require(m2).names());
+
+    }
+    
+    @Test
+    public void testDiscard() {
+        
+        List<String> exp1 = Arrays.asList(
+            "java.lang.String", 
+            "java.lang.Integer", 
+            "java.lang.Number", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface"
+        );
+        List<String> exp2 = Arrays.asList(
+            "java.lang.String", 
+            "java.lang.Integer", 
+            "java.lang.Number", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface",
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1"
+        );
+        List<String> exp3 = Arrays.asList(
+            "java.lang.Number", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
+        );
+        List<String> exp4 = Arrays.asList(
+            "java.lang.Number", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
+        );
+        List<String> exp5 = Arrays.asList(
+            "java.lang.Integer", 
+            "java.lang.Number", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CInterface", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated1", 
+            "net.ranides.assira.reflection.mockup.ForClassTraits$CAnnotated2"
+        );
+        List<String> exp6 = Arrays.asList(
+            "java.lang.Integer"
+        );
+        List<String> exp7 = Arrays.asList(
+            "java.lang.String", "java.lang.Integer", "java.lang.Number"
+        );
+        
+        assertEquals(exp1, iclist().discard(Meta.Immutable.class).names());
+        assertEquals(exp2, iclist().discard(Meta.Unsafe.class).names());
+        
+        assertEquals(exp1, iclist().discard(ANNOTATED_1.annotations()).names());
+        assertEquals(exp1, iclist().discard(ANNOTATED_2.annotations()).names());
+        
+        assertEquals(exp3, iclist().discard(FINAL).names());
+        
+        assertEquals(exp4, iclist().discard(collect(PUBLIC,FINAL)).names());
+        
+        IMethod m = STRING.methods().require("valueOf").first();
+        assertEquals(exp5, iclist().discard(m).names());
+
+        IClasses ic2 = new AClasses(new IClass[]{INTEGER, BEAN_1, BEAN_2});
+        IMethod m2 = BEAN_1.methods().require("getName1").first();
+        assertEquals(exp6, ic2.discard(m2).names());
+        
+        assertEquals(exp7, iclist().discard(n -> n.name().startsWith("net.")).names());
+        
+
+    }
+    
+    @Test
+    public void testFields() {
+        List<String> exp1 = Arrays.asList(
+            "CASE_INSENSITIVE_ORDER", 
+            "MIN_VALUE", 
+            "MAX_VALUE", 
+            "TYPE", 
+            "SIZE", 
+            "BYTES"
+        );
+        List<String> exp2 = Arrays.asList(
+            "serialVersionUID",
+            "serialVersionUID",
+            "serialVersionUID",
+            "serialVersionUID",
+            "value",
+            "value",
+            "serialPersistentFields",
+            "hash"
+        );
+        List<String> exp3 = Arrays.asList(
+            "serialVersionUID", 
+            "serialVersionUID", 
+            "serialVersionUID", 
+            "this$0", 
+            "this$0",
+            "value", 
+            "value", 
+            "sizeTable", 
+            "serialPersistentFields", 
+            "hash", 
+            "digits", 
+            "DigitTens", 
+            "DigitOnes", 
+            "TYPE", 
+            "SIZE", 
+            "MIN_VALUE", 
+            "MAX_VALUE", 
+            "CASE_INSENSITIVE_ORDER", 
+            "BYTES"
+        );
+        
+        TestReflective.assertEquals(exp1, iclist().fields().names());
+        TestReflective.assertEquals(exp2, iclist().fields().require(PRIVATE).names());
+        TestReflective.assertEquals(exp3, iclist().fields().require(DECLARED).names());
+    }
+    
+    @Test
+    public void testConstructors() throws IOException {
+        List<String> exp1 = IOStrings.readLines(TestFiles.CONSTRUCT_1, Charsets.UTF8);
+        List<String> exp2 = IOStrings.readLines(TestFiles.CONSTRUCT_2, Charsets.UTF8);
+        List<String> exp3 = IOStrings.readLines(TestFiles.CONSTRUCT_3, Charsets.UTF8);
+        List<String> exp4 = IOStrings.readLines(TestFiles.CONSTRUCT_4, Charsets.UTF8);
+        List<String> exp5 = IOStrings.readLines(TestFiles.CONSTRUCT_5, Charsets.UTF8);
+        
+        TestReflective.assertEquals(exp1, iclist().constructors());
+        TestReflective.assertEquals(exp1, iclist().constructors().require(PUBLIC));
+        TestReflective.assertEquals(exp2, iclist().constructors().require(DECLARED));
+        TestReflective.assertEquals(exp3, iclist().constructors().require(PRIVATE));
+        TestReflective.assertEquals(exp4, iclist().constructors().require(PROTECTED));
+        TestReflective.assertEquals(exp5, iclist().constructors().require(PACKAGE));
+    }
+    
+    @Test
+    public void testMethods() throws IOException {
+        List<String> exp1 = IOStrings.readLines(TestFiles.METHODS_1, Charsets.UTF8);
+        List<String> exp2 = IOStrings.readLines(TestFiles.METHODS_2, Charsets.UTF8);
+        List<String> exp3 = IOStrings.readLines(TestFiles.METHODS_3, Charsets.UTF8);
+        List<String> exp4 = IOStrings.readLines(TestFiles.METHODS_4, Charsets.UTF8);
+        List<String> exp5 = IOStrings.readLines(TestFiles.METHODS_5, Charsets.UTF8);
+        
+        TestReflective.assertEquals(exp1, iclist().methods());
+        TestReflective.assertEquals(exp1, iclist().methods().require(PUBLIC));
+        TestReflective.assertEquals(exp2, iclist().methods().require(DECLARED));
+        TestReflective.assertEquals(exp3, iclist().methods().require(PRIVATE));
+        TestReflective.assertEquals(exp4, iclist().methods().require(PROTECTED));
+        TestReflective.assertEquals(exp5, iclist().methods().require(PACKAGE));
+    }
+    
+    @Test
+    public void testParent() {
+        List<String> exp = Arrays.asList(
+            "java.lang.Object",
+            "java.lang.Number",
+            "java.lang.Object",
+            "net.ranides.assira.reflection.mockup.ForMethodUtils$Root",
+            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean",
+            "$NULL"
+        );
+        TestReflective.assertEquals(exp, iclist2().parent());
+    }
+    
+    @Test
+    public void testParents() {
+        IClass[] array = new IClass[]{
+            STRING,
+            INTEGER,
+            NUMBER, 
+            IClass.typeinfo(ForMethodUtils.A.class),
+            BEAN_2,
+            INT,
+            IClass.typefor(new ArrayList<Float>() {}),
+            IClass.typefor(new ArrayList<Float>())
+            
+        };
+        List<String> exp1 = Arrays.asList(
+            "java.lang.Object",
+            "java.lang.Number",
+            "java.lang.Object",
+            "java.lang.Object",
+            "net.ranides.assira.reflection.mockup.ForMethodUtils$Root",
+            "java.lang.Object",
+            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean",
+            "java.lang.Object",
+            "java.util.ArrayList<java.lang.Float>",
+            "java.util.AbstractList<java.lang.Float>",
+            "java.util.AbstractCollection<java.lang.Float>",
+            "java.lang.Object",
+            "java.util.AbstractList<E>",
+            "java.util.AbstractCollection<E>",
+            "java.lang.Object"
+        );
+        List<String> exp2 = Arrays.asList(
+            "java.lang.Object",
+            "java.lang.Number",
+            "java.lang.Object",
+            "net.ranides.assira.reflection.mockup.ForMethodUtils$Root",
+            "net.ranides.assira.reflection.mockup.ForMemberTraits$Bean",
+            "java.util.ArrayList<java.lang.Float>",
+            "java.util.AbstractList<E>"
+        );
+        TestReflective.assertEquals(exp1, new AClasses(array).parents());
+        TestReflective.assertEquals(exp2, new AClasses(array).parents().require(DECLARED));
+    }
+    
+    @Test
+    public void testInterfaces() {
+        Class<?>[] array = new Class<?>[]{
+            String.class,
+            Integer.class,
+            Number.class, 
+            ForMethodUtils.A.class,
+            ForMemberTraits.Bean2.class,
+            int.class
+        };
+        List<String> exp1 = Arrays.asList(
+            "java.io.Serializable",
+            "java.lang.Comparable<T>",
+            "java.lang.CharSequence",
+            "java.lang.Comparable<T>",
+            "java.io.Serializable",
+            "java.io.Serializable"
+        );
+        List<String> exp2 = Arrays.asList(
+            "java.io.Serializable",
+            "java.lang.Comparable<T>",
+            "java.lang.CharSequence",
+            "java.lang.Comparable<T>",
+            "java.io.Serializable"
+        );
+        TestReflective.assertEquals(exp1, IClasses.typeinfo(array).interfaces());
+        TestReflective.assertEquals(exp2, IClasses.typeinfo(array).interfaces().require(DECLARED));
+    }
+    
+    @Test
+    public void testOuter() {
+        List<String> exp = Arrays.asList(
+            "$NULL",
+            "$NULL",
+            "$NULL",
+            "net.ranides.assira.reflection.mockup.ForMethodUtils",
+            "net.ranides.assira.reflection.mockup.ForMemberTraits<Q>",
+            "$NULL"
+        );
+        TestReflective.assertEquals(exp, iclist2().outer());
+    }
+    
+    @Test
+    public void testInner() {
+        List<String> exp = Arrays.asList(
+            "java.lang.String$CaseInsensitiveComparator",
+            "java.lang.Integer$IntegerCache"
+        );
+        TestReflective.assertEquals(exp, iclist2().inner().discard(c -> c.name().equals("java.lang.String$1")));
+    }
+    
+    @Test
+    public void testRaw() {
+        IClass[] array = new IClass[]{STRING, INTEGER, NUMBER, T_INTERFACE, ANNOTATED_1, new TypeToken<List<String>>(){}};
+        List<Class<?>> exp = Arrays.asList(
+            String.class, 
+            Integer.class, 
+            Number.class, 
+            ForClassTraits.INTERFACE, 
+            ForClassTraits.CAnnotated1.class,
+            List.class
+        );
+        assertEquals(exp, new AClasses(array).raw().list());
+        assertEquals(exp, new AClasses(array).reflective().list());
+    }
+
+    @Test
+    public void testSubClass() {
+        IClasses a = IClasses.typeinfo(CharSequence.class, Number.class, Integer.class);
+        IClasses b = IClasses.typeinfo(String.class, Integer.class, Integer.class);
+        IClasses c = IClasses.typeinfo(String.class, Integer.class, int.class);
+        
+        assertTrue( b.isSubclass(a) );
+        assertFalse( c.isSubclass(a) );
+        assertTrue( a.isSuper(b) );
+        
+        assertTrue( a.isInstance("", 41.5, 7) );
+        assertTrue( b.isInstance("", 41, 7) );
+        assertTrue( c.isInstance("", 41, 7) );
+        
+        assertFalse( c.isInstance("", 41, 7.0) );
+        assertFalse( c.isInstance("", 41.0, 7) );
+        
+    }
+    
+    private static AClasses iclist() {
+        return new AClasses(new IClass[]{STRING, INTEGER, NUMBER, T_INTERFACE, ANNOTATED_1, ANNOTATED_2});
+    }
+    
+    private static IClasses iclist2() {
+        return IClasses.typeinfo(new Class<?>[]{
+            String.class, 
+            Integer.class, 
+            Number.class, 
+            ForMethodUtils.A.class,
+            ForMemberTraits.Bean2.class,
+            int.class
+        });
+    }
+    
+}

+ 54 - 58
assira/src/test/java/net/ranides/assira/reflection/impl/AContextTest.java

@@ -1,58 +1,54 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.reflection.impl;
-
-import java.util.List;
-import net.ranides.assira.generic.TypeToken;
-import net.ranides.assira.reflection.IClass;
-import org.junit.Test;
-import static net.ranides.assira.junit.NewAssert.*;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public class AContextTest {
-    
-    public AContextTest() {
-    }
-
-    @Test
-    public void testTypeVariable() {
-        IClass ic1 = new TypeToken<TValue<Float>>(){};
-        
-//        System.out.printf("%s%n", ic1.method("func1").arguments().types());
-//        System.out.printf("%s%n", ic1.method("func2").arguments().types());
-//        System.out.printf("%s%n", ic1.method("func3").arguments().types());
-        
-        assertEquals("[java.util.List<java.lang.Float>]", ic1.method("func1").arguments().types().toString());
-        assertEquals("[java.util.List<? super E>]", ic1.method("func2").arguments().types().toString());
-        assertEquals("[java.util.List<? extends E>]", ic1.method("func3").arguments().types().toString());
-        
-
-
-    }
-    
-    public class TValue<E> {
-        
-        // mieliśmy bardzo dziwny błąd: jeśli parametr-generic miał argument o nazwie X (np List<X>) i nasza klasa też
-        // to wpadaliśmy w rekurencję przy rozpoznawaniu typów wildcardów
-        
-        // btw: nawet jeśli nie było błędu (bo nazwy różne) to i tak źle nam te typy rozpoznawało
-        // więc wyłączyliśmy "odgenericowywanie" dla wildcardów całkiem
-        // ZWŁASZCZA, że wynik takiego czegoś i tak jest bezużyteczny programowo w obecnym API
-        
-        public void func1(List<E> param) { }
-        
-        public void func2(List<? super E> param) { }
-        
-        public void func3(List<? extends E> param) { }
-
-        
-    }
-    
-}
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection.impl;
+
+import java.util.List;
+import net.ranides.assira.generic.TypeToken;
+import net.ranides.assira.reflection.IClass;
+import org.junit.Test;
+import static net.ranides.assira.junit.NewAssert.*;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public class AContextTest {
+    
+    public AContextTest() {
+    }
+
+    @Test
+    public void testTypeVariable() {
+        IClass ic1 = new TypeToken<TValue<Float>>(){};
+        
+        assertEquals("[java.util.List<java.lang.Float>]", ic1.method("func1").arguments().types().toString());
+        assertEquals("[java.util.List<? super E>]", ic1.method("func2").arguments().types().toString());
+        assertEquals("[java.util.List<? extends E>]", ic1.method("func3").arguments().types().toString());
+        
+
+
+    }
+    
+    public class TValue<E> {
+        
+        // mieliśmy bardzo dziwny błąd: jeśli parametr-generic miał argument o nazwie X (np List<X>) i nasza klasa też
+        // to wpadaliśmy w rekurencję przy rozpoznawaniu typów wildcardów
+        
+        // btw: nawet jeśli nie było błędu (bo nazwy różne) to i tak źle nam te typy rozpoznawało
+        // więc wyłączyliśmy "odgenericowywanie" dla wildcardów całkiem
+        // ZWŁASZCZA, że wynik takiego czegoś i tak jest bezużyteczny programowo w obecnym API
+        
+        public void func1(List<E> param) { }
+        
+        public void func2(List<? super E> param) { }
+        
+        public void func3(List<? extends E> param) { }
+
+        
+    }
+    
+}

+ 233 - 237
assira/src/test/java/net/ranides/assira/reflection/impl/AMethodsTest.java

@@ -1,237 +1,233 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.reflection.impl;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-import net.ranides.assira.annotations.Meta;
-import net.ranides.assira.generic.CompareUtils;
-import net.ranides.assira.generic.TypeToken;
-import net.ranides.assira.reflection.IAnnotations;
-import net.ranides.assira.reflection.IClass;
-import net.ranides.assira.reflection.IMethods;
-import net.ranides.assira.reflection.mockup.ForMethodUtils;
-import org.junit.Test;
-import static net.ranides.assira.junit.NewAssert.*;
-import net.ranides.assira.reflection.IArguments;
-import static net.ranides.assira.reflection.IAttribute.*;
-import net.ranides.assira.reflection.IClasses;
-import net.ranides.assira.reflection.mockup.ForIClass;
-import net.ranides.assira.text.StringUtils;
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public class AMethodsTest {
-
-    @Test
-    public void testRequireAnnotations() {
-        IMethods m1 = methods1().require(Override.class);
-        assertEquivalent(Arrays.asList(), m1.names());
-        
-        IMethods m2 = methods1().require(Meta.Unsafe.class);
-        assertEquivalent(Arrays.asList("some2", "some4"), m2.names());
-        
-        IMethods m3 = methods1().require(Deprecated.class);
-        assertEquivalent(Arrays.asList("some3", "some4"), m3.names());
-        
-        IMethods m4 = methods1().require(IAnnotations.of(Meta.Unsafe.class, Deprecated.class));
-        assertEquivalent(Arrays.asList("some4"), m4.names());
-        
-        IMethods m5 = methods1().require(IAnnotations.of(Deprecated.class));
-        assertEquivalent(Arrays.asList("some3", "some4"), m5.names());
-    }
-    
-    @Test
-    public void testDiscardAnnotations() {
-        IMethods m1 = methods1().require(DECLARED).discard(Override.class);
-        assertEquivalent(Arrays.asList("compare", "fun6", "fun7", "some1", "some2", "some3", "some4"), m1.names());
-        
-        IMethods m2 = methods1().require(DECLARED).discard(Meta.Unsafe.class);
-        assertEquivalent(Arrays.asList("compare", "fun6", "fun7", "some1", "some3"), m2.names());
-        
-        IMethods m3 = methods1().require(DECLARED).discard(Deprecated.class);
-        assertEquivalent(Arrays.asList("compare", "fun6", "fun7", "some1", "some2"), m3.names());
-        
-        IMethods m4 = methods1().require(DECLARED).discard(IAnnotations.of(Meta.Unsafe.class, Deprecated.class));
-        assertEquivalent(Arrays.asList("compare", "fun6", "fun7", "some1"), m4.names());
-        
-        IMethods m5 = methods1().require(DECLARED).discard(IAnnotations.of(Deprecated.class));
-        assertEquivalent(Arrays.asList("compare", "fun6", "fun7", "some1", "some2"), m5.names());
-    }
-    
-    @Test
-    public void testRequireAttr() {
-        List<String> m1 = Arrays.asList("fun3", "fun1c", "fun2", "fun1", "fun3", "wait", "wait", "wait", "equals", "toString", "hashCode", "getClass", "notify", "notifyAll");
-        List<String> m2 = Arrays.asList("fun3", "fun1c", "fun2", "fun1", "fun4", "fun5");
-        List<String> m3 = Arrays.asList();
-        List<String> m4 = Arrays.asList("fun5");
-        List<String> m5 = Arrays.asList("fun5", "fun5", "registerNatives");
-        
-        assertEquivalent(m1, methods2().require(collect(PUBLIC)).names());
-        assertEquivalent(m2, methods2().require(collect(DECLARED)).names());
-        assertEquivalent(m3, methods2().require(collect(STRICT)).names());
-        assertEquivalent(m4, methods2().require(collect(PRIVATE,STRICT)).names());
-        assertEquivalent(m5, methods2().require(collect(PRIVATE)).names());
-    }
-    
-    @Test
-    public void testRequireName() {
-        List<String> m1 = Arrays.asList("fun3", "fun1c", "fun2", "fun1", "fun3", "equals", "toString", "hashCode", "getClass", "notify", "notifyAll");
-        List<String> m3 = Arrays.asList("fun5");
-        List<String> m4 = Arrays.asList();
-        List<String> m5 = Arrays.asList("fun5", "fun5", "registerNatives");
-        List<String> m6 = Arrays.asList("registerNatives");
-        
-        assertEquivalent(m1, methods2().require(collect(PUBLIC)).discard("wait").names());
-        assertEquivalent(m3, methods2().require(collect(PRIVATE,STRICT)).discard("fun2").names());
-        assertEquivalent(m4, methods2().require(collect(PRIVATE,STRICT)).discard("fun5").names());
-        assertEquivalent(m5, methods2().require(collect(PRIVATE)).discard("fun2").names());
-        assertEquivalent(m6, methods2().require(collect(PRIVATE)).discard("fun5").names());
-    }
-    
-    @Test
-    public void testDiscardAttr() {
-        List<String> m1 = Arrays.asList("equals", "fun1", "fun1c", "fun2", "fun3", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait", "wait", "wait");
-        List<String> m2 = Arrays.asList("equals", "fun1",          "fun2", "fun3", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait", "wait", "wait");
-        List<String> m3 = Arrays.asList("clone", "finalize", "fun4", "fun5", "registerNatives");
-        List<String> m4 = Arrays.asList("fun1", "fun1c", "fun2", "fun3", "fun4", "fun5");
-        List<String> m5 = Arrays.asList("fun1", "fun1c", "fun2", "fun3", "fun4");
-        
-
-        assertEquivalent(m1, methods3().names());
-        assertEquivalent(m2, methods3().discard(collect(DECLARED)).names());
-        assertEquivalent(m3, methods3().discard(collect(PUBLIC)).names());
-        assertEquivalent(m4, methods2().require(DECLARED).names());
-        assertEquivalent(m5, methods2().require(DECLARED).discard(STRICT).names());
-    }
-    
-    @Test
-    public void testRequireReturns() {
-        List<String> m1 = Arrays.asList("compare", "some1", "fun7", "fun6", "hashCode");
-        List<String> m2 = Arrays.asList("some2");
-        List<String> m3 = Arrays.asList("some3");
-        List<String> m4 = Arrays.asList("some4", "wait", "wait", "wait", "notify", "notifyAll");
-        List<String> m5 = Arrays.asList();
-        
-        assertEquivalent(m1, methods1().require(ForIClass.INT).names());
-        assertEquivalent(m2, methods1().require(ForIClass.INTEGER).names());
-        assertEquivalent(m3, methods1().require(ForIClass.FLOAT).names());
-        assertEquivalent(m4, methods1().require(ForIClass.VOID).names());
-        assertEquivalent(m5, methods1().require(IClass.typeinfo(Void.class)).names());
-    }
-    
-    @Test
-    public void testDiscardReturns() {
-        List<String> m1 = Arrays.asList("some2", "some3", "some4");
-        List<String> m2 = Arrays.asList("compare", "fun6", "fun7", "some1", "some3", "some4");
-        List<String> m3 = Arrays.asList("compare", "fun6", "fun7", "some1", "some2", "some4");
-        List<String> m4 = Arrays.asList("compare", "fun6", "fun7", "some1", "some2", "some3");
-        List<String> m5 = Arrays.asList("compare", "fun6", "fun7", "some1", "some2", "some3", "some4");
-
-        assertEquivalent(m1, methods1().require(DECLARED).discard(ForIClass.INT).names());
-        assertEquivalent(m2, methods1().require(DECLARED).discard(ForIClass.INTEGER).names());
-        assertEquivalent(m3, methods1().require(DECLARED).discard(ForIClass.FLOAT).names());
-        assertEquivalent(m4, methods1().require(DECLARED).discard(ForIClass.VOID).names());
-        assertEquivalent(m5, methods1().require(DECLARED).discard(ForIClass.O_VOID).names());
-    }
-    
-    @Test
-    public void testDiscardArguments() {
-        List<String> m1 = Arrays.asList("func2", "func3", "func4", "func5", "func6", "func7");
-        List<String> m2 = Arrays.asList("func1", "func3", "func4", "func4", "func5", "func6", "func7");
-        List<String> m3 = Arrays.asList("func1", "func2", "func3", "func4", "func5", "func7");
-        List<String> m4 = Arrays.asList("func1", "func2", "func3", "func4", "func4", "func6", "func7");
-        List<String> m5 = Arrays.asList("func1", "func2", "func3", "func4", "func4", "func5", "func6");
-        
-        assertEquivalent(m1, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.INT)).names());
-        assertEquivalent(m2, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.INTEGER)).names());
-        assertEquivalent(m2, methods4().require(DECLARED).discard(IArguments.typeinfo(IClass.typefor(88))).names());
-        
-        assertEquivalent(m3, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.STRING)).names());
-        assertEquivalent(m4, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.CHARSEQUENCE)).names());
-        assertEquivalent(m5, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.OBJECT)).names());
-    }
-    
-    @Test
-    public void testMatches() {
-        List<String> m1 = Arrays.asList("func1", "func4");
-        List<String> m2 = Arrays.asList("func2", "func7");
-        List<String> m3 = Arrays.asList("func4", "func5", "func6", "func7");
-        List<String> m4 = Arrays.asList("func7");
-         
-        assertEquivalent(m1, methods4().require(DECLARED).matches(IClasses.typeinfo(int.class)).names());
-        assertEquivalent(m2, methods4().require(DECLARED).matches(IClasses.typeinfo(Integer.class)).names());
-        assertEquivalent(m2, methods4().require(DECLARED).matches(IClasses.typefor(77)).names());
-        assertEquivalent(m3, methods4().require(DECLARED).matches(IClasses.typeinfo(String.class)).names());
-        assertEquivalent(m4, methods4().require(DECLARED).matches(IClasses.typeinfo(Object.class)).names()); 
-    }
-    
-    @Test
-    public void testReturns() {
-        List<String> m1 = Arrays.asList("int", "int", "int", "int", "java.lang.Float", "java.lang.Integer", "void");
-        List<String> m2 = Arrays.asList("java.util.Comparator<T>", "java.util.Comparator<T>", "java.util.Comparator<T>");
-        List<String> m3 = Arrays.asList("java.util.Comparator<java.lang.Float>", "java.util.Comparator<java.lang.Float>", "java.util.Comparator<java.lang.Float>");
-        
-        assertEquivalent(m1, methods1().require(DECLARED).returns().list(Object::toString));
-        assertEquivalent(m2, methods1().require("thenComparing").returns().list(Object::toString));
-        assertEquivalent(m3, new TypeToken<ForMethodUtils.MCP<Float>>(){}.methods().require("thenComparing").returns().list(Object::toString));
-    }
-    
-    @Test
-    public void testMethod() {
-        String mcp = "net.ranides.assira.reflection.mockup.ForMethodUtils$MCP<T>";
-        List<String> m1 = Arrays.asList(mcp, mcp, mcp, mcp, mcp, mcp, mcp);
-        List<String> m2 = Arrays.asList("java.util.Comparator<T>", "java.util.Comparator<T>", "java.util.Comparator<T>");
-        
-        assertEquivalent(m1, methods1().require(DECLARED).parent().list(Object::toString));
-        assertEquivalent(m2, methods1().require("thenComparing").parent().list(Object::toString));
-    }
-    
-    @Test
-    public void testAccepts() {
-        List<String> m1 = Arrays.asList("func1", "func2", "func4", "func7");
-        List<String> m2 = Arrays.asList("func4", "func5", "func6", "func7");
-        
-        assertEquivalent(m1, methods4().require(DECLARED).accepts(77).names());
-        
-        assertEquivalent(m2, methods4().require(DECLARED).accepts("x").names());
-        
-    }
-    
-    @Test
-    public void testHandles() throws Exception, Throwable {
-        ForMethodUtils.MCP<?> mcp = new ForMethodUtils.MCP<>();
-        IMethods m1 = methods1().require("some1");
-        
-        assertEquals(777, m1.reflective().first().invoke(mcp));
-        assertEquals(777, m1.handle().first().invoke(mcp));
-    }
-
-    private static IMethods methods1() {
-        return IClass.typeinfo(ForMethodUtils.MCP.class).methods();
-    }
-    
-    private static IMethods methods2() {
-        return IClass.typeinfo(ForMethodUtils.A.class).methods();
-    }
-    
-    private static IMethods methods3() {
-        return IClass.typeinfo(ForMethodUtils.B.class).methods();
-    }
-    
-    private static IMethods methods4() {
-        return IClass.typeinfo(ForMethodUtils.C.class).methods();
-    }
-    
-    private static void assertEquivalent2(List<String> a, List<?> b) {
-        b.sort(CompareUtils.comparator());
-        System.out.printf("%s%n", StringUtils.join(b, ", ", v -> StringUtils.quote(v.toString())));
-    }
-    
-}
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection.impl;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+import net.ranides.assira.annotations.Meta;
+import net.ranides.assira.generic.CompareUtils;
+import net.ranides.assira.generic.TypeToken;
+import net.ranides.assira.reflection.IAnnotations;
+import net.ranides.assira.reflection.IClass;
+import net.ranides.assira.reflection.IMethods;
+import net.ranides.assira.reflection.mockup.ForMethodUtils;
+import org.junit.Test;
+import static net.ranides.assira.junit.NewAssert.*;
+import net.ranides.assira.reflection.IArguments;
+import static net.ranides.assira.reflection.IAttribute.*;
+import net.ranides.assira.reflection.IClasses;
+import net.ranides.assira.reflection.mockup.ForIClass;
+import net.ranides.assira.reflection.mockup.TestReflective;
+import net.ranides.assira.text.StringUtils;
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public class AMethodsTest {
+
+    @Test
+    public void testRequireAnnotations() {
+        IMethods m1 = methods1().require(Override.class);
+        assertEquivalent(Arrays.asList(), m1.names());
+        
+        IMethods m2 = methods1().require(Meta.Unsafe.class);
+        assertEquivalent(Arrays.asList("some2", "some4"), m2.names());
+        
+        IMethods m3 = methods1().require(Deprecated.class);
+        assertEquivalent(Arrays.asList("some3", "some4"), m3.names());
+        
+        IMethods m4 = methods1().require(IAnnotations.of(Meta.Unsafe.class, Deprecated.class));
+        assertEquivalent(Arrays.asList("some4"), m4.names());
+        
+        IMethods m5 = methods1().require(IAnnotations.of(Deprecated.class));
+        assertEquivalent(Arrays.asList("some3", "some4"), m5.names());
+    }
+    
+    @Test
+    public void testDiscardAnnotations() {
+        IMethods m1 = methods1().require(DECLARED).discard(Override.class);
+        TestReflective.assertEquals(Arrays.asList("compare", "fun6", "fun7", "some1", "some2", "some3", "some4"), m1.names());
+        
+        IMethods m2 = methods1().require(DECLARED).discard(Meta.Unsafe.class);
+        TestReflective.assertEquals(Arrays.asList("compare", "fun6", "fun7", "some1", "some3"), m2.names());
+        
+        IMethods m3 = methods1().require(DECLARED).discard(Deprecated.class);
+        TestReflective.assertEquals(Arrays.asList("compare", "fun6", "fun7", "some1", "some2"), m3.names());
+        
+        IMethods m4 = methods1().require(DECLARED).discard(IAnnotations.of(Meta.Unsafe.class, Deprecated.class));
+        TestReflective.assertEquals(Arrays.asList("compare", "fun6", "fun7", "some1"), m4.names());
+        
+        IMethods m5 = methods1().require(DECLARED).discard(IAnnotations.of(Deprecated.class));
+        TestReflective.assertEquals(Arrays.asList("compare", "fun6", "fun7", "some1", "some2"), m5.names());
+    }
+    
+    @Test
+    public void testRequireAttr() {
+        List<String> m1 = Arrays.asList("fun3", "fun1c", "fun2", "fun1", "fun3", "wait", "wait", "wait", "equals", "toString", "hashCode", "getClass", "notify", "notifyAll");
+        List<String> m2 = Arrays.asList("fun3", "fun1c", "fun2", "fun1", "fun4", "fun5");
+        List<String> m3 = Arrays.asList();
+        List<String> m4 = Arrays.asList("fun5");
+        List<String> m5 = Arrays.asList("fun5", "fun5", "registerNatives");
+        
+        assertEquivalent(m1, methods2().require(collect(PUBLIC)).names());
+        assertEquivalent(m2, methods2().require(collect(DECLARED)).names());
+        assertEquivalent(m3, methods2().require(collect(STRICT)).names());
+        assertEquivalent(m4, methods2().require(collect(PRIVATE,STRICT)).names());
+        assertEquivalent(m5, methods2().require(collect(PRIVATE)).names());
+    }
+    
+    @Test
+    public void testRequireName() {
+        List<String> m1 = Arrays.asList("fun3", "fun1c", "fun2", "fun1", "fun3", "equals", "toString", "hashCode", "getClass", "notify", "notifyAll");
+        List<String> m3 = Arrays.asList("fun5");
+        List<String> m4 = Arrays.asList();
+        List<String> m5 = Arrays.asList("fun5", "fun5", "registerNatives");
+        List<String> m6 = Arrays.asList("registerNatives");
+        
+        assertEquivalent(m1, methods2().require(collect(PUBLIC)).discard("wait").names());
+        assertEquivalent(m3, methods2().require(collect(PRIVATE,STRICT)).discard("fun2").names());
+        assertEquivalent(m4, methods2().require(collect(PRIVATE,STRICT)).discard("fun5").names());
+        assertEquivalent(m5, methods2().require(collect(PRIVATE)).discard("fun2").names());
+        assertEquivalent(m6, methods2().require(collect(PRIVATE)).discard("fun5").names());
+    }
+    
+    @Test
+    public void testDiscardAttr() {
+        List<String> m1 = Arrays.asList("equals", "fun1", "fun1c", "fun2", "fun3", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait", "wait", "wait");
+        List<String> m2 = Arrays.asList("equals", "fun1",          "fun2", "fun3", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait", "wait", "wait");
+        List<String> m3 = Arrays.asList("clone", "finalize", "fun4", "fun5", "registerNatives");
+        List<String> m4 = Arrays.asList("fun1", "fun1c", "fun2", "fun3", "fun4", "fun5");
+        List<String> m5 = Arrays.asList("fun1", "fun1c", "fun2", "fun3", "fun4");
+        
+
+        assertEquivalent(m1, methods3().names());
+        assertEquivalent(m2, methods3().discard(collect(DECLARED)).names());
+        assertEquivalent(m3, methods3().discard(collect(PUBLIC)).names());
+        assertEquivalent(m4, methods2().require(DECLARED).names());
+        assertEquivalent(m5, methods2().require(DECLARED).discard(STRICT).names());
+    }
+    
+    @Test
+    public void testRequireReturns() {
+        List<String> m1 = Arrays.asList("compare", "some1", "fun7", "fun6", "hashCode");
+        List<String> m2 = Arrays.asList("some2");
+        List<String> m3 = Arrays.asList("some3");
+        List<String> m4 = Arrays.asList("some4", "wait", "wait", "wait", "notify", "notifyAll");
+        List<String> m5 = Arrays.asList();
+        
+        assertEquivalent(m1, methods1().require(ForIClass.INT).names());
+        assertEquivalent(m2, methods1().require(ForIClass.INTEGER).names());
+        assertEquivalent(m3, methods1().require(ForIClass.FLOAT).names());
+        assertEquivalent(m4, methods1().require(ForIClass.VOID).names());
+        assertEquivalent(m5, methods1().require(IClass.typeinfo(Void.class)).names());
+    }
+    
+    @Test
+    public void testDiscardReturns() {
+        List<String> m1 = Arrays.asList("some2", "some3", "some4");
+        List<String> m2 = Arrays.asList("compare", "fun6", "fun7", "some1", "some3", "some4");
+        List<String> m3 = Arrays.asList("compare", "fun6", "fun7", "some1", "some2", "some4");
+        List<String> m4 = Arrays.asList("compare", "fun6", "fun7", "some1", "some2", "some3");
+        List<String> m5 = Arrays.asList("compare", "fun6", "fun7", "some1", "some2", "some3", "some4");
+
+        assertEquivalent(m1, methods1().require(DECLARED).discard(ForIClass.INT).names());
+        assertEquivalent(m2, methods1().require(DECLARED).discard(ForIClass.INTEGER).names());
+        assertEquivalent(m3, methods1().require(DECLARED).discard(ForIClass.FLOAT).names());
+        assertEquivalent(m4, methods1().require(DECLARED).discard(ForIClass.VOID).names());
+        assertEquivalent(m5, methods1().require(DECLARED).discard(ForIClass.O_VOID).names());
+    }
+    
+    @Test
+    public void testDiscardArguments() {
+        List<String> m1 = Arrays.asList("func2", "func3", "func4", "func5", "func6", "func7");
+        List<String> m2 = Arrays.asList("func1", "func3", "func4", "func4", "func5", "func6", "func7");
+        List<String> m3 = Arrays.asList("func1", "func2", "func3", "func4", "func5", "func7");
+        List<String> m4 = Arrays.asList("func1", "func2", "func3", "func4", "func4", "func6", "func7");
+        List<String> m5 = Arrays.asList("func1", "func2", "func3", "func4", "func4", "func5", "func6");
+        
+        assertEquivalent(m1, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.INT)).names());
+        assertEquivalent(m2, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.INTEGER)).names());
+        assertEquivalent(m2, methods4().require(DECLARED).discard(IArguments.typeinfo(IClass.typefor(88))).names());
+        
+        assertEquivalent(m3, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.STRING)).names());
+        assertEquivalent(m4, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.CHARSEQUENCE)).names());
+        assertEquivalent(m5, methods4().require(DECLARED).discard(IArguments.typeinfo(ForIClass.OBJECT)).names());
+    }
+    
+    @Test
+    public void testMatches() {
+        List<String> m1 = Arrays.asList("func1", "func4");
+        List<String> m2 = Arrays.asList("func2", "func7");
+        List<String> m3 = Arrays.asList("func4", "func5", "func6", "func7");
+        List<String> m4 = Arrays.asList("func7");
+         
+        assertEquivalent(m1, methods4().require(DECLARED).matches(IClasses.typeinfo(int.class)).names());
+        assertEquivalent(m2, methods4().require(DECLARED).matches(IClasses.typeinfo(Integer.class)).names());
+        assertEquivalent(m2, methods4().require(DECLARED).matches(IClasses.typefor(77)).names());
+        assertEquivalent(m3, methods4().require(DECLARED).matches(IClasses.typeinfo(String.class)).names());
+        assertEquivalent(m4, methods4().require(DECLARED).matches(IClasses.typeinfo(Object.class)).names()); 
+    }
+    
+    @Test
+    public void testReturns() {
+        List<String> m1 = Arrays.asList("int", "int", "int", "int", "java.lang.Float", "java.lang.Integer", "void");
+        List<String> m2 = Arrays.asList("java.util.Comparator<T>", "java.util.Comparator<T>", "java.util.Comparator<T>");
+        List<String> m3 = Arrays.asList("java.util.Comparator<java.lang.Float>", "java.util.Comparator<java.lang.Float>", "java.util.Comparator<java.lang.Float>");
+        
+        assertEquivalent(m1, methods1().require(DECLARED).returns().list(Object::toString));
+        assertEquivalent(m2, methods1().require("thenComparing").returns().list(Object::toString));
+        assertEquivalent(m3, new TypeToken<ForMethodUtils.MCP<Float>>(){}.methods().require("thenComparing").returns().list(Object::toString));
+    }
+    
+    @Test
+    public void testMethod() {
+        String mcp = "net.ranides.assira.reflection.mockup.ForMethodUtils$MCP<T>";
+        List<String> m1 = Arrays.asList(mcp, mcp, mcp, mcp, mcp, mcp, mcp);
+        List<String> m2 = Arrays.asList("java.util.Comparator<T>", "java.util.Comparator<T>", "java.util.Comparator<T>");
+        
+        assertEquivalent(m1, methods1().require(DECLARED).parent().list(Object::toString));
+        assertEquivalent(m2, methods1().require("thenComparing").parent().list(Object::toString));
+    }
+    
+    @Test
+    public void testAccepts() {
+        List<String> m1 = Arrays.asList("func1", "func2", "func4", "func7");
+        List<String> m2 = Arrays.asList("func4", "func5", "func6", "func7");
+        
+        assertEquivalent(m1, methods4().require(DECLARED).accepts(77).names());
+        
+        assertEquivalent(m2, methods4().require(DECLARED).accepts("x").names());
+        
+    }
+    
+    @Test
+    public void testHandles() throws Exception, Throwable {
+        ForMethodUtils.MCP<?> mcp = new ForMethodUtils.MCP<>();
+        IMethods m1 = methods1().require("some1");
+        
+        assertEquals(777, m1.reflective().first().invoke(mcp));
+        assertEquals(777, m1.handle().first().invoke(mcp));
+    }
+
+    private static IMethods methods1() {
+        return IClass.typeinfo(ForMethodUtils.MCP.class).methods();
+    }
+    
+    private static IMethods methods2() {
+        return IClass.typeinfo(ForMethodUtils.A.class).methods();
+    }
+    
+    private static IMethods methods3() {
+        return IClass.typeinfo(ForMethodUtils.B.class).methods();
+    }
+    
+    private static IMethods methods4() {
+        return IClass.typeinfo(ForMethodUtils.C.class).methods();
+    }
+    
+}

+ 220 - 229
assira/src/test/java/net/ranides/assira/reflection/impl/RMethodTest.java

@@ -1,229 +1,220 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.reflection.impl;
-
-import java.lang.invoke.WrongMethodTypeException;
-import java.lang.reflect.Type;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-import net.ranides.assira.reflection.IClass;
-import net.ranides.assira.reflection.mockup.ForRMethod;
-import net.ranides.assira.reflection.IMethod;
-import org.junit.Test;
-import static net.ranides.assira.junit.NewAssert.*;
-import net.ranides.assira.reflection.IContext;
-import net.ranides.assira.reflection.mockup.ForRMethod.TAction;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-@SuppressWarnings({"PMD.AvoidDuplicateLiterals"})
-public class RMethodTest {
-    
-    private static final String RECORD_TYPE = "net.ranides.assira.reflection.mockup.ForRMethod<java.lang.Float>.Record<java.lang.Double>";
-    
-    @Test(expected = java.lang.reflect.GenericSignatureFormatError.class)
-    public void testJVM1() {
-        // @todo (assira #9) JVM BUG :)
-        ForRMethod<? super Float> parent = new ForRMethod<Float>(){};
-        Object record = parent.new Record<Double>(){};
-        Type type = record.getClass().getGenericSuperclass();
-        
-        assertEquals(RECORD_TYPE, type);
-    }
-    
-    @Test
-    public void testJVM2() {
-        ForRMethod<Float> parent = new ForRMethod<Float>(){};
-        Object record = parent.new Record<Double>(){};
-        String type = record.getClass().getGenericSuperclass().getTypeName();
-        
-        assertEquals(RECORD_TYPE, type);
-    }
-    
-    @Test
-    public void testMethodReturs() {
-        // Ja pierdolę: uzupełniamy TypeParams poprawnie. Szok.
-        // Jakkolwiek JVM trochę abstrakcyjnie te sygnatury generuje ;)
-
-        ForRMethod p0 = new ForRMethod(){};
-        ForRMethod<Float> p1 = p0;
-        ForRMethod<String> p2 = p0;
-        
-        Object o1 = p1.new Record<Double>(){};
-        Object o2 = p2.new Record<Character>(){};
-        
-        IClass ic1 = IClass.typefor(o1);
-        IClass ic2 = IClass.typefor(o2);
-        
-        String o1map1 = ic1.methods().require("map1").first().toString();
-        String o1map2 = ic1.methods().require("map2").first().toString();
-        String o2map1 = ic2.methods().require("map1").first().toString();
-        String o2map2 = ic2.methods().require("map2").first().toString();
-        
-        assertEquals(Arrays.asList("Q=>class java.lang.Double", "T=>class java.lang.Float"), asText(ic1.context()));
-        assertEquals(Arrays.asList("Q=>class java.lang.Character", "T=>class java.lang.String"), asText(ic2.context()));
-        
-//        System.out.printf("1.context = %s%n", LexicalCast.toJSON(ic1.context().map()));
-//        System.out.printf("2.context = %s%n", LexicalCast.toJSON(ic2.context().map()));
-                
-        String e1map1 = MessageFormat.format(
-            "{1}<{2}, {1}<{3}, {1}<R, {4}>>> {0}<{3}>.map1(R a, {2} b, {3} c, {4} d)",
-            "net.ranides.assira.reflection.mockup.ForRMethod$Record",
-            "java.util.Map",
-            "java.lang.Float",
-            "java.lang.Double",
-            "java.lang.Integer"
-        );
-        String e1map2 = MessageFormat.format(
-            "{1}<{2}, {1}<{3}, {1}<R, {4}>>> {0}<{3}>.map2({5}<R> a, {5}<{2}> b, {5}<{3}> c, {5}<{4}> d)", 
-            "net.ranides.assira.reflection.mockup.ForRMethod$Record",
-            "java.util.Map",
-            "java.lang.Float",
-            "java.lang.Double",
-            "java.lang.Integer",
-            "java.util.List"
-        );
-        String e2map1 = MessageFormat.format(
-            "{1}<{2}, {1}<{3}, {1}<R, {4}>>> {0}<{3}>.map1(R a, {2} b, {3} c, {4} d)",
-            "net.ranides.assira.reflection.mockup.ForRMethod$Record",
-            "java.util.Map",
-            "java.lang.String",
-            "java.lang.Character",
-            "java.lang.Integer"
-        );
-        String e2map2 = MessageFormat.format(
-            "{1}<{2}, {1}<{3}, {1}<R, {4}>>> {0}<{3}>.map2({5}<R> a, {5}<{2}> b, {5}<{3}> c, {5}<{4}> d)", 
-            "net.ranides.assira.reflection.mockup.ForRMethod$Record",
-            "java.util.Map",
-            "java.lang.String",
-            "java.lang.Character",
-            "java.lang.Integer",
-            "java.util.List"
-        );
-        
-//        System.out.printf("o1map1  = %s%n", o1map1);
-//        System.out.printf("e1map1  = %s%n%n", e1map1);
-//        System.out.printf("o1map2  = %s%n", o1map2);
-//        System.out.printf("e1map2  = %s%n%n", e1map2);
-//        System.out.printf("o2map1  = %s%n", o2map1);
-//        System.out.printf("e2map1  = %s%n%n", e2map1);
-//        System.out.printf("o2map2  = %s%n", o2map2);
-//        System.out.printf("e2map2  = %s%n%n", e2map2);
-        
-        assertEquals(e1map1, o1map1);
-        assertEquals(e1map2, o1map2);
-        assertEquals(e2map1, o2map1);
-        assertEquals(e2map2, o2map2);
-    }
-    
-    @Test
-    public void testTypeInfo() {
-        IClass type = IClass.typeinfo(TAction.class);
-        
-        IMethod m1 = type.methods().require("hello").first();
-        IMethod m2 = type.methods().require("stat").first();
-        
-        IMethod r1 = IMethod.typeinfo(m1.reflective());
-        IMethod r2 = IMethod.typeinfo(m2.reflective());
-        
-        assertEquals(m1, r1);
-        assertEquals(m2, r2);
-    }
-    
-    @Test
-    public void testApply() {
-        TAction a1 = new TAction(3);
-        TAction a2 = new TAction(10);
-        IMethod m1 = IClass.typefor(a1).methods().require("hello").first();
-        IMethod m2 = IClass.typefor(a1).methods().require("stat").first();
-        
-        assertEquals("[6:9]", m1.apply(a1, 2, 3));
-        assertEquals("[20:30]", m1.apply(a2, 2, 3));
-        
-        assertEquals("[2/3]", m2.apply(a1, 2, 3));
-        assertEquals("[2/3]", m2.apply(null, 2, 3));
-        
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.apply(a1, "q", 3);
-        });
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.apply(a1, 1, 2, 3);
-        });
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.apply(null, 2, 3);
-        });
-    }
-    
-    @Test
-    public void testCall() {
-        TAction a1 = new TAction(3);
-        TAction a2 = new TAction(10);
-        IMethod m1 = IClass.typefor(a1).methods().require("hello").first();
-        IMethod m2 = IClass.typefor(a1).methods().require("stat").first();
-        
-        assertEquals("[6:9]", m1.call(a1, 2, 3));
-        assertEquals("[20:30]", m1.call(a2, 2, 3));
-        
-        assertEquals("[2/3]", m2.call(2, 3));
-        assertThrows(WrongMethodTypeException.class, ()->{
-            m2.call(null, 2, 3);
-        });
-        assertThrows(ClassCastException.class, ()->{
-            m2.call("z", 3);
-        });
-        
-        assertThrows(ClassCastException.class, ()->{
-            m1.call(a1, "q", 3);
-        });
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.apply(a1, 1, 2, 3);
-        });
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.apply(null, 2, 3);
-        });
-    }
-    
-    @Test
-    public void testCallVoid() {
-        TAction a1 = new TAction(3);
-        TAction a2 = new TAction(10);
-        IMethod m0 = IClass.typefor(a1).methods().require("nop").first();
-        
-        assertEquals("nop!", m0.call());
-        assertEquals("nop!", m0.apply());
-//        
-//        assertEquals("[2/3]", m2.call(2, 3));
-//        assertThrows(WrongMethodTypeException.class, ()->{
-//            m2.call(null, 2, 3);
-//        });
-//        assertThrows(ClassCastException.class, ()->{
-//            m2.call("z", 3);
-//        });
-//        
-//        assertThrows(ClassCastException.class, ()->{
-//            m1.call(a1, "q", 3);
-//        });
-//        assertThrows(IllegalArgumentException.class, ()->{
-//            m1.apply(a1, 1, 2, 3);
-//        });
-//        assertThrows(IllegalArgumentException.class, ()->{
-//            m1.apply(null, 2, 3);
-//        });
-    }
-    
-    private static List<String> asText(IContext context) {
-        return context.map().entrySet().stream()
-            .map(Object::toString)
-            .sorted()
-            .collect(Collectors.toList());
-    }
-    
-}
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection.impl;
+
+import java.lang.invoke.WrongMethodTypeException;
+import java.lang.reflect.Type;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import net.ranides.assira.reflection.IClass;
+import net.ranides.assira.reflection.mockup.ForRMethod;
+import net.ranides.assira.reflection.IMethod;
+import org.junit.Test;
+import static net.ranides.assira.junit.NewAssert.*;
+import net.ranides.assira.reflection.IContext;
+import net.ranides.assira.reflection.mockup.ForRMethod.TAction;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+@SuppressWarnings({"PMD.AvoidDuplicateLiterals"})
+public class RMethodTest {
+    
+    private static final String RECORD_TYPE = "net.ranides.assira.reflection.mockup.ForRMethod<java.lang.Float>.Record<java.lang.Double>";
+    
+    @Test(expected = java.lang.reflect.GenericSignatureFormatError.class)
+    public void testJVM1() {
+        // @todo (assira #9) JVM BUG :)
+        ForRMethod<? super Float> parent = new ForRMethod<Float>(){};
+        Object record = parent.new Record<Double>(){};
+        Type type = record.getClass().getGenericSuperclass();
+        
+        assertEquals(RECORD_TYPE, type);
+    }
+    
+    @Test
+    public void testJVM2() {
+        ForRMethod<Float> parent = new ForRMethod<Float>(){};
+        Object record = parent.new Record<Double>(){};
+        String type = record.getClass().getGenericSuperclass().getTypeName();
+        
+        assertEquals(RECORD_TYPE, type);
+    }
+    
+    @Test
+    public void testMethodReturs() {
+        // Ja pierdolę: uzupełniamy TypeParams poprawnie. Szok.
+        // Jakkolwiek JVM trochę abstrakcyjnie te sygnatury generuje ;)
+
+        ForRMethod p0 = new ForRMethod(){};
+        ForRMethod<Float> p1 = p0;
+        ForRMethod<String> p2 = p0;
+        
+        Object o1 = p1.new Record<Double>(){};
+        Object o2 = p2.new Record<Character>(){};
+        
+        IClass ic1 = IClass.typefor(o1);
+        IClass ic2 = IClass.typefor(o2);
+        
+        String o1map1 = ic1.methods().require("map1").first().toString();
+        String o1map2 = ic1.methods().require("map2").first().toString();
+        String o2map1 = ic2.methods().require("map1").first().toString();
+        String o2map2 = ic2.methods().require("map2").first().toString();
+        
+        assertEquals(Arrays.asList("Q=>class java.lang.Double", "T=>class java.lang.Float"), asText(ic1.context()));
+        assertEquals(Arrays.asList("Q=>class java.lang.Character", "T=>class java.lang.String"), asText(ic2.context()));
+        
+//        System.out.printf("1.context = %s%n", LexicalCast.toJSON(ic1.context().map()));
+//        System.out.printf("2.context = %s%n", LexicalCast.toJSON(ic2.context().map()));
+                
+        String e1map1 = MessageFormat.format(
+            "{1}<{2}, {1}<{3}, {1}<R, {4}>>> {0}<{3}>.map1(R a, {2} b, {3} c, {4} d)",
+            "net.ranides.assira.reflection.mockup.ForRMethod$Record",
+            "java.util.Map",
+            "java.lang.Float",
+            "java.lang.Double",
+            "java.lang.Integer"
+        );
+        String e1map2 = MessageFormat.format(
+            "{1}<{2}, {1}<{3}, {1}<R, {4}>>> {0}<{3}>.map2({5}<R> a, {5}<{2}> b, {5}<{3}> c, {5}<{4}> d)", 
+            "net.ranides.assira.reflection.mockup.ForRMethod$Record",
+            "java.util.Map",
+            "java.lang.Float",
+            "java.lang.Double",
+            "java.lang.Integer",
+            "java.util.List"
+        );
+        String e2map1 = MessageFormat.format(
+            "{1}<{2}, {1}<{3}, {1}<R, {4}>>> {0}<{3}>.map1(R a, {2} b, {3} c, {4} d)",
+            "net.ranides.assira.reflection.mockup.ForRMethod$Record",
+            "java.util.Map",
+            "java.lang.String",
+            "java.lang.Character",
+            "java.lang.Integer"
+        );
+        String e2map2 = MessageFormat.format(
+            "{1}<{2}, {1}<{3}, {1}<R, {4}>>> {0}<{3}>.map2({5}<R> a, {5}<{2}> b, {5}<{3}> c, {5}<{4}> d)", 
+            "net.ranides.assira.reflection.mockup.ForRMethod$Record",
+            "java.util.Map",
+            "java.lang.String",
+            "java.lang.Character",
+            "java.lang.Integer",
+            "java.util.List"
+        );
+        
+        assertEquals(e1map1, o1map1);
+        assertEquals(e1map2, o1map2);
+        assertEquals(e2map1, o2map1);
+        assertEquals(e2map2, o2map2);
+    }
+    
+    @Test
+    public void testTypeInfo() {
+        IClass type = IClass.typeinfo(TAction.class);
+        
+        IMethod m1 = type.methods().require("hello").first();
+        IMethod m2 = type.methods().require("stat").first();
+        
+        IMethod r1 = IMethod.typeinfo(m1.reflective());
+        IMethod r2 = IMethod.typeinfo(m2.reflective());
+        
+        assertEquals(m1, r1);
+        assertEquals(m2, r2);
+    }
+    
+    @Test
+    public void testApply() {
+        TAction a1 = new TAction(3);
+        TAction a2 = new TAction(10);
+        IMethod m1 = IClass.typefor(a1).methods().require("hello").first();
+        IMethod m2 = IClass.typefor(a1).methods().require("stat").first();
+        
+        assertEquals("[6:9]", m1.apply(a1, 2, 3));
+        assertEquals("[20:30]", m1.apply(a2, 2, 3));
+        
+        assertEquals("[2/3]", m2.apply(a1, 2, 3));
+        assertEquals("[2/3]", m2.apply(null, 2, 3));
+        
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.apply(a1, "q", 3);
+        });
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.apply(a1, 1, 2, 3);
+        });
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.apply(null, 2, 3);
+        });
+    }
+    
+    @Test
+    public void testCall() {
+        TAction a1 = new TAction(3);
+        TAction a2 = new TAction(10);
+        IMethod m1 = IClass.typefor(a1).methods().require("hello").first();
+        IMethod m2 = IClass.typefor(a1).methods().require("stat").first();
+        
+        assertEquals("[6:9]", m1.call(a1, 2, 3));
+        assertEquals("[20:30]", m1.call(a2, 2, 3));
+        
+        assertEquals("[2/3]", m2.call(2, 3));
+        assertThrows(WrongMethodTypeException.class, ()->{
+            m2.call(null, 2, 3);
+        });
+        assertThrows(ClassCastException.class, ()->{
+            m2.call("z", 3);
+        });
+        
+        assertThrows(ClassCastException.class, ()->{
+            m1.call(a1, "q", 3);
+        });
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.apply(a1, 1, 2, 3);
+        });
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.apply(null, 2, 3);
+        });
+    }
+    
+    @Test
+    public void testCallVoid() {
+        TAction a1 = new TAction(3);
+        TAction a2 = new TAction(10);
+        IMethod m0 = IClass.typefor(a1).methods().require("nop").first();
+        
+        assertEquals("nop!", m0.call());
+        assertEquals("nop!", m0.apply());
+//        
+//        assertEquals("[2/3]", m2.call(2, 3));
+//        assertThrows(WrongMethodTypeException.class, ()->{
+//            m2.call(null, 2, 3);
+//        });
+//        assertThrows(ClassCastException.class, ()->{
+//            m2.call("z", 3);
+//        });
+//        
+//        assertThrows(ClassCastException.class, ()->{
+//            m1.call(a1, "q", 3);
+//        });
+//        assertThrows(IllegalArgumentException.class, ()->{
+//            m1.apply(a1, 1, 2, 3);
+//        });
+//        assertThrows(IllegalArgumentException.class, ()->{
+//            m1.apply(null, 2, 3);
+//        });
+    }
+    
+    private static List<String> asText(IContext context) {
+        return context.map().entrySet().stream()
+            .map(Object::toString)
+            .sorted()
+            .collect(Collectors.toList());
+    }
+    
+}

+ 67 - 0
assira/src/test/java/net/ranides/assira/reflection/mockup/TestReflective.java

@@ -0,0 +1,67 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection.mockup;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import net.ranides.assira.generic.CompareUtils;
+import net.ranides.assira.junit.NewAssert;
+import net.ranides.assira.reflection.IClasses;
+import net.ranides.assira.reflection.IMethod;
+import net.ranides.assira.reflection.IMethods;
+import net.ranides.assira.text.StringUtils;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public class TestReflective {
+    
+    public static <T> List<T> remove(List<T> input) {
+        return input.stream().filter(n -> !n.toString().contains("jacoco")).collect(Collectors.toList());
+    }
+    
+    public static String asText(IMethod m) {
+        return m.name() + " " + m.arguments().types();
+    }
+    
+    public static List<String> asText(List<?> list) {
+        return list.stream().map(Object::toString).collect(Collectors.toList());
+    }
+    
+    public static void print(List<String> $0, List<?> values) {
+        values.sort(CompareUtils.comparator());
+        System.out.printf("%s%n", StringUtils.join(values, ", ", v -> StringUtils.quote(v.toString())));
+    }
+    
+    public static void print(List<String> $0, IMethods methods) {
+        System.out.printf(">>>>%n");
+        methods.each(c -> {
+            System.out.printf("    %s%n", asText(c));
+        });
+    }
+    
+    public static void print(List<String> $0, IClasses methods) {
+        System.out.printf(">>>>%n");
+        methods.each(c -> {
+            System.out.printf("   \"%s\",%n", c);
+        });
+    }
+    
+    public static <T> void assertEquals(List<String> expected, List<T> input) {
+        NewAssert.assertEquivalent(expected, asText(remove(input)));
+    }
+    
+    public static void assertEquals(List<String> expected, IMethods methods) {
+        NewAssert.assertEquivalent(expected, remove(methods.list(m -> asText(m))));
+    }
+    
+    public static void assertEquals(List<String> expected, IClasses classes) {
+        NewAssert.assertEquivalent(expected, remove(classes.list(m -> m.toString())));
+    }
+    
+}