From fea6769e84439cd0a1c26fed11755a17772d85ed Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 14 Jun 2005 14:56:51 +0000 Subject: [PATCH] Some new TypeX tests to check parameterization processing is working. --- .../org/aspectj/weaver/TypeXTestCase.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java b/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java index 1ba812845..500baacd8 100644 --- a/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/TypeXTestCase.java @@ -76,6 +76,44 @@ public class TypeXTestCase extends TestCase { assertEquals(t.getName(),"java.util.Map>"); assertEquals(t.getSignature(),"Ljava/util/Map;>;"); } + + /** + * Verify TypeX signature processing creates the right kind of TypeX's from a signature. + * + * For example, calling TypeX.dump() for + * "Ljava/util/Map;Ljava/lang/String;>;" + * results in: + * TypeX: signature=Ljava/util/Map;Ljava/lang/String;>; parameterized=true #params=2 + * TypeX: signature=Ljava/util/List; parameterized=true #params=1 + * TypeX: signature=Ljava/lang/String; parameterized=false #params=0 + * TypeX: signature=Ljava/lang/String; parameterized=false #params=0 + */ + public void testTypexGenericSignatureProcessing() { + TypeX tx = null; + + tx = new TypeX("Ljava/util/Set;"); + checkTX(tx,true,1); + + tx = new TypeX("Ljava/util/Set;>;"); + checkTX(tx,true,1); + + tx = new TypeX("Ljava/util/Map;Ljava/lang/String;>;"); + checkTX(tx,true,2); + checkTX(tx.getTypeParameters()[0],true,1); + checkTX(tx.getTypeParameters()[1],false,0); +// System.err.println(tx.dump()); + } + + private void checkTX(TypeX tx,boolean shouldBeParameterized,int numberOfTypeParameters) { + assertTrue("Expected parameterization flag to be "+shouldBeParameterized,tx.isParameterized()==shouldBeParameterized); + if (numberOfTypeParameters==0) { + TypeX[] params = tx.getTypeParameters(); + assertTrue("Expected 0 type parameters but found "+params.length,params==null || params.length==0); + } else { + assertTrue("Expected #type parameters to be "+numberOfTypeParameters,tx.getTypeParameters().length==numberOfTypeParameters); + } + } + private void isPrimitiveTest(TypeX[] types, boolean[] isPrimitives) { for (int i = 0, len = types.length; i < len; i++) { -- 2.39.5