// run this with "java -ea AssertTest" (option -ea to enable assertions)

public class AssertTest
{
  public static void main(String args[])
  {
    System.out.println("Setting test = 0");
    int test = 0;
    try
      {
	System.out.println("Asserting that test == 0");
	assert test == 0; // ok

	System.out.print("Asserting that test == 1 should cause an assertion violation: raise an AssertionError");
	assert test == 1 : "test is 0, not 1"; // not ok
      }
    catch (AssertionError error)
      {
	System.out.println();
	System.out.println(error);
	System.out.println("Exiting Java upon assertion violation");
	System.exit(1); // non-0 indicates abnormal termination
      }

    System.out.println("... but it doesn't! - BUG!!!");

  }
}
