summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoracolyer <acolyer>2004-07-28 15:13:09 +0000
committeracolyer <acolyer>2004-07-28 15:13:09 +0000
commit10c6de6fbc8a0b9eb07801f4ac19bea8304a9cb3 (patch)
treeb44260eba290558bdc43afb7e968b60990e96bd0 /tests
parent573741c8081c6b6b45921cafaae39f37eede2302 (diff)
downloadaspectj-10c6de6fbc8a0b9eb07801f4ac19bea8304a9cb3.tar.gz
aspectj-10c6de6fbc8a0b9eb07801f4ac19bea8304a9cb3.zip
fix for Bugzilla Bug 48990
Special case if(false) to not require a dynamic test
Diffstat (limited to 'tests')
-rw-r--r--tests/ajcTests.xml12
-rw-r--r--tests/new/IfFalse.aj37
-rw-r--r--tests/new/IfTrue.aj37
3 files changed, 86 insertions, 0 deletions
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml
index f76405da3..96bdd14c5 100644
--- a/tests/ajcTests.xml
+++ b/tests/ajcTests.xml
@@ -7794,6 +7794,18 @@
text="void Subclass.nonstaticMethod() cannot override void Superclass.nonstaticMethod(); overriding method is static"/>
</compile>
</ajc-test>
+
+ <ajc-test dir="new"
+ title="if(false) optimisation" pr="48990">
+ <compile files="IfFalse.aj"/>
+ <run class="IfFalse"/>
+ </ajc-test>
+
+ <ajc-test dir="new"
+ title="if(true) optimisation" pr="48990">
+ <compile files="IfTrue.aj"/>
+ <run class="IfTrue"/>
+ </ajc-test>
<ajc-test dir="bugs/abstractITDs"
pr="64331" title="java.lang.NullPointerException in WeaverMessageHandler class">
diff --git a/tests/new/IfFalse.aj b/tests/new/IfFalse.aj
new file mode 100644
index 000000000..6b1b8d402
--- /dev/null
+++ b/tests/new/IfFalse.aj
@@ -0,0 +1,37 @@
+import org.aspectj.testing.Tester;
+
+public aspect IfFalse {
+
+ private static boolean x = false;
+
+ pointcut p1() : if(false);
+
+ pointcut p2() : if( false );
+
+ pointcut p3() : if(x);
+
+ pointcut p4() : within(IfFalse) && if(false);
+
+
+ after() returning : p1() {
+ // should never get here
+ Tester.checkFailed("if(false) matched!");
+ }
+
+ after() returning : p2() {
+ // should never get here
+ Tester.checkFailed("if( false ) matched!");
+ }
+
+ after() returning : p3() {
+ // should never get here
+ Tester.checkFailed("if(x) matched!");
+ }
+
+ after() returning : p4() {
+ // should never get here
+ Tester.checkFailed("if(false) matched!");
+ }
+
+ public static void main(String[] args) {}
+} \ No newline at end of file
diff --git a/tests/new/IfTrue.aj b/tests/new/IfTrue.aj
new file mode 100644
index 000000000..afbbdb48f
--- /dev/null
+++ b/tests/new/IfTrue.aj
@@ -0,0 +1,37 @@
+import org.aspectj.testing.Tester;
+
+public aspect IfTrue {
+
+ private static boolean x = true;
+
+ pointcut p1() : !if(true);
+
+ pointcut p2() : !if( true );
+
+ pointcut p3() : !if(x) && execution(* *(..));
+
+ pointcut p4() : within(IfTrue) && !if(true);
+
+
+ after() returning : p1() {
+ // should never get here
+ Tester.checkFailed("!if(true) matched!");
+ }
+
+ after() returning : p2() {
+ // should never get here
+ Tester.checkFailed("!if( true ) matched!");
+ }
+
+ after() returning : p3() {
+ // should never get here
+ Tester.checkFailed("!if(x) matched!");
+ }
+
+ after() returning : p4() {
+ // should never get here
+ Tester.checkFailed("!if(true) matched!");
+ }
+
+ public static void main(String[] args) {}
+} \ No newline at end of file