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.

AssertInIntro.java 810B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import org.aspectj.testing.Tester;
  2. public class AssertInIntro {
  3. public static void main(String[] args) {
  4. turnOnAssertions();
  5. runTests();
  6. }
  7. static void turnOnAssertions() {
  8. ClassLoader cl = AssertInIntro.class.getClassLoader();
  9. cl.setClassAssertionStatus("C", false);
  10. cl.setClassAssertionStatus("A", true);
  11. }
  12. static void runTests() {
  13. boolean failed = false;
  14. try {
  15. C.foo();
  16. } catch (AssertionError e) {
  17. failed = true;
  18. }
  19. Tester.check(failed, "introduced assertions improperly off");
  20. failed = false;
  21. try {
  22. C.goo();
  23. } catch (AssertionError e) {
  24. failed = true;
  25. }
  26. Tester.check(!failed, "non-introduced assertions improperly on");
  27. }
  28. }
  29. class C {
  30. static void goo() {
  31. assert false;
  32. }
  33. }
  34. aspect A {
  35. static void C.foo() {
  36. assert false;
  37. }
  38. }