From: acolyer Date: Mon, 11 Jul 2005 09:37:21 +0000 (+0000) Subject: test case for Enum conversions X-Git-Tag: PRE_ANDY~49 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b5ad17eebeb1b8baf6748ba0125219a15a8925e2;p=aspectj.git test case for Enum conversions --- diff --git a/weaver/testsrc/BcweaverModuleTests15.java b/weaver/testsrc/BcweaverModuleTests15.java index c00f055f1..b4612e6d4 100644 --- a/weaver/testsrc/BcweaverModuleTests15.java +++ b/weaver/testsrc/BcweaverModuleTests15.java @@ -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 index 000000000..241d939cb --- /dev/null +++ b/weaver/testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java @@ -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;>;",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("Ljava/lang/Object;LBase;"); + 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); + + } + +}