diff options
author | aclement <aclement> | 2005-07-11 10:46:02 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-07-11 10:46:02 +0000 |
commit | a4492af50cb0eafd85918b2755125f0bab162c63 (patch) | |
tree | dd28d5b5f5c0d0a761706fe2a219cb091fb0b349 /tests/src | |
parent | 5de55b02cb75716fb4aba5fdf90e5e4e3f312ef5 (diff) | |
download | aspectj-a4492af50cb0eafd85918b2755125f0bab162c63.tar.gz aspectj-a4492af50cb0eafd85918b2755125f0bab162c63.zip |
generics: lots of generic decp tests.
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java | 77 | ||||
-rw-r--r-- | tests/src/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<Ljava/lang/Double;>;LI<Ljava/lang/Double;>;"); + } + + // 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 @@ <run class="Basic"/> </ajc-test> - <ajc-test dir="java5/generics/decp" title="generic decp - implementing two variants"> - <compile files="Basic2.aj" options="-1.5"/> - <run class="Basic2"/> + <ajc-test dir="java5/generics/decp" title="generic decp - implementing two variants #1"> + <compile files="Basic2.aj" options="-1.5"> + <message kind="error" line="11" text="Cannot declare parent I<java.lang.Integer> onto type Basic2 since it already has I<java.lang.String> in its hierarchy"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/decp" title="generic decp - implementing two variants #2"> + <compile files="Basic2b.aj" options="-1.5"> + <message kind="error" line="10" text="Cannot declare parent I<java.lang.Integer> onto type Basic2b since it already has I in its hierarchy"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/decp" title="generic decp - implementing two variants #3"> + <compile files="Basic2c.aj" options="-1.5"> + <message kind="error" line="10" text="Cannot declare parent I onto type Basic2c since it already has I<java.lang.Double> in its hierarchy"/> + </compile> + </ajc-test> + + <ajc-test dir="java5/generics/decp" title="generic decp - implementing two variants #4"> + <compile files="Basic2d.aj" options="-1.5"/> </ajc-test> + + <ajc-test dir="java5/generics/decp/binary" title="generic decp binary - implementing two variants #1"> + <weave classesFiles="Base1.java" aspectsFiles="Asp1.aj" options="-1.5,-showWeaveInfo"> + <message kind="error" line="2" text="Cannot declare parent I<java.lang.Integer> onto type Base1 since it already has I<java.lang.String> in its hierarchy"/> + </weave> + </ajc-test> + + <ajc-test dir="java5/generics/decp/binary" title="generic decp binary - implementing two variants #2"> + <weave classesFiles="Base2.java" aspectsFiles="Asp2.aj" options="-1.5,-showWeaveInfo"> + <message kind="error" line="2" text="Cannot declare parent I<java.lang.Integer> onto type Base2 since it already has I in its hierarchy"/> + </weave> + </ajc-test> + + <ajc-test dir="java5/generics/decp/binary" title="generic decp binary - implementing two variants #3"> + <weave classesFiles="Base3.java" aspectsFiles="Asp3.aj" options="-1.5,-showWeaveInfo"> + <message kind="error" line="2" text="Cannot declare parent I onto type Base3 since it already has I<java.lang.Double> in its hierarchy"/> + </weave> + </ajc-test> + + <ajc-test dir="java5/generics/decp/binary" title="generic decp binary - implementing two variants #4"> + <weave classesFiles="Base4.java" aspectsFiles="Asp4.aj" options="-1.5,-showWeaveInfo"/> + </ajc-test> + +<!-- --> <ajc-test dir="java5/generics/decp" title="generic decp - incorrect number of type parameters"> <compile files="Basic3.aj" options="-1.5"/> |