aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java
blob: 466135dc258720b1a615e2cb0291329bc6e729fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*******************************************************************************
 * 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.ajc1921;

import junit.framework.Test;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater;

/**
 * @author Alexander Kriegisch
 */
public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater {

  public void testSwitchPatternMatchingPreview4Java() {
    runTest("switch pattern matching preview 4 java");
    checkVersion("SwitchPatternPreview4OK", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  }

  public void testSwitchPatternMatchingPreview4Error() {
    runTest("switch pattern matching preview 4 error");
  }

  public void testSwitchPatternMatchingPreview3Aspect() {
    runTest("switch pattern matching preview 3 aspect");
    checkVersion("SwitchPatternPreview3Aspect", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
    checkVersion("Application", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
    checkVersion("Shape", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
    checkVersion("S", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  }

  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 void testRecordPatternsPreview1OK() {
    // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450
    runTest("record patterns");
  }

  public void testRecordPatternsPreview1Error() {
    // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27)
    runTest("record patterns error");
    checkVersion("RecordPatternsPreview1Error", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
    checkVersion("Box", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  }

  public void testRecordPatternsPreview1ExhaustivenessOK1() {
    // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected' twice,
    // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. Fixed in Java 21.
    runTest("record patterns exhaustiveness 1");
  }

  public void testRecordPatternsPreview1Aspect() {
    runTest("record patterns aspect");
  }

  public void testRecordPatternsPreview1ExhaustivenessAspect() {
    // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected' twice,
    // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. Fixed in Java 21.
    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() {
    // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected',
    // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398. Fixed in Java 21.
    runTest("record patterns exhaustiveness 2");
  }

  public static Test suite() {
    return XMLBasedAjcTestCase.loadSuite(Ajc1921TestsJava.class);
  }

  @Override
  protected java.net.URL getSpecFile() {
    return getClassResource("ajc1921.xml");
  }

}