From a4492af50cb0eafd85918b2755125f0bab162c63 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 11 Jul 2005 10:46:02 +0000 Subject: [PATCH] generics: lots of generic decp tests. --- .../systemtest/ajc150/GenericsTests.java | 77 ++++++++++++++++++- .../org/aspectj/systemtest/ajc150/ajc150.xml | 47 ++++++++++- 2 files changed, 117 insertions(+), 7 deletions(-) diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java index a385c6b92..d148b9850 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java @@ -4,6 +4,11 @@ import java.io.File; import junit.framework.Test; +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Signature; +import org.aspectj.apache.bcel.util.ClassPath; +import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.testing.XMLBasedAjcTestCase; public class GenericsTests extends XMLBasedAjcTestCase { @@ -97,14 +102,54 @@ public class GenericsTests extends XMLBasedAjcTestCase { // runTest("itd incorrectly using type parameter"); // } - // generic declare parents + // ---------------------------------------------------------------------------------------- + // generic declare parents tests + // ---------------------------------------------------------------------------------------- + public void testPR96220_GenericDecp() { runTest("generic decp - simple"); + verifyClassSignature("Basic","Ljava/lang/Object;LJ;LI;"); + } + + // Both the existing type decl and the one adding via decp are parameterized + public void testGenericDecpMultipleVariantsOfAParameterizedType1() { + runTest("generic decp - implementing two variants #1"); + } + + // Existing type decl is raw and the one added via decp is parameterized + public void testGenericDecpMultipleVariantsOfAParameterizedType2() { + runTest("generic decp - implementing two variants #2"); + } + + // Existing type decl is parameterized and the one added via decp is raw + public void testGenericDecpMultipleVariantsOfAParameterizedType3() { + runTest("generic decp - implementing two variants #3"); + } + + // decp is parameterized but it does match the one already on the type + public void testGenericDecpMultipleVariantsOfAParameterizedType4() { + runTest("generic decp - implementing two variants #4"); + } + + // same as above four tests for binary weaving + public void testGenericDecpMultipleVariantsOfAParameterizedType1_binaryWeaving() { + runTest("generic decp binary - implementing two variants #1"); + } + + public void testGenericDecpMultipleVariantsOfAParameterizedType2_binaryWeaving() { + runTest("generic decp binary - implementing two variants #2"); + } + + // Existing type decl is parameterized and the one added via decp is raw + public void testGenericDecpMultipleVariantsOfAParameterizedType3_binaryWeaving() { + runTest("generic decp binary - implementing two variants #3"); + } + + // decp is parameterized but it does match the one already on the type + public void testGenericDecpMultipleVariantsOfAParameterizedType4_binaryWeaving() { + runTest("generic decp binary - implementing two variants #4"); } -// public void testGenericDecpMultipleVariantsOfAParameterizedType() { -// runTest("generic decp - implementing two variants"); -// } // // public void testGenericDecpIncorrectNumberOfTypeParams() { // runTest("generic decp - incorrect number of type parameters"); @@ -132,4 +177,28 @@ public class GenericsTests extends XMLBasedAjcTestCase { // 1. public ITDs and separate compilation - are the signatures correct for the new public members? // 2. ITDF + + // --- helpers + + // Check the signature attribute on a class is correct + private void verifyClassSignature(String classname,String sig) { + try { + ClassPath cp = + new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path")); + SyntheticRepository sRepos = SyntheticRepository.getInstance(cp); + JavaClass clazz = sRepos.loadClass(classname); + Signature sigAttr = null; + Attribute[] attrs = clazz.getAttributes(); + for (int i = 0; i < attrs.length; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals("Signature")) sigAttr = (Signature)attribute; + } + assertTrue("Failed to find signature attribute for class "+classname,sigAttr!=null); + assertTrue("Expected signature to be '"+sig+"' but was '"+sigAttr.getSignature()+"'", + sigAttr.getSignature().equals(sig)); + } catch (ClassNotFoundException e) { + fail("Couldn't find class "+classname+" in the sandbox directory."); + } + } + } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 32155d554..bc11dfeb4 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -2396,10 +2396,51 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.5