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.

Java21PreviewFeaturesTests.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*******************************************************************************
  2. * Copyright (c) 2023 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.XMLBasedAjcTestCaseForJava21Only;
  13. /**
  14. * @author Alexander Kriegisch
  15. */
  16. public class Java21PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava21Only {
  17. public void testSwitchPatternMatchingPreview4Java() {
  18. runTest("switch pattern matching preview 4 java");
  19. checkVersion("SwitchPatternPreview4OK", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION);
  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.MAJOR_21, Constants.PREVIEW_MINOR_VERSION);
  27. checkVersion("Application", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION);
  28. checkVersion("Shape", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION);
  29. checkVersion("S", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION);
  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.MAJOR_21, Constants.PREVIEW_MINOR_VERSION);
  48. checkVersion("Box", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION);
  49. }
  50. public void testRecordPatternsPreview1ExhaustivenessOK1() {
  51. // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice,
  52. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
  53. // TODO: Remove redundant default clauses when fixed upstream
  54. System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed");
  55. runTest("record patterns exhaustiveness 1");
  56. }
  57. public void testRecordPatternsPreview1Aspect() {
  58. runTest("record patterns aspect");
  59. }
  60. public void testRecordPatternsPreview1ExhaustivenessAspect() {
  61. // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice,
  62. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
  63. // TODO: Remove redundant default clauses when fixed upstream
  64. System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed");
  65. runTest("record patterns exhaustiveness aspect");
  66. }
  67. public void testRecordPatternsPreview1ExhaustivenessError() {
  68. // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
  69. runTest("record patterns exhaustiveness error");
  70. }
  71. public void testRecordPatternsPreview1ExhaustivenessOK2() {
  72. // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected',
  73. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398
  74. // TODO: activate when fixed
  75. System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed");
  76. //runTest("record patterns exhaustiveness 2");
  77. }
  78. public static Test suite() {
  79. return XMLBasedAjcTestCase.loadSuite(Java21PreviewFeaturesTests.class);
  80. }
  81. @Override
  82. protected java.net.URL getSpecFile() {
  83. return getClassResource("ajc1921.xml");
  84. }
  85. }