diff options
author | aclement <aclement> | 2010-07-30 03:51:56 +0000 |
---|---|---|
committer | aclement <aclement> | 2010-07-30 03:51:56 +0000 |
commit | 34b6b7ea43e739b9e70fb3f64e94e50f420f095a (patch) | |
tree | 82a7e240dc5815a71ce6172b16b187b12d8c38bd /org.aspectj.matcher/testsrc | |
parent | 3f281a1935b5b237be4d0d18d95af563b6e13893 (diff) | |
download | aspectj-34b6b7ea43e739b9e70fb3f64e94e50f420f095a.tar.gz aspectj-34b6b7ea43e739b9e70fb3f64e94e50f420f095a.zip |
320358: type signature changes
Diffstat (limited to 'org.aspectj.matcher/testsrc')
-rw-r--r-- | org.aspectj.matcher/testsrc/org/aspectj/weaver/MatcherModuleTests.java | 1 | ||||
-rw-r--r-- | org.aspectj.matcher/testsrc/org/aspectj/weaver/TypeFactoryTests.java | 76 |
2 files changed, 77 insertions, 0 deletions
diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/MatcherModuleTests.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/MatcherModuleTests.java index 5b646c5df..234e387de 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/MatcherModuleTests.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/MatcherModuleTests.java @@ -33,6 +33,7 @@ public class MatcherModuleTests extends TestCase { suite.addTestSuite(ReflectionWorldSpecificTest.class); suite.addTestSuite(ReflectionWorldBasicTest.class); suite.addTestSuite(ReflectionWorldPointcutExpressionTests.class); + suite.addTestSuite(TypeFactoryTests.class); suite.addTest(PatternsTests.suite()); return suite; } diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/TypeFactoryTests.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/TypeFactoryTests.java new file mode 100644 index 000000000..40fed411a --- /dev/null +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/TypeFactoryTests.java @@ -0,0 +1,76 @@ +/* ******************************************************************* + * Copyright (c) 2010 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 + * ******************************************************************/ +package org.aspectj.weaver; + +import junit.framework.TestCase; + +/** + * Check signature to type mapping. + * + * @author Andy Clement + */ +public class TypeFactoryTests extends TestCase { + + public void testParameterizedSig() { + UnresolvedType t = null; + t = UnresolvedType.forSignature("Pjava/util/List<Ljava/lang/String;>;"); + assertEquals("Ljava/util/List;", t.getErasureSignature()); + assertEquals("Ljava/lang/String;", t.getTypeParameters()[0].signature); + assertEquals("Ljava/lang/String;", t.getTypeParameters()[0].signatureErasure); + assertEquals("Pjava/util/List<Ljava/lang/String;>;", t.getSignature()); + + t = TypeFactory.createTypeFromSignature("Ljava/util/List<Ljava/lang/String;>;"); + assertEquals("Ljava/util/List;", t.getErasureSignature()); + assertEquals("Ljava/lang/String;", t.getTypeParameters()[0].signature); + assertEquals("Ljava/lang/String;", t.getTypeParameters()[0].signatureErasure); + assertEquals("Pjava/util/List<Ljava/lang/String;>;", t.getSignature()); + + t = UnresolvedType.forName("java.util.List<java.lang.String>"); + assertEquals("Ljava/util/List;", t.getErasureSignature()); + assertEquals("Ljava/lang/String;", t.getTypeParameters()[0].signature); + assertEquals("Ljava/lang/String;", t.getTypeParameters()[0].signatureErasure); + assertEquals("Pjava/util/List<Ljava/lang/String;>;", t.getSignature()); + + t = UnresolvedType.forSignature("Pjava/util/Map<TS;Pjava/util/List<Ljava/lang/String;>;>;"); + assertEquals("Ljava/util/Map;", t.getErasureSignature()); + assertEquals("TS;", t.getTypeParameters()[0].signature); + assertEquals("Ljava/lang/Object;", t.getTypeParameters()[0].signatureErasure); + assertEquals("S", ((UnresolvedTypeVariableReferenceType) t.getTypeParameters()[0]).getTypeVariable().getName()); + assertEquals("Pjava/util/Map<TS;Pjava/util/List<Ljava/lang/String;>;>;", t.getSignature()); + assertEquals("Pjava/util/List<Ljava/lang/String;>;", t.getTypeParameters()[1].signature); + assertEquals("Ljava/util/List;", t.getTypeParameters()[1].signatureErasure); + + t = UnresolvedType.forSignature("Pjava/util/List<+Pnl/ZoekFoo<TS;Pnl/ZoekCopy<TS;>;>;>;"); + assertEquals("Ljava/util/List;", t.getErasureSignature()); + WildcardedUnresolvedType wut = (WildcardedUnresolvedType) t.getTypeParameters()[0]; + assertEquals("+Pnl/ZoekFoo<TS;Pnl/ZoekCopy<TS;>;>;", wut.signature); + assertEquals("Lnl/ZoekFoo;", wut.signatureErasure); + assertTrue(wut.isExtends()); + assertEquals("Pnl/ZoekFoo<TS;Pnl/ZoekCopy<TS;>;>;", wut.getUpperBound().signature); + assertEquals("Lnl/ZoekFoo;", wut.getUpperBound().signatureErasure); + UnresolvedTypeVariableReferenceType tvar = (UnresolvedTypeVariableReferenceType) wut.getUpperBound().getTypeParameters()[0]; + assertEquals("Pnl/ZoekFoo<TS;Pnl/ZoekCopy<TS;>;>;", wut.getUpperBound().signature); + assertEquals("Lnl/ZoekFoo;", wut.getUpperBound().signatureErasure); + assertEquals("S", tvar.getTypeVariable().getName()); + UnresolvedType t2 = wut.getUpperBound().getTypeParameters()[1]; + assertEquals("Pnl/ZoekCopy<TS;>;", t2.getSignature()); + assertEquals("Lnl/ZoekCopy;", t2.getErasureSignature()); + + // // t = UnresolvedType.forSignature("Ljava/util/List<+Lnl/ZoekFoo<TS;Lnl/ZoekCopy<TS;>;>;>;"); + // t = TypeFactory.createTypeFromSignature("Ljava/util/List<+Lnl/ZoekFoo<TS;Lnl/ZoekCopy<TS;>;>;>;"); + // System.out.println(t.getSignature()); + // + // t = TypeFactory.createTypeFromSignature("Ljava/util/List<Lnl/ZoekFoo<Ljava/lang/String;>;>;"); + // System.out.println(t.getSignature()); // Pjava/util/List<Lnl/ZoekFoo<Ljava/lang/String;>;>; + + // TODO should be able to cope with nested parameterizations + // Foo<String>.Bar<List<Map<String,Integer>>> + // both components Foo and Bar of that are parameterized + } +} |