]> source.dussan.org Git - aspectj.git/commitdiff
test case for Enum conversions
authoracolyer <acolyer>
Mon, 11 Jul 2005 09:37:21 +0000 (09:37 +0000)
committeracolyer <acolyer>
Mon, 11 Jul 2005 09:37:21 +0000 (09:37 +0000)
weaver/testsrc/BcweaverModuleTests15.java
weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java [new file with mode: 0644]

index c00f055f1498ee71c482caf5e635f218c7095e76..b4612e6d471bb9a9042949145244eb21c7e26aa1 100644 (file)
@@ -19,6 +19,7 @@ import org.aspectj.weaver.MemberTestCase15;
 import org.aspectj.weaver.ReferenceTypeTestCase;
 import org.aspectj.weaver.TypeVariableReferenceTypeTestCase;
 import org.aspectj.weaver.TypeVariableTestCase;
+import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXTestCase;
 
 public class BcweaverModuleTests15 extends TestCase {
           public static Test suite() { 
@@ -29,6 +30,7 @@ public class BcweaverModuleTests15 extends TestCase {
                suite.addTestSuite(TypeVariableReferenceTypeTestCase.class);
                suite.addTestSuite(GenericsWildCardTypeXTestCase.class);
                suite.addTestSuite(MemberTestCase15.class);
+               suite.addTestSuite(BcelGenericSignatureToTypeXTestCase.class);
                return suite;
            }
 
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java
new file mode 100644 (file)
index 0000000..241d939
--- /dev/null
@@ -0,0 +1,73 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver.bcel;
+
+import org.aspectj.apache.bcel.Repository;
+import org.aspectj.apache.bcel.classfile.GenericSignatureParser;
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.Signature;
+import org.aspectj.weaver.ResolvedTypeX;
+import org.aspectj.weaver.TypeVariable;
+import org.aspectj.weaver.TypeX;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ *
+ */
+public class BcelGenericSignatureToTypeXTestCase extends TestCase {
+
+       public void testEnumFromHell() {
+               BcelWorld world = new BcelWorld();
+               JavaClass javaLangEnum = Repository.lookupClass("java/lang/Enum");
+               Signature.ClassSignature cSig = javaLangEnum.getGenericClassTypeSignature();
+               TypeX superclass = 
+                       BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                                       cSig.superclassSignature,
+                                       cSig.formalTypeParameters,
+                                       world
+                                       );
+               assertEquals("Ljava/lang/Object;",superclass.getSignature());
+               assertEquals("2 superinterfaces",2,cSig.superInterfaceSignatures.length);
+               TypeX comparable = 
+                       BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                                       cSig.superInterfaceSignatures[0],
+                                       cSig.formalTypeParameters,
+                                       world
+                                       );                      
+               assertEquals("Ljava/lang/Comparable<Ljava/lang/Enum<Ljava/lang/Object;>;>;",comparable.getSignature());
+               TypeX serializable = 
+                       BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                                       cSig.superInterfaceSignatures[1],
+                                       cSig.formalTypeParameters,
+                                       world
+                                       );
+               assertEquals("Ljava/io/Serializable;",serializable.getSignature());
+       }
+       
+       public void testInners() {
+               BcelWorld world = new BcelWorld();
+               Signature.ClassSignature cSig = new GenericSignatureParser().parseAsClassSignature("<T::LBase$Inner;>Ljava/lang/Object;LBase<TT;>;");
+               TypeX resolved = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                               cSig.superclassSignature,
+                               cSig.formalTypeParameters,
+                               world);
+               assertEquals("Ljava/lang/Object;",resolved.getSignature());
+               TypeX resolvedInt = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                               cSig.superInterfaceSignatures[0],
+                               cSig.formalTypeParameters,
+                               world);
+               
+       }
+       
+}