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.

Enums.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Andy Clement - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.systemtest.ajc150;
  12. import org.aspectj.testing.XMLBasedAjcTestCase;
  13. import junit.framework.Test;
  14. /**
  15. * Enums, the rules/tests:
  16. *
  17. * 1. cannot make ITDC on an enum
  18. * 2. cannot make ITDM or ITDF on an enum
  19. * 3. cannot use declare parents to change the super type of an enum
  20. * 4. cannot use decp to make an enum type implement an interface
  21. * 5. cannot use decp to dec java.lang.Enum as the parent of any type
  22. * 6. cannot extend set of values in an enum via an ITD like construct
  23. * 7. Compilation error if you explicitly identify an Enum type.
  24. * 8. Lint warning if a non-explicit type pattern would match an enum type.
  25. *
  26. */
  27. public class Enums extends XMLBasedAjcTestCase {
  28. public static Test suite() {
  29. return XMLBasedAjcTestCase.loadSuite(Enums.class);
  30. }
  31. protected java.net.URL getSpecFile() {
  32. return getClassResource("ajc150.xml");
  33. }
  34. // Cannot make ITDC on an enum
  35. public void test001_itdcsOnEnumNotAllowed() {
  36. runTest("cant itd constructor on enum");
  37. }
  38. // Cannot make ITDM or ITDF on an enum
  39. public void test002_itdFieldOrMethodOnEnumNotAllowed() {
  40. runTest("cant itd field or method on enum");
  41. }
  42. // Deals with the cases where an explicit type is specified and it is an enum type
  43. public void test003_decpOnEnumNotAllowed_errors() {
  44. runTest("declare parents and enums");
  45. }
  46. //Deals with the cases where an wild type pattern is specified and it hits an enum type
  47. public void test004_decpOnEnumNotAllowed_xlints() {
  48. runTest("wildcard enum match in itd");
  49. }
  50. // CompilationResult cR = binaryWeave("testcode.jar","EnumAspect04.aj",0,2,false);
  51. // IMessage msg = (IMessage)cR.getWarningMessages().get(0);
  52. // assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg,
  53. // msg.toString().indexOf("matches a declare parents type pattern")!=-1);
  54. // msg = (IMessage)cR.getWarningMessages().get(1);
  55. // assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg,
  56. // msg.toString().indexOf("matches a declare parents type pattern")!=-1);
  57. // verifyWeavingMessagesOutput(cR,new String[]{});
  58. // }
  59. }