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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 java.io.File;
  13. import junit.framework.Test;
  14. import org.aspectj.testing.XMLBasedAjcTestCase;
  15. /**
  16. * Enums, the rules/tests:
  17. *
  18. * 1. cannot make ITDC on an enum
  19. * 2. cannot make ITDM or ITDF on an enum
  20. * 3. cannot use declare parents to change the super type of an enum
  21. * 4. cannot use decp to make an enum type implement an interface
  22. * 5. cannot use decp to dec java.lang.Enum as the parent of any type
  23. * 6. cannot extend set of values in an enum via an ITD like construct
  24. * 7. Compilation error if you explicitly identify an Enum type.
  25. * 8. Lint warning if a non-explicit type pattern would match an enum type.
  26. *
  27. */
  28. public class Enums extends XMLBasedAjcTestCase {
  29. public static Test suite() {
  30. return XMLBasedAjcTestCase.loadSuite(Enums.class);
  31. }
  32. protected File getSpecFile() {
  33. return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml");
  34. }
  35. // Cannot make ITDC on an enum
  36. public void test001_itdcsOnEnumNotAllowed() {
  37. runTest("cant itd constructor on enum");
  38. }
  39. // Cannot make ITDM or ITDF on an enum
  40. public void test002_itdFieldOrMethodOnEnumNotAllowed() {
  41. runTest("cant itd field or method on enum");
  42. }
  43. // Deals with the cases where an explicit type is specified and it is an enum type
  44. public void test003_decpOnEnumNotAllowed_errors() {
  45. runTest("declare parents and enums");
  46. }
  47. //Deals with the cases where an wild type pattern is specified and it hits an enum type
  48. public void test004_decpOnEnumNotAllowed_xlints() {
  49. runTest("wildcard enum match in itd");
  50. }
  51. // CompilationResult cR = binaryWeave("testcode.jar","EnumAspect04.aj",0,2,false);
  52. // IMessage msg = (IMessage)cR.getWarningMessages().get(0);
  53. // assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg,
  54. // msg.toString().indexOf("matches a declare parents type pattern")!=-1);
  55. // msg = (IMessage)cR.getWarningMessages().get(1);
  56. // assertTrue("Expected a message about an enum type matching a declare parents but being ignored: "+msg,
  57. // msg.toString().indexOf("matches a declare parents type pattern")!=-1);
  58. // verifyWeavingMessagesOutput(cR,new String[]{});
  59. // }
  60. }