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.

Java19PreviewFeaturesTests.java 4.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.ajc1919;
  9. import junit.framework.Test;
  10. import org.aspectj.apache.bcel.Constants;
  11. import org.aspectj.testing.XMLBasedAjcTestCase;
  12. import org.aspectj.testing.XMLBasedAjcTestCaseForJava19Only;
  13. /**
  14. * @author Alexander Kriegisch
  15. */
  16. public class Java19PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava19Only {
  17. private static final Constants.ClassFileVersion classFileVersion = Constants.ClassFileVersion.of(19);
  18. public void testSwitchPatternMatchingPreview3Java() {
  19. runTest("switch pattern matching preview 3 java");
  20. checkVersion("SwitchPatternPreview3OK", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  21. }
  22. public void testSwitchPatternMatchingPreview3Aspect() {
  23. runTest("switch pattern matching preview 3 aspect");
  24. checkVersion("SwitchPatternPreview3Aspect", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  25. checkVersion("Application", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  26. checkVersion("Shape", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  27. checkVersion("S", classFileVersion.MAJOR, classFileVersion.PREVIEW_MINOR);
  28. }
  29. public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() {
  30. runTest("switch pattern matching error");
  31. }
  32. public void testSwitchPatternMatchingPreview3Error1() {
  33. runTest("switch pattern matching preview 3 error 1");
  34. }
  35. public void testSwitchPatternMatchingPreview3Error2() {
  36. runTest("switch pattern matching preview 3 error 2");
  37. }
  38. public void testRecordPatternsPreview1OK() {
  39. // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450
  40. runTest("record patterns");
  41. }
  42. public void testRecordPatternsPreview1Error() {
  43. // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450
  44. runTest("record patterns error");
  45. }
  46. public void testRecordPatternsPreview1ExhaustivenessOK1() {
  47. // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice,
  48. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455
  49. // TODO: activate when fixed
  50. System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed");
  51. //runTest("record patterns exhaustiveness 1");
  52. }
  53. public void testRecordPatternsPreview1Aspect() {
  54. runTest("record patterns aspect");
  55. }
  56. public void testRecordPatternsPreview1ExhaustivenessAspect() {
  57. // TODO: Remove redundant default clauses in RecordPatternsPreview1Aspect when
  58. // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed. Furthermore, activate '<run />'
  59. // action for XML test case in order to not just compile but also run the code.
  60. System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed");
  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. // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected',
  69. // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398
  70. // TODO: activate when fixed
  71. System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed");
  72. //runTest("record patterns exhaustiveness 2");
  73. }
  74. public static Test suite() {
  75. return XMLBasedAjcTestCase.loadSuite(Java19PreviewFeaturesTests.class);
  76. }
  77. @Override
  78. protected java.net.URL getSpecFile() {
  79. return getClassResource("ajc1919.xml");
  80. }
  81. }