]> source.dussan.org Git - aspectj.git/commitdiff
annoValMatch: testcode
authoraclement <aclement>
Mon, 25 Feb 2008 21:28:33 +0000 (21:28 +0000)
committeraclement <aclement>
Mon, 25 Feb 2008 21:28:33 +0000 (21:28 +0000)
16 files changed:
tests/features160/annotationValueMatching/AllKinds.java [new file with mode: 0644]
tests/features160/annotationValueMatching/BooleanValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/ByteValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/CharValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/DoubleValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/Error.java [new file with mode: 0644]
tests/features160/annotationValueMatching/ErrorOne.java [new file with mode: 0644]
tests/features160/annotationValueMatching/ExampleOne.java [new file with mode: 0644]
tests/features160/annotationValueMatching/FloatValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/IntValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/LongValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/MultiTypePatterns.java [new file with mode: 0644]
tests/features160/annotationValueMatching/Parsing.java
tests/features160/annotationValueMatching/ShortValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/StringValueMatching.java [new file with mode: 0644]
tests/features160/annotationValueMatching/Test.java [new file with mode: 0644]

diff --git a/tests/features160/annotationValueMatching/AllKinds.java b/tests/features160/annotationValueMatching/AllKinds.java
new file mode 100644 (file)
index 0000000..9ba3221
--- /dev/null
@@ -0,0 +1,39 @@
+import java.lang.annotation.*;
+
+public class AllKinds {
+       public static void main(String[] args) {
+               
+       }
+}
+
+enum Color { RED, GREEN, AMBER }
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface ComplexAnnotation {
+  int ival();
+  byte bval();
+  char cval();
+  long jval();
+  double dval();
+  boolean zval();
+  short sval();
+  float fval();
+  Color enumval();
+  String strval();
+  Class clazzval();
+  int[] arrayval();
+}
+
+aspect X {     
+  pointcut p1(): execution(@ComplexAnnotation(ival=5) * *(..)); 
+  pointcut p2(): execution(@ComplexAnnotation(bval=5) * *(..)); 
+  pointcut p3(): execution(@ComplexAnnotation(cval='5') * *(..)); 
+  pointcut p4(): execution(@ComplexAnnotation(jval=32232323) * *(..)); 
+  pointcut p5(): execution(@ComplexAnnotation(dval=5.0) * *(..)); 
+  pointcut p6(): execution(@ComplexAnnotation(zval=true) * *(..)); 
+  pointcut p7(): execution(@ComplexAnnotation(sval=42) * *(..)); 
+  pointcut p8(): execution(@ComplexAnnotation(enumval=Color.GREEN) * *(..)); 
+  pointcut p9(): execution(@ComplexAnnotation(strval="Hello") * *(..)); 
+//  pointcut pa(): execution(@ComplexAnnotation(clazzval=String.class) * *(..)); 
+//  pointcut pb(): execution(@ComplexAnnotation(arrayval={1,2,3}) * *(..)); 
+}
diff --git a/tests/features160/annotationValueMatching/BooleanValueMatching.java b/tests/features160/annotationValueMatching/BooleanValueMatching.java
new file mode 100644 (file)
index 0000000..bb11e2a
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.*;
+
+public class BooleanValueMatching {
+  public static void main(String[] args) { }
+
+  @Anno(zval=true) public void methodOne() {}
+  @Anno(zval=false) public void methodTwo() {}
+}
+
+@interface Anno {
+  boolean zval();
+}
+
+
+aspect X {     
+  before(): execution(@Anno(zval=true) * *(..))  {}
+}
diff --git a/tests/features160/annotationValueMatching/ByteValueMatching.java b/tests/features160/annotationValueMatching/ByteValueMatching.java
new file mode 100644 (file)
index 0000000..8c9001c
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.*;
+
+public class ByteValueMatching {
+  public static void main(String[] args) { }
+
+  @Anno(bval=123) public void methodOne() {}
+  @Anno(bval=27) public void methodTwo() {}
+}
+
+@interface Anno {
+  byte bval();
+}
+
+
+aspect X {     
+  before(): execution(@Anno(bval=123) * *(..))  {}
+}
diff --git a/tests/features160/annotationValueMatching/CharValueMatching.java b/tests/features160/annotationValueMatching/CharValueMatching.java
new file mode 100644 (file)
index 0000000..8a440a5
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.*;
+
+public class CharValueMatching {
+  public static void main(String[] args) { }
+
+  @Anno(cval='e') public void methodOne() {}
+  @Anno(cval='a') public void methodTwo() {}
+}
+
+@interface Anno {
+  char cval();
+}
+
+
+aspect X {     
+  before(): execution(@Anno(cval='a') * *(..))  {}
+}
diff --git a/tests/features160/annotationValueMatching/DoubleValueMatching.java b/tests/features160/annotationValueMatching/DoubleValueMatching.java
new file mode 100644 (file)
index 0000000..f6b3109
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.*;
+
+public class DoubleValueMatching {
+  public static void main(String[] args) { }
+
+  @Anno(dval=37.01) public void methodOne() {}
+  @Anno(dval=52.123) public void methodTwo() {}
+}
+
+@interface Anno {
+  double dval();
+}
+
+
+aspect X {     
+  before(): execution(@Anno(dval=37.01) * *(..))  {}
+}
diff --git a/tests/features160/annotationValueMatching/Error.java b/tests/features160/annotationValueMatching/Error.java
new file mode 100644 (file)
index 0000000..c36e2f4
--- /dev/null
@@ -0,0 +1,36 @@
+import java.lang.annotation.*;
+
+public class Error {
+  public static void main(String[] args) { }
+
+}
+
+@interface Anno {
+  int ival();
+  float fval();
+  double dval();
+  byte bval();
+  short sval();
+  boolean zval();
+  long jval();
+  Color enumval();
+  char cval();
+  String stringval();
+}
+
+enum Color { RED,GREEN,BLUE };
+
+aspect X {     
+    before(): execution(@Anno(ival=Color.GREEN) * *(..)) {}
+    before(): execution(@Anno(fval="hello") * *(..))  {} // invalid
+    before(): execution(@Anno(bval="foo") * *(..)) {}
+    before(): execution(@Anno(cval="no") * *(..))  {}
+    before(): execution(@Anno(jval=30.0f) * *(..))  {}
+    before(): execution(@Anno(dval="foo") * *(..)) {}
+    before(): execution(@Anno(zval=123) * *(..)) {}
+    before(): execution(@Anno(sval=4212312312) * *(..)) {}
+    before(): execution(@Anno(enumval=12) * *(..)) {}
+    before(): execution(@Anno(stringval=234) * *(..)) {}
+//  before(): execution(@Anno(clazzval=String.class) * *(..)); 
+//  before(): execution(@Anno(arrayval={1,2,3}) * *(..)); 
+}
diff --git a/tests/features160/annotationValueMatching/ErrorOne.java b/tests/features160/annotationValueMatching/ErrorOne.java
new file mode 100644 (file)
index 0000000..aae8074
--- /dev/null
@@ -0,0 +1,16 @@
+import java.lang.annotation.*;
+
+public class ErrorOne {
+  public static void main(String[] args) { }
+}
+
+@interface Anno {
+  float fval();
+}
+
+enum Color { RED,GREEN,BLUE };
+
+// Non existent value of the annotation!
+aspect X {     
+    before(): execution(@Anno(ival=Color.GREEN) * *(..)) {}
+}
diff --git a/tests/features160/annotationValueMatching/ExampleOne.java b/tests/features160/annotationValueMatching/ExampleOne.java
new file mode 100644 (file)
index 0000000..5cb6ca8
--- /dev/null
@@ -0,0 +1,48 @@
+
+enum TraceLevel { NONE, LEVEL1, LEVEL2, LEVEL3 }
+
+@interface Trace {
+  TraceLevel value() default TraceLevel.NONE;
+}
+  
+aspect X {
+  before(): execution(@Trace !@Trace(TraceLevel.NONE) * *(..)) {
+    System.err.println("tracing "+thisJoinPoint);
+  }
+}
+
+public class ExampleOne {
+
+  public static void main(String[] args) {
+    ExampleOne eOne = new ExampleOne();
+    eOne.m001();
+    eOne.m002();
+    eOne.m003();
+    eOne.m004();
+    eOne.m005();
+    eOne.m006();
+    eOne.m007();
+  }
+
+  @Trace(TraceLevel.NONE)
+  public void m001() {}
+
+  @Trace(TraceLevel.LEVEL2)
+  public void m002() {}
+
+  @Trace(TraceLevel.LEVEL3)
+  public void m003() {}
+
+  @Trace(TraceLevel.NONE)
+  public void m004() {}
+
+  @Trace(TraceLevel.LEVEL2)
+  public void m005() {}
+
+  @Trace(TraceLevel.NONE)
+  public void m006() {}
+
+  @Trace
+  public void m007() {}
+
+}
diff --git a/tests/features160/annotationValueMatching/FloatValueMatching.java b/tests/features160/annotationValueMatching/FloatValueMatching.java
new file mode 100644 (file)
index 0000000..d20b7df
--- /dev/null
@@ -0,0 +1,28 @@
+import java.lang.annotation.*;
+
+public class FloatValueMatching {
+  public static void main(String[] args) { }
+
+  @Anno(fval=37.0f) public void methodOne() {}
+  @Anno(fval=52.1f) public void methodTwo() {}
+}
+
+@interface Anno {
+  float fval();
+}
+
+
+aspect X {     
+//  before(): execution(@Anno(ival=5) * *(..)) {}
+    before(): execution(@Anno(fval=52.1f) * *(..))  {}
+//  before(): execution(@Anno(bval=5) * *(..)) {}
+//  before(): execution(@Anno(cval='5') * *(..))  {}
+//  before(): execution(@Anno(jval=32232323) * *(..))  {}
+//  before(): execution(@Anno(dval=5.0) * *(..)) {}
+//  before(): execution(@Anno(zval=true) * *(..)) {}
+//  before(): execution(@Anno(sval=42) * *(..)) {}
+//  before(): execution(@Anno(enumval=Color.GREEN) * *(..)) {}
+//  before(): execution(@Anno(strval="Hello") * *(..)) {}
+//  before(): execution(@Anno(clazzval=String.class) * *(..)); 
+//  before(): execution(@Anno(arrayval={1,2,3}) * *(..)); 
+}
diff --git a/tests/features160/annotationValueMatching/IntValueMatching.java b/tests/features160/annotationValueMatching/IntValueMatching.java
new file mode 100644 (file)
index 0000000..c04af38
--- /dev/null
@@ -0,0 +1,32 @@
+import java.lang.annotation.*;
+
+public class IntValueMatching {
+       public static void main(String[] args) {
+               
+       }
+
+  @Anno(ival=3) public void a() {}
+  @Anno(ival=5) public void b() {}
+}
+
+enum Color { RED, GREEN, AMBER }
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {
+  int ival();
+}
+
+
+aspect X {     
+  before(): execution(@Anno(ival=5) * *(..)) {}
+//  before(): execution(@Anno(bval=5) * *(..)) {}
+//  before(): execution(@Anno(cval='5') * *(..))  {}
+//  before(): execution(@Anno(jval=32232323) * *(..))  {}
+//  before(): execution(@Anno(dval=5.0) * *(..)) {}
+//  before(): execution(@Anno(zval=true) * *(..)) {}
+//  before(): execution(@Anno(sval=42) * *(..)) {}
+//  before(): execution(@Anno(enumval=Color.GREEN) * *(..)) {}
+//  before(): execution(@Anno(strval="Hello") * *(..)) {}
+//  before(): execution(@Anno(clazzval=String.class) * *(..)); 
+//  before(): execution(@Anno(arrayval={1,2,3}) * *(..)); 
+}
diff --git a/tests/features160/annotationValueMatching/LongValueMatching.java b/tests/features160/annotationValueMatching/LongValueMatching.java
new file mode 100644 (file)
index 0000000..f3eec42
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.*;
+
+public class LongValueMatching {
+  public static void main(String[] args) { }
+
+  @Anno(jval=123123123) public void methodOne() {}
+  @Anno(jval=8) public void methodTwo() {}
+}
+
+@interface Anno {
+  long jval();
+}
+
+
+aspect X {     
+  before(): execution(@Anno(jval=123123123) * *(..))  {}
+}
diff --git a/tests/features160/annotationValueMatching/MultiTypePatterns.java b/tests/features160/annotationValueMatching/MultiTypePatterns.java
new file mode 100644 (file)
index 0000000..84cf468
--- /dev/null
@@ -0,0 +1,25 @@
+// testing what happens with multiple annotations together in a type pattern list @(A B C) type thing
+
+
+enum Rainbow { RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET }
+
+@interface Col1 { Rainbow value() default Rainbow.RED; }
+@interface Col2 { Rainbow value() default Rainbow.YELLOW; }
+
+aspect X {
+  before(): execution(@(Col1 && Col2) * *(..)) {
+    System.err.println("advising "+thisJoinPoint);
+  }
+}
+
+public class MultiTypePatterns {
+
+  public static void main(String[] args) {
+    MultiTypePatterns eOne = new MultiTypePatterns();
+  }
+
+  @Col1 public void m001() {}
+  @Col2 public void m002() {}
+  @Col1 @Col2 public void m003() {}
+
+}
index f541a8610d29e0e56bdc467ff4ad9ecafce5171d..0bbb6e241f455bffb2db51a38eb1e32dcb6b00d8 100644 (file)
@@ -1,7 +1,7 @@
 enum Color { RED, GREEN, AMBER }
 
 @interface TrafficLight {
-       Color value() default Color.RED;
+       Color value() default Color.RED; Color a() default Color.GREEN; Color c() default Color.GREEN; Color e() default Color.GREEN;
 }
 
 public class Parsing {
@@ -29,4 +29,4 @@ aspect X {
   pointcut p2(): execution(@TrafficLight(a=Color.GREEN) * *(..));
   pointcut p3(): execution(@TrafficLight(a=Color.RED,c=Color.RED) * *(..));
   pointcut p4(): execution(@TrafficLight(a=Color.RED,c=Color.RED,e=Color.RED) * *(..));
-}
\ No newline at end of file
+}
diff --git a/tests/features160/annotationValueMatching/ShortValueMatching.java b/tests/features160/annotationValueMatching/ShortValueMatching.java
new file mode 100644 (file)
index 0000000..b24825a
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.*;
+
+public class ShortValueMatching {
+  public static void main(String[] args) { }
+
+  @Anno(sval=32700) public void methodOne() {}
+  @Anno(sval=27) public void methodTwo() {}
+}
+
+@interface Anno {
+  short sval();
+}
+
+
+aspect X {     
+  before(): execution(@Anno(sval=32700) * *(..))  {}
+}
diff --git a/tests/features160/annotationValueMatching/StringValueMatching.java b/tests/features160/annotationValueMatching/StringValueMatching.java
new file mode 100644 (file)
index 0000000..17de47a
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.*;
+
+public class StringValueMatching {
+  public static void main(String[] args) { }
+
+  @Anno(stringval="foobar") public void methodOne() {}
+  @Anno(stringval="goo") public void methodTwo() {}
+}
+
+@interface Anno {
+  String stringval();
+}
+
+
+aspect X {     
+  before(): execution(@Anno(stringval="foobar") * *(..))  {}
+}
diff --git a/tests/features160/annotationValueMatching/Test.java b/tests/features160/annotationValueMatching/Test.java
new file mode 100644 (file)
index 0000000..5cf17a7
--- /dev/null
@@ -0,0 +1,16 @@
+//@Retention(RetentionPolicy.RUNTIME)
+@interface ComplexAnnotation {
+  int ival();
+  byte bval();
+  char cval();
+  long jval();
+  double dval();
+  boolean zval();
+  short sval();
+  float fval();
+//  Color enumval();
+  String strval();
+  Class classval();
+  int[] arrayval();
+}
+