You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Ajc1921TestsJava.java 4.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*******************************************************************************
  2. * Copyright (c) 2022 Contributors
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v 2.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  7. *******************************************************************************/
  8. package org.aspectj.systemtest.ajc1921;
  9. import junit.framework.Test;
  10. import org.aspectj.apache.bcel.Constants;
  11. import org.aspectj.testing.XMLBasedAjcTestCase;
  12. import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater;
  13. /**
  14. * @author Alexander Kriegisch
  15. */
  16. public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater {
  17. public void testSwitchPatternMatchingPreview4Java() {
  18. runTest("switch pattern matching preview 4 java");
  19. checkVersion("SwitchPatternPreview4OK", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  20. }
  21. public void testSwitchPatternMatchingPreview4Error() {
  22. runTest("switch pattern matching preview 4 error");
  23. }
  24. public void testSwitchPatternMatchingPreview3Aspect() {
  25. runTest("switch pattern matching preview 3 aspect");
  26. checkVersion("SwitchPatternPreview3Aspect", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  27. checkVersion("Application", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  28. checkVersion("Shape", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  29. checkVersion("S", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  30. }
  31. public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
  32. runTest("switch pattern matching error");
  33. }
  34. public void testSwitchPatternMatchingPreview3Error1() {
  35. runTest("switch pattern matching preview 3 error 1");
  36. }
  37. public void testSwitchPatternMatchingPreview3Error2() {
  38. runTest("switch pattern matching preview 3 error 2");
  39. }
  40. public void testRecordPatternsPreview1OK() {
  41. // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450
  42. runTest("record patterns");
  43. }
  44. public void testRecordPatternsPreview1Error() {
  45. // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27)
  46. runTest("record patterns error");
  47. checkVersion("RecordPatternsPreview1Error", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  48. checkVersion("Box", Constants.ClassFileVersion.of(21).MAJOR, Constants.ClassFileVersion.of(21).MINOR);
  49. }
  50. public void testRecordPatternsPreview1ExhaustivenessOK1() {
  51. // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected' twice,
  52. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. Fixed in Java 21.
  53. runTest("record patterns exhaustiveness 1");
  54. }
  55. public void testRecordPatternsPreview1Aspect() {
  56. runTest("record patterns aspect");
  57. }
  58. public void testRecordPatternsPreview1ExhaustivenessAspect() {
  59. // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected' twice,
  60. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. Fixed in Java 21.
  61. runTest("record patterns exhaustiveness aspect");
  62. }
  63. public void testRecordPatternsPreview1ExhaustivenessError() {
  64. // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
  65. runTest("record patterns exhaustiveness error");
  66. }
  67. public void testRecordPatternsPreview1ExhaustivenessOK2() {
  68. // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected',
  69. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398. Fixed in Java 21.
  70. runTest("record patterns exhaustiveness 2");
  71. }
  72. public static Test suite() {
  73. return XMLBasedAjcTestCase.loadSuite(Ajc1921TestsJava.class);
  74. }
  75. @Override
  76. protected java.net.URL getSpecFile() {
  77. return getClassResource("ajc1921.xml");
  78. }
  79. }