summaryrefslogtreecommitdiffstats
path: root/tests/hasmember
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-08-21 19:53:30 +0000
committeracolyer <acolyer>2005-08-21 19:53:30 +0000
commit262edc95da3a65bb4c86024abf531ac0ddf8bd69 (patch)
tree8c42083fa9677838168e3ddc6a8fd5ad7b1f8e7e /tests/hasmember
parentce7e64ba610a2957b81d373986668c6cf60b8722 (diff)
downloadaspectj-262edc95da3a65bb4c86024abf531ac0ddf8bd69.tar.gz
aspectj-262edc95da3a65bb4c86024abf531ac0ddf8bd69.zip
hasmember (hasmethod / hasfield) tests - not linked into main suite at this point in time
Diffstat (limited to 'tests/hasmember')
-rw-r--r--tests/hasmember/HasField.aj19
-rw-r--r--tests/hasmember/HasFieldInherited.aj28
-rw-r--r--tests/hasmember/HasMethod.aj19
-rw-r--r--tests/hasmember/HasMethodInherited.aj28
-rw-r--r--tests/hasmember/HasMethodViaITD.aj17
-rw-r--r--tests/hasmember/HasPrivateFieldInherited.aj28
-rw-r--r--tests/hasmember/HasPrivateMethodInherited.aj28
7 files changed, 167 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