diff options
Diffstat (limited to 'tests/src')
8 files changed, 404 insertions, 0 deletions
diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java index d14bc54cb..21ad9de90 100644 --- a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java @@ -9,6 +9,7 @@ package org.aspectj.systemtest; import org.aspectj.systemtest.ajc190.AllTestsAspectJ190; import org.aspectj.systemtest.ajc191.AllTestsAspectJ191; +import org.aspectj.systemtest.ajc1919.AllTestsAspectJ1919; import org.aspectj.systemtest.ajc192.AllTestsAspectJ192; import org.aspectj.systemtest.ajc193.AllTestsAspectJ193; import org.aspectj.systemtest.ajc195.AllTestsAspectJ195; @@ -38,6 +39,7 @@ public class AllTests19 { suite.addTest(AllTestsAspectJ197.suite()); suite.addTest(AllTestsAspectJ198.suite()); suite.addTest(AllTestsAspectJ199.suite()); + suite.addTest(AllTestsAspectJ1919.suite()); suite.addTest(AllTests18.suite()); // $JUnit-END$ return suite; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/Ajc1919TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Ajc1919TestsJava.java new file mode 100644 index 000000000..5f471490d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Ajc1919TestsJava.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava19OrLater; + +/** + * @author Alexander Kriegisch + */ +public class Ajc1919TestsJava extends XMLBasedAjcTestCaseForJava19OrLater { + + public void testDummyJava19() { + //runTest("dummy Java 19"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1919TestsJava.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1919.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/AllTestsAspectJ1919.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/AllTestsAspectJ1919.java new file mode 100644 index 000000000..da1a81f97 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/AllTestsAspectJ1919.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.aspectj.util.LangUtil; + +/** + * @author Alexander Kriegisch + */ +public class AllTestsAspectJ1919 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.19 tests"); + suite.addTest(Bugs1919Tests.suite()); + if (LangUtil.is19VMOrGreater()) { + suite.addTest(SanityTestsJava19.suite()); + suite.addTest(Ajc1919TestsJava.suite()); + } + // Do not run tests using a previous compiler's preview features anymore. They would all fail. + // TODO: Comment out the following block when upgrading JDT Core to Java 20 + if (LangUtil.is19VMOrGreater() && !LangUtil.is20VMOrGreater()) { + suite.addTest(Java19PreviewFeaturesTests.suite()); + } + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/Bugs1919Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Bugs1919Tests.java new file mode 100644 index 000000000..38441267e --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Bugs1919Tests.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Alexander Kriegisch + */ +public class Bugs1919Tests extends XMLBasedAjcTestCase { + + public void testDummyBug() { + //runTest("dummy Java 19 bug"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Bugs1919Tests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1919.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java new file mode 100644 index 000000000..39f9019f4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava19Only; + +/** + * @author Alexander Kriegisch + */ +public class Java19PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava19Only { + + public void testSwitchPatternMatchingPreview3Java() { + runTest("switch pattern matching preview 3 java"); + checkVersion("SwitchPatternPreview3OK", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSwitchPatternMatchingPreview3Aspect() { + runTest("switch pattern matching preview 3 aspect"); + checkVersion("SwitchPatternPreview3Aspect", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Application", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Shape", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + checkVersion("S", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() { + runTest("switch pattern matching error"); + } + + public void testSwitchPatternMatchingPreview3Error1() { + runTest("switch pattern matching preview 3 error 1"); + } + + public void testSwitchPatternMatchingPreview3Error2() { + runTest("switch pattern matching preview 3 error 2"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Java19PreviewFeaturesTests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1919.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java new file mode 100644 index 000000000..fa2abafe5 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava19OrLater; + +/* + * Some very trivial tests that help verify things are OK. + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -19 option + * to check code generation and modification with that version specified. + * + * @author Alexander Kriegisch + */ +public class SanityTestsJava19 extends XMLBasedAjcTestCaseForJava19OrLater { + + public static final int bytecode_version_for_JDK_level = 63; + + // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) + public void testSimpleJava_A() { + runTest("simple - a"); + } + + public void testSimpleJava_B() { + runTest("simple - b"); + } + + public void testSimpleCode_C() { + runTest("simple - c"); + } + + public void testSimpleCode_D() { + runTest("simple - d"); + } + + public void testSimpleCode_E() { + runTest("simple - e"); + } + + public void testSimpleCode_F() { + runTest("simple - f"); + } + + public void testSimpleCode_G() { + runTest("simple - g"); + } + + public void testSimpleCode_H() { + runTest("simple - h", true); + } + + public void testSimpleCode_I() { + runTest("simple - i"); + } + + public void testVersionCorrect1() { + runTest("simple - j"); + checkVersion("A", bytecode_version_for_JDK_level, 0); + } + + public void testVersionCorrect2() { + runTest("simple - k"); + checkVersion("A", bytecode_version_for_JDK_level, 0); + } + + public void testVersionCorrect4() { + runTest("simple - m"); + // Must be 49.0 when -1.5 is specified + checkVersion("A", 49, 0); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTestsJava19.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("sanity-tests-19.xml"); + } + +} diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml new file mode 100644 index 000000000..9adc98bca --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml @@ -0,0 +1,95 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<!-- + Java 19: no new final language features, only preview/incubator ones: + - "JEP 427: Pattern Matching for switch (Third Preview)" (syntax change, introducing 'when') + - "JEP 405: Record Patterns (Preview)" + - "JEP 425: Virtual Threads (Preview)" (API only) + - "JEP 428: Structured Concurrency (Incubator)" (API only) +--> +<suite> + + <!-- Java ?? final, Java 17, 18, 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="switch pattern matching preview 3 java"> + <compile files="SwitchPatternPreview3OK.java" options="--enable-preview -19" /> + <run class="SwitchPatternPreview3OK" vmargs="--enable-preview"> + <message></message> + <stdout> + <line text="null" /> + <line text="int 123" /> + <line text="long 999" /> + <line text="double 12.340000" /> + <line text="String foo" /> + <line text="[123, foo, 999, 12.34]" /> + <line text="Non-circle" /> + <line text="Small circle" /> + <line text="Large circle" /> + <line text="Sealed sub-class A" /> + <line text="Sealed sub-class B" /> + <line text="Sealed sub-record C" /> + <line text="absolute value 1: -1" /> + <line text="other integer: 0" /> + <line text="positive integer: 42" /> + <line text="other integer: -99" /> + <line text="positive integer: 123" /> + <line text="value unavailable: null" /> + </stdout> + </run> + </ajc-test> + + <!-- Java ?? final, Java 17, 18, 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="switch pattern matching preview 3 aspect"> + <compile files="SwitchPatternPreview3Aspect.aj" options="--enable-preview -19" /> + <run class="Application" vmargs="--enable-preview"> + <stdout> + <line text="null" /> + <line text="int 123" /> + <line text="long 999" /> + <line text="double 12.340000" /> + <line text="String foo" /> + <line text="[123, foo, 999, 12.34]" /> + <line text="Non-circle" /> + <line text="Small circle" /> + <line text="Large circle" /> + <line text="Sealed sub-class A" /> + <line text="Sealed sub-class B" /> + <line text="Sealed sub-record C" /> + <line text="absolute value 1: -1" /> + <line text="other integer: 0" /> + <line text="positive integer: 42" /> + <line text="other integer: -99" /> + <line text="positive integer: 123" /> + <line text="value unavailable: null" /> + </stdout> + </run> + </ajc-test> + + <!-- Java ?? final, Java 17, 18, 19 preview --> + <ajc-test dir="features198/java17" vm="19" title="switch pattern matching error"> + <compile files="SwitchPatternError.java" options="--enable-preview -19"> + <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it --> + <message kind="error" file="SwitchPatternError.java" text="This case label is dominated by one of the preceding case label"/> + </compile> + </ajc-test> + + <!-- Java ?? final, Java 17, 18, 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="switch pattern matching preview 3 error 1"> + <compile files="SwitchPatternPreview3Error1.java" options="--enable-preview -19"> + <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it --> + <message kind="error" file="SwitchPatternPreview3Error1.java" text="This case label is dominated by one of the preceding case label"/> + </compile> + </ajc-test> + + <!-- Java ?? final, Java 17, 18, 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="switch pattern matching preview 3 error 2"> + <compile files="SwitchPatternPreview3Error2.java" options="--enable-preview -19"> + <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it --> + <message kind="error" file="SwitchPatternPreview3Error2.java" text="This case label is dominated by one of the preceding case label"/> + </compile> + </ajc-test> + + <!-- Currently, there are no bugfixes with tests in this AspectJ vesion --> + <ajc-test dir="bugs1919/github_99999" vm="19" title="dummy Java 19"> + </ajc-test> + +</suite> diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1919/sanity-tests-19.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/sanity-tests-19.xml new file mode 100644 index 000000000..25df39e53 --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/sanity-tests-19.xml @@ -0,0 +1,70 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + <!-- empty class --> + <ajc-test dir="bugs160/simplejava" title="simple - a"> + <compile files="SimpleA.java" options="-19"/> + </ajc-test> + + <!-- class with one method --> + <ajc-test dir="bugs160/simplejava" title="simple - b"> + <compile files="SimpleB.java" options="-19"/> + <run class="SimpleB"/> + </ajc-test> + + <!-- empty aspect --> + <ajc-test dir="bugs160/simplejava" title="simple - c"> + <compile files="SimpleC.java" options="-19"/> + </ajc-test> + + <!-- simple before --> + <ajc-test dir="bugs160/simplejava" title="simple - d"> + <compile files="SimpleD.java" options="-19"/> + </ajc-test> + + <!-- simple itd field --> + <ajc-test dir="bugs160/simplejava" title="simple - e"> + <compile files="SimpleE.java" options="-19"/> + </ajc-test> + + <!-- aspect with main calling a static method --> + <ajc-test dir="bugs160/simplejava" title="simple - f"> + <compile files="SimpleF.java" options="-19"/> + </ajc-test> + + <!-- pertarget --> + <ajc-test dir="bugs160/simplejava" title="simple - g"> + <compile files="SimpleG.java" options="-19"/> + </ajc-test> + + <!-- generic ctor itds --> + <ajc-test dir="bugs160/simplejava" title="simple - h"> + <compile files="SimpleH.java" options="-19"/> + </ajc-test> + + <!-- overriding generic itd methods --> + <ajc-test dir="bugs160/simplejava" title="simple - i"> + <compile files="SimpleI.java" options="-19"/> + </ajc-test> + + <!-- check class file version is 63.0 (Java 19) --> + <ajc-test dir="bugs160/simplejava" title="simple - j"> + <compile files="SimpleJ.java" options="-19"/> + </ajc-test> + + <!-- check class file version is 63.0 (Java 19) --> + <ajc-test dir="bugs160/simplejava" title="simple - k"> + <compile files="SimpleJ.java" options="-source 19"/> + </ajc-test> + + <!-- check class file version is 49.0 --> + <ajc-test dir="bugs160/simplejava" title="simple - m"> + <compile files="SimpleJ.java" options="-1.5"/> + </ajc-test> + + <ajc-test dir="bugs160/simplejava" title="simple - n"> + <compile files="SimpleN.java" options="-19"/> + </ajc-test> + +</suite> |