aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-04-03 10:23:44 -0700
committerAndy Clement <aclement@pivotal.io>2019-04-03 10:23:44 -0700
commit0e2c95a36900fe913f5d768e7f4632034ddf005b (patch)
treef7f1bb92dfbae87de0a8998491e863490984aa0a /tests
parentdbb2c59fcfa6837f1fde9e0c1f0d04751c9268ee (diff)
downloadaspectj-0e2c95a36900fe913f5d768e7f4632034ddf005b.tar.gz
aspectj-0e2c95a36900fe913f5d768e7f4632034ddf005b.zip
Updated with Java12 support
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs190/modules/ggg/foo2.jarbin0 -> 318 bytes
-rw-r--r--tests/features193/Switch1.java22
-rw-r--r--tests/features193/Switch2.java28
-rw-r--r--tests/features193/Switch3.java32
-rw-r--r--tests/java5/ataspectj/ajc-ant.xml8
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java16
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java10
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java11
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java11
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java9
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java5
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java46
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190.xml6
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml39
14 files changed, 180 insertions, 63 deletions
diff --git a/tests/bugs190/modules/ggg/foo2.jar b/tests/bugs190/modules/ggg/foo2.jar
new file mode 100644
index 000000000..54b354ef6
--- /dev/null
+++ b/tests/bugs190/modules/ggg/foo2.jar
Binary files differ
diff --git a/tests/features193/Switch1.java b/tests/features193/Switch1.java
new file mode 100644
index 000000000..1daeeff6f
--- /dev/null
+++ b/tests/features193/Switch1.java
@@ -0,0 +1,22 @@
+public class Switch1 {
+ public static void main(String[] argv) {
+ System.out.println(one(Color.R));
+ System.out.println(one(Color.G));
+ System.out.println(one(Color.B));
+ System.out.println(one(Color.Y));
+ }
+
+ public static int one(Color color) {
+ int result = switch(color) {
+ case R -> 0;
+ case G -> 1;
+ case B -> 2;
+ default -> 3;
+ };
+ return result;
+ }
+}
+
+enum Color {
+ R, G, B, Y;
+} \ No newline at end of file
diff --git a/tests/features193/Switch2.java b/tests/features193/Switch2.java
new file mode 100644
index 000000000..c4acc82d9
--- /dev/null
+++ b/tests/features193/Switch2.java
@@ -0,0 +1,28 @@
+public class Switch2 {
+ public static void main(String[] argv) {
+ System.out.println(one(Color.R));
+ System.out.println(one(Color.G));
+ System.out.println(one(Color.B));
+ System.out.println(one(Color.Y));
+ }
+
+ public static int one(Color color) {
+ int result = switch(color) {
+ case R -> 0;
+ case G -> 1;
+ case B -> 2;
+ default -> 3;
+ };
+ return result;
+ }
+}
+
+enum Color {
+ R, G, B, Y;
+}
+
+aspect X {
+ int around(): call(* one(..)) {
+ return proceed()*2;
+ }
+} \ No newline at end of file
diff --git a/tests/features193/Switch3.java b/tests/features193/Switch3.java
new file mode 100644
index 000000000..a99622d75
--- /dev/null
+++ b/tests/features193/Switch3.java
@@ -0,0 +1,32 @@
+public class Switch3 {
+ public static void main(String[] argv) {
+ System.out.println(one(Color.R));
+ System.out.println(one(Color.G));
+ System.out.println(one(Color.B));
+ System.out.println(one(Color.Y));
+ }
+
+ public static int one(Color color) {
+ int result = switch(color) {
+ case R -> foo(0);
+ case G -> foo(1);
+ case B -> foo(2);
+ default -> foo(3);
+ };
+ return result;
+ }
+
+ public static final int foo(int i) {
+ return i+1;
+ }
+}
+
+enum Color {
+ R, G, B, Y;
+}
+
+aspect X {
+ int around(): call(* foo(..)) {
+ return proceed()*3;
+ }
+} \ No newline at end of file
diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml
index a9b215bf3..c3ac6bac8 100644
--- a/tests/java5/ataspectj/ajc-ant.xml
+++ b/tests/java5/ataspectj/ajc-ant.xml
@@ -10,7 +10,7 @@
<target name="compile:javac">
<!-- compile only javac compilable stuff, exclude the one that needs other dependencies -->
- <javac source="1.6" target="1.6" destdir="${aj.sandbox}" classpathref="aj.path"
+ <javac source="1.7" target="1.7" destdir="${aj.sandbox}" classpathref="aj.path"
srcdir="${basedir}"
includes="ataspectj/*"
excludes="ataspectj/UnweavableTest.java"
@@ -75,7 +75,7 @@
<target name="ltw.Aspect2MainTest">
<!-- javac Aspect2 -->
- <javac source="1.6" target="1.6" destdir="${aj.sandbox}" classpathref="aj.path"
+ <javac source="1.7" target="1.7" destdir="${aj.sandbox}" classpathref="aj.path"
srcdir="${basedir}"
includes="ataspectj/ltwreweavable/Aspect2.java"
debug="true">
@@ -125,7 +125,7 @@
</target>
<target name="ltw.Unweavable">
- <javac source="1.6" target="1.6" destdir="${aj.sandbox}"
+ <javac source="1.7" target="1.7" destdir="${aj.sandbox}"
srcdir="${basedir}"
includes="ataspectj/UnweavableTest.java, ataspectj/TestHelper.java"
debug="true">
@@ -171,7 +171,7 @@
<target name="ltw.Decp2">
<!-- javac compile the 2nd aspect -->
- <javac source="1.6" target="1.6" destdir="${aj.sandbox}"
+ <javac source="1.7" target="1.7" destdir="${aj.sandbox}"
srcdir="${basedir}"
includes="ataspectj/DeclareParentsImplementsReweavableTestAspect.java"
debug="true">
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java
index 157fdc6ce..9bdb68665 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java
@@ -10,16 +10,14 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc160;
-import java.io.File;
-
-import junit.framework.Test;
-
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.Code;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.testing.XMLBasedAjcTestCase;
+import junit.framework.Test;
+
/*
* Some very trivial tests that help verify things are OK.
* Followed by some Java6 specific checks to ensure the class files are well formed.
@@ -136,16 +134,6 @@ public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase {
return false;
}
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
-
// Check the stackmap stuff is removed when a method gets woven (for now...)
// public void testStackMapAttributesDeletedInWovenCode() {
// fail("Not implemented");
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java
index 8cdf93597..ac5eb14e4 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java
@@ -149,16 +149,6 @@ public class ModuleTests extends XMLBasedAjcTestCaseForJava9OrLater {
return false;
}
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
-
// Check the stackmap stuff is removed when a method gets woven (for now...)
// public void testStackMapAttributesDeletedInWovenCode() {
// fail("Not implemented");
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java
index edb45c513..46aaddff1 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc190;
-import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;
import junit.framework.Test;
@@ -124,16 +123,6 @@ public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase {
// return false;
// }
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
-
// Check the stackmap stuff is removed when a method gets woven (for now...)
// public void testStackMapAttributesDeletedInWovenCode() {
// fail("Not implemented");
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java b/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java
index 87d8b932a..c6d4bc86e 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java
@@ -7,7 +7,6 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc191;
-import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;
import junit.framework.Test;
@@ -73,16 +72,6 @@ public class SanityTestsJava10 extends org.aspectj.testing.XMLBasedAjcTestCase {
checkVersion("A", 49, 0);
}
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
-
// ///////////////////////////////////////
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(SanityTestsJava10.class);
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java b/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java
index 33a5affe6..0506f90a1 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java
@@ -74,15 +74,6 @@ public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater {
checkVersion("A", 49, 0);
}
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
// ///////////////////////////////////////
public static Test suite() {
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java b/tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java
index 62cfcccb2..ddd88372d 100644
--- a/tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Contributors
+ * Copyright (c) 2018-2019 Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,9 +17,8 @@ public class AllTestsAspectJ193 {
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.3 tests");
- // $JUnit-BEGIN$
suite.addTest(Ajc193Tests.suite());
- // $JUnit-END$
+ suite.addTest(Java12Tests.suite());
return suite;
}
}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java
new file mode 100644
index 000000000..72388ba68
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc193;
+
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava12OrLater;
+
+import junit.framework.Test;
+
+/**
+ * @author Andy Clement
+ */
+public class Java12Tests extends XMLBasedAjcTestCaseForJava12OrLater {
+
+ public void testSwitch1() {
+ runTest("switch 1");
+ checkVersion("Switch1", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ }
+
+ public void testSwitch2() {
+ runTest("switch 2");
+ checkVersion("Switch2", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ }
+
+ public void testSwitch3() {
+ runTest("switch 3");
+ checkVersion("Switch3", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ }
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Java12Tests.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("ajc193.xml");
+ }
+
+}
diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190.xml
index 2936888cb..5a3dec730 100644
--- a/tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190.xml
+++ b/tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190.xml
@@ -111,8 +111,12 @@
<!-- this fails because if you start working with modules you commit to the modules story and classpath
becomes irrelevant -->
<compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="module.jar" classpath="foo.jar">
- <message kind="error" text="The import ddd cannot be resolved"/>
+ <message kind="error" text="The type ddd.D is not accessible"/>
<message kind="error" text="D cannot be resolved"/>
+ <!--
+ <message kind="error" text="The import ddd cannot be resolved"/>
+ <message kind="error" text="package ddd is not visible"/>
+ -->
</compile>
</ajc-test>
diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml
index 2a4be40f8..c13159c30 100644
--- a/tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml
+++ b/tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml
@@ -51,6 +51,45 @@ Method call
</run>
</ajc-test>
+ <ajc-test dir="features193" vm="12" title="switch 1">
+ <compile files="Switch1.java" options="-12 --enable-preview">
+ </compile>
+ <run class="Switch1" vmargs="--enable-preview">
+ <stdout>
+ <line text="0"/>
+ <line text="1"/>
+ <line text="2"/>
+ <line text="3"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features193" vm="12" title="switch 2">
+ <compile files="Switch2.java" options="--enable-preview -source 12">
+ </compile>
+ <run class="Switch2" vmargs="--enable-preview">
+ <stdout>
+ <line text="0"/>
+ <line text="2"/>
+ <line text="4"/>
+ <line text="6"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features193" vm="12" title="switch 3">
+ <compile files="Switch3.java" options="--enable-preview -source 12">
+ </compile>
+ <run class="Switch3" vmargs="--enable-preview">
+ <stdout>
+ <line text="3"/>
+ <line text="6"/>
+ <line text="9"/>
+ <line text="12"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
<ajc-test dir="bugs193/543657" vm="1.8" title="overweaving decm - reweaving">
<compile files="MoodIndicator.java,Code1.java" options="-showWeaveInfo -1.8" outjar="one.jar">
<message kind="weave" text="Mixing interface 'MoodIndicator$Moody' (MoodIndicator.java) into type 'Code1' (Code1.java)"/>