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.

Asserts.java 862B

12345678910111213141516171819202122232425262728293031323334
  1. import org.aspectj.testing.Tester;
  2. public class Asserts {
  3. public static void main(String[] args) {
  4. Asserts.class.getClassLoader().setClassAssertionStatus("TestAsserts", true);
  5. TestAsserts.main(args);
  6. }
  7. }
  8. class TestAsserts {
  9. public static void main(String[] args) {
  10. //C c = new C();
  11. //C.m(9);
  12. int x = 0;
  13. assert x < 2;
  14. assert x <10 : 3;
  15. boolean pass = false;
  16. try { assert x > 2; }
  17. catch (AssertionError e) { pass = true; }
  18. finally { Tester.check(pass, "no expected assertion-1"); }
  19. pass = false;
  20. try { assert x >10 : 3; }
  21. catch (AssertionError e) { pass = true; }
  22. finally { Tester.check(pass, "no expected assertion-2"); }
  23. }
  24. static class C {
  25. static void m(int i ) {
  26. assert i < 10;
  27. }
  28. }
  29. }