aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features1921
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2024-02-13 17:05:04 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2024-02-13 17:05:04 +0700
commitc028a472697a6934a538f2d61cb9974a66421fb1 (patch)
treebd70e5b647c2e1ad6fee7d6b983d82416b36d4be /tests/features1921
parent8478d33a68781b3dd950224eb3ebbec6727bfc8e (diff)
downloadaspectj-c028a472697a6934a538f2d61cb9974a66421fb1.tar.gz
aspectj-c028a472697a6934a538f2d61cb9974a66421fb1.zip
Add tests for underscores in pointcuts on Java 21+
See also: https://github.com/eclipse-aspectj/eclipse.jdt.core/commit/5d2f2aecd2 Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/features1921')
-rw-r--r--tests/features1921/java21/UnderscoreInPointcutAspect.aj53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/features1921/java21/UnderscoreInPointcutAspect.aj b/tests/features1921/java21/UnderscoreInPointcutAspect.aj
new file mode 100644
index 000000000..41ed65d15
--- /dev/null
+++ b/tests/features1921/java21/UnderscoreInPointcutAspect.aj
@@ -0,0 +1,53 @@
+public aspect UnderscoreInPointcutAspect {
+ public static void main(String[] args) {
+ UnderTest u = new UnderTest();
+ System.out.println(u._add(12, 4));
+ System.out.println(u._subtract(12, 4));
+ System.out.println(u.multiply_(12, 4));
+ System.out.println(u.divide_(12, 4));
+ System.out.println(u.power_of(3, 3));
+ System.out.println(u.squareRoot(49));
+ }
+
+ before(int a, int b) : execution(* _*(..)) && args(a, b) {
+ System.out.println("[starts with underscore] " + thisJoinPoint + " -> " + a + ", " + b);
+ }
+
+ before(int a, int b) : execution(* *_(..)) && args(a, b) {
+ System.out.println("[ends with underscore] " + thisJoinPoint + " -> " + a + ", " + b);
+ }
+
+ before(int a, int b) : execution(* *_*(..)) && args(a, b) {
+ System.out.println("[contains underscore] " + thisJoinPoint + " -> " + a + ", " + b);
+ }
+
+ before(int a) : execution(* *(..)) && !execution(* *_*(..)) && args(a) {
+ System.out.println("[no underscore] " + thisJoinPoint + " -> " + a);
+ }
+}
+
+class UnderTest {
+ int _add(int a, int b) {
+ return a + b;
+ }
+
+ int _subtract(int a, int b) {
+ return a - b;
+ }
+
+ int multiply_(int a, int b) {
+ return a * b;
+ }
+
+ int divide_(int a, int b) {
+ return a / b;
+ }
+
+ int power_of(int base, int exponent) {
+ return (int) Math.pow(base, exponent);
+ }
+
+ int squareRoot(int a) {
+ return (int) Math.sqrt(a);
+ }
+}