diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-12-21 12:57:44 +0100 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-12-21 12:57:44 +0100 |
commit | 5239ae0480d4f623aa9c9491b6bf75e3e568cc89 (patch) | |
tree | f6bd5d5e80275c25770282eb5b8de4f22db8c6cd /tests/src | |
parent | 9be61fe259dfd3340050f0c4d80ee9e9555583e1 (diff) | |
download | aspectj-5239ae0480d4f623aa9c9491b6bf75e3e568cc89.tar.gz aspectj-5239ae0480d4f623aa9c9491b6bf75e3e568cc89.zip |
Add tests for Java 19 record patterns
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java | 43 | ||||
-rw-r--r-- | tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml | 78 |
2 files changed, 119 insertions, 2 deletions
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java index 39f9019f4..b4dc12f39 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java @@ -42,6 +42,49 @@ public class Java19PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava19Only runTest("switch pattern matching preview 3 error 2"); } + public void testRecordPatternsPreview1OK() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 + runTest("record patterns"); + } + + public void testRecordPatternsPreview1Error() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 + runTest("record patterns error"); + } + + public void testRecordPatternsPreview1ExhaustivenessOK1() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + // TODO: activate when fixed + System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + //runTest("record patterns exhaustiveness 1"); + } + + public void testRecordPatternsPreview1Aspect() { + runTest("record patterns aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessAspect() { + // TODO: Remove redundant default clauses in RecordPatternsPreview1Aspect when + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed. Furthermore, activate '<run />' + // action for XML test case in order to not just compile but also run the code. + System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + runTest("record patterns exhaustiveness aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessError() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + runTest("record patterns exhaustiveness error"); + } + + public void testRecordPatternsPreview1ExhaustivenessOK2() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected', + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 + // TODO: activate when fixed + System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed"); + //runTest("record patterns exhaustiveness 2"); + } + public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Java19PreviewFeaturesTests.class); } diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml index 9adc98bca..3741b338c 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml @@ -88,8 +88,82 @@ </compile> </ajc-test> + <!-- Java ?? final, Java 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="record patterns"> + <compile files="RecordPatternsPreview1OK.java" options="--enable-preview -19"/> + </ajc-test> + + <!-- Java ?? final, Java 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="record patterns error"> + <compile files="RecordPatternsPreview1Error.java" options="--enable-preview -19"> + <message kind="error" file="RecordPatternsPreview1Error.java" text="Raw types are not allowed in record patterns"/> + <message kind="error" file="RecordPatternsPreview1Error.java" text="Raw types are not allowed in record patterns"/> + </compile> + </ajc-test> + + <!-- Java ?? final, Java 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="record patterns exhaustiveness 1"> + <compile files="RecordPatternsPreview1ExhaustivenessOK1.java" options="--enable-preview -19"/> + <run class="RecordPatternsPreview1ExhaustivenessOK1" vmargs="--enable-preview"> + <stdout> + <line text="y"/> + <line text="a"/> + </stdout> + </run> + </ajc-test> + + <!-- Java ?? final, Java 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="record patterns exhaustiveness aspect"> + <compile files="RecordPatternsPreview1ExhaustivenessAspect.aj" options="--enable-preview -19"/> + <!-- + TODO: Remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + has been fixed. But even with the default clause, it generates wrong byte code and throws runtime error: + NoSuchMethodError: 'I Pair.x()' + --> + <!--run class="RecordPatternsPreview1ExhaustivenessAspect" vmargs="-XXX-enable-preview"> + <stdout> + <line text="y"/> + <line text="a"/> + <line text="Pair[x=C@000, y=D@000]"/> + </stdout> + </run--> + </ajc-test> + + <!-- Java ?? final, Java 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="record patterns aspect"> + <compile files="RecordPatternsPreview1Aspect.aj" options="--enable-preview -19"/> + <run class="RecordPatternsPreview1Aspect" vmargs="--enable-preview"> + <stdout> + <line text="9"/> + <line text="14"/> + <line text="Doing something with Point[x=2, y=7]"/> + <line text="Upper-left color: RED"/> + <line text="Upper-left color: RED"/> + <line text="Upper-left x coordinate: 1"/> + <line text="Doing something with Rectangle[upperLeft=ColoredPoint[p=Point[x=1, y=6], c=RED], lowerRight=ColoredPoint[p=Point[x=4, y=6], c=BLUE]]"/> + </stdout> + </run> + </ajc-test> + + <!-- Java ?? final, Java 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="record patterns exhaustiveness error"> + <compile files="RecordPatternsPreview1ExhaustivenessError.java" options="--enable-preview -19"> + <message kind="error" file="RecordPatternsPreview1ExhaustivenessError.java" text="An enhanced switch statement should be exhaustive; a default label expected"/> + </compile> + </ajc-test> + + <!-- Java ?? final, Java 19 preview --> + <ajc-test dir="features1919/java19" vm="19" title="record patterns exhaustiveness 2"> + <compile files="RecordPatternsPreview1ExhaustivenessOK2.java" options="--enable-preview -19"/> + <run class="RecordPatternsPreview1ExhaustivenessOK2" vmargs="--enable-preview"> + <stdout> + <line text="Bob 12"/> + </stdout> + </run> + </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> + <ajc-test dir="bugs1919/github_99999" vm="19" title="dummy Java 19"> + </ajc-test> </suite> |