diff options
author | acolyer <acolyer> | 2005-08-21 19:53:30 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-08-21 19:53:30 +0000 |
commit | 262edc95da3a65bb4c86024abf531ac0ddf8bd69 (patch) | |
tree | 8c42083fa9677838168e3ddc6a8fd5ad7b1f8e7e /tests | |
parent | ce7e64ba610a2957b81d373986668c6cf60b8722 (diff) | |
download | aspectj-262edc95da3a65bb4c86024abf531ac0ddf8bd69.tar.gz aspectj-262edc95da3a65bb4c86024abf531ac0ddf8bd69.zip |
hasmember (hasmethod / hasfield) tests - not linked into main suite at this point in time
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hasmember/HasField.aj | 19 | ||||
-rw-r--r-- | tests/hasmember/HasFieldInherited.aj | 28 | ||||
-rw-r--r-- | tests/hasmember/HasMethod.aj | 19 | ||||
-rw-r--r-- | tests/hasmember/HasMethodInherited.aj | 28 | ||||
-rw-r--r-- | tests/hasmember/HasMethodViaITD.aj | 17 | ||||
-rw-r--r-- | tests/hasmember/HasPrivateFieldInherited.aj | 28 | ||||
-rw-r--r-- | tests/hasmember/HasPrivateMethodInherited.aj | 28 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/HasMember.java | 57 |
8 files changed, 224 insertions, 0 deletions
diff --git a/tests/hasmember/HasField.aj b/tests/hasmember/HasField.aj new file mode 100644 index 000000000..d8b4ef522 --- /dev/null +++ b/tests/hasmember/HasField.aj @@ -0,0 +1,19 @@ +public aspect HasField { + + declare parents : hasfield(* printer) implements Printable; + + public static void main(String[] args) { + C c = new C(); + if (! (c instanceof Printable)) { + throw new RuntimeException("declare parents : hasfield failed"); + } + } +} + +class C { + + int printer; + +} + +interface Printable {};
\ No newline at end of file diff --git a/tests/hasmember/HasFieldInherited.aj b/tests/hasmember/HasFieldInherited.aj new file mode 100644 index 000000000..bed5b42a0 --- /dev/null +++ b/tests/hasmember/HasFieldInherited.aj @@ -0,0 +1,28 @@ +public aspect HasFieldInherited { + + declare parents : D && hasfield(* printer) implements Printable; + + public static void main(String[] args) { + C c = new C(); + if ((c instanceof Printable)) { + throw new RuntimeException("declare parents : hasfield failed on super"); + } + D d = new D(); + if (!(d instanceof Printable)) { + throw new RuntimeException("declare parents : hasfield failed on sub"); + } + + } +} + +class C { + + String printer; + +} + +class D extends C { + +} + +interface Printable {};
\ No newline at end of file diff --git a/tests/hasmember/HasMethod.aj b/tests/hasmember/HasMethod.aj new file mode 100644 index 000000000..dc1bb3eb7 --- /dev/null +++ b/tests/hasmember/HasMethod.aj @@ -0,0 +1,19 @@ +public aspect HasMethod { + + declare parents : hasmethod(* print(..)) implements Printable; + + public static void main(String[] args) { + C c = new C(); + if (! (c instanceof Printable)) { + throw new RuntimeException("declare parents : hasmethod failed"); + } + } +} + +class C { + + public void print() {} + +} + +interface Printable {};
\ No newline at end of file diff --git a/tests/hasmember/HasMethodInherited.aj b/tests/hasmember/HasMethodInherited.aj new file mode 100644 index 000000000..1c5aaaaca --- /dev/null +++ b/tests/hasmember/HasMethodInherited.aj @@ -0,0 +1,28 @@ +public aspect HasMethodInherited { + + declare parents : D && hasmethod(* print(..)) implements Printable; + + public static void main(String[] args) { + C c = new C(); + if ((c instanceof Printable)) { + throw new RuntimeException("declare parents : hasmethod failed on super"); + } + D d = new D(); + if (!(d instanceof Printable)) { + throw new RuntimeException("declare parents : hasmethod failed on sub"); + } + + } +} + +class C { + + protected void print() {} + +} + +class D extends C { + +} + +interface Printable {};
\ No newline at end of file diff --git a/tests/hasmember/HasMethodViaITD.aj b/tests/hasmember/HasMethodViaITD.aj new file mode 100644 index 000000000..5573675d5 --- /dev/null +++ b/tests/hasmember/HasMethodViaITD.aj @@ -0,0 +1,17 @@ +public aspect HasMethodViaITD { + + declare parents : hasmethod(* foo()) implements I; + + // C gets foo via ITD + public void C.foo() {} + + declare warning : execution(* I+.bar()) : "hasmethod matched on ITD ok"; +} + +interface I {} + +class C { + + void bar() {} + +}
\ No newline at end of file diff --git a/tests/hasmember/HasPrivateFieldInherited.aj b/tests/hasmember/HasPrivateFieldInherited.aj new file mode 100644 index 000000000..b4d7b9abc --- /dev/null +++ b/tests/hasmember/HasPrivateFieldInherited.aj @@ -0,0 +1,28 @@ +public aspect HasPrivateFieldInherited { + + declare parents : D && hasfield(* printer) implements Printable; + + public static void main(String[] args) { + C c = new C(); + if ((c instanceof Printable)) { + throw new RuntimeException("declare parents : hasfield failed on super"); + } + D d = new D(); + if ((d instanceof Printable)) { + throw new RuntimeException("declare parents : hasfield failed on sub"); + } + + } +} + +class C { + + private String printer; + +} + +class D extends C { + +} + +interface Printable {};
\ No newline at end of file diff --git a/tests/hasmember/HasPrivateMethodInherited.aj b/tests/hasmember/HasPrivateMethodInherited.aj new file mode 100644 index 000000000..dff672b6a --- /dev/null +++ b/tests/hasmember/HasPrivateMethodInherited.aj @@ -0,0 +1,28 @@ +public aspect HasPrivateMethodInherited { + + declare parents : D && hasmethod(* print(..)) implements Printable; + + public static void main(String[] args) { + C c = new C(); + if ((c instanceof Printable)) { + throw new RuntimeException("declare parents : hasmethod failed on super"); + } + D d = new D(); + if ((d instanceof Printable)) { + throw new RuntimeException("declare parents : hasmethod failed on sub"); + } + + } +} + +class C { + + private void print() {} + +} + +class D extends C { + +} + +interface Printable {};
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/HasMember.java b/tests/src/org/aspectj/systemtest/ajc150/HasMember.java new file mode 100644 index 000000000..9eb7ba5af --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc150/HasMember.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Adrian Colyer - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class HasMember extends XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(HasMember.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml"); + } + + public void testSimpleDecPHasMethod() { + runTest("declare parents : hasmethod(..) - 1"); + } + + public void testSimpleDecPHasMethodInherited() { + runTest("declare parents : hasmethod(..) - 2"); + } + + public void testSimpleDecPHasMethodInheritedPrivate() { + runTest("declare parents : hasmethod(..) - 3"); + } + + public void testDecPHasMethodViaITD() { + runTest("declare parents : hasmethod(..) - 4"); + } + + public void testSimpleDecPHasField() { + runTest("declare parents : hasfield(..) - 1"); + } + + public void testSimpleDecPHasFieldInherited() { + runTest("declare parents : hasfield(..) - 2"); + } + + public void testSimpleDecPHasFieldInheritedPrivate() { + runTest("declare parents : hasfield(..) - 3"); + } + +}
\ No newline at end of file |