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.

Java20PreviewFeaturesTests.java 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.ajc1920;
  9. import junit.framework.Test;
  10. import org.aspectj.apache.bcel.Constants;
  11. import org.aspectj.testing.JavaVersionSpecificXMLBasedAjcTestCase;
  12. import org.aspectj.testing.XMLBasedAjcTestCase;
  13. /**
  14. * @author Alexander Kriegisch
  15. */
  16. public class Java20PreviewFeaturesTests extends JavaVersionSpecificXMLBasedAjcTestCase {
  17. private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(20);
  18. public Java20PreviewFeaturesTests() {
  19. super(20, 20);
  20. }
  21. public void testSwitchPatternMatchingPreview4Java() {
  22. runTest("switch pattern matching preview 4 java");
  23. checkVersion("SwitchPatternPreview4OK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  24. }
  25. public void testSwitchPatternMatchingPreview4Error() {
  26. runTest("switch pattern matching preview 4 error");
  27. }
  28. public void testSwitchPatternMatchingPreview3Aspect() {
  29. runTest("switch pattern matching preview 3 aspect");
  30. checkVersion("SwitchPatternPreview3Aspect", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  31. checkVersion("Application", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  32. checkVersion("Shape", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  33. checkVersion("S", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  34. }
  35. public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
  36. runTest("switch pattern matching error");
  37. }
  38. public void testSwitchPatternMatchingPreview3Error1() {
  39. runTest("switch pattern matching preview 3 error 1");
  40. }
  41. public void testSwitchPatternMatchingPreview3Error2() {
  42. runTest("switch pattern matching preview 3 error 2");
  43. }
  44. public void testRecordPatternsPreview1OK() {
  45. // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450
  46. runTest("record patterns");
  47. }
  48. public void testRecordPatternsPreview1Error() {
  49. // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27)
  50. runTest("record patterns error");
  51. checkVersion("RecordPatternsPreview1Error", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  52. checkVersion("Box", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  53. }
  54. public void testRecordPatternsPreview1ExhaustivenessOK1() {
  55. // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice,
  56. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
  57. // TODO: Remove redundant default clauses when fixed upstream
  58. System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed");
  59. runTest("record patterns exhaustiveness 1");
  60. }
  61. public void testRecordPatternsPreview1Aspect() {
  62. runTest("record patterns aspect");
  63. }
  64. public void testRecordPatternsPreview1ExhaustivenessAspect() {
  65. // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice,
  66. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
  67. // TODO: Remove redundant default clauses when fixed upstream
  68. System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed");
  69. runTest("record patterns exhaustiveness aspect");
  70. }
  71. public void testRecordPatternsPreview1ExhaustivenessError() {
  72. // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
  73. runTest("record patterns exhaustiveness error");
  74. }
  75. public void testRecordPatternsPreview1ExhaustivenessOK2() {
  76. // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected',
  77. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398
  78. // TODO: activate when fixed
  79. System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed");
  80. //runTest("record patterns exhaustiveness 2");
  81. }
  82. public static Test suite() {
  83. return XMLBasedAjcTestCase.loadSuite(Java20PreviewFeaturesTests.class);
  84. }
  85. @Override
  86. protected java.net.URL getSpecFile() {
  87. return getClassResource("ajc1920.xml");
  88. }
  89. }