@@ -0,0 +1,2967 @@
+package org.realityforge.arez.api2;%0A%0Aimport org.testng.annotations.Test;%0Aimport static org.testng.Assert.*;%0A%0Apublic class GuardsTest%0A  extends AbstractArezTest%0A%7B%0A  @Test%0A  public void fail()%0A    throws Exception%0A  %7B%0A    final IllegalStateException exception =%0A      expectThrows( IllegalStateException.class, () -%3E Guards.fail( () -%3E %22My Failure Reason%22 ) );%0A%0A    assertEquals( exception.getMessage(), %22My Failure Reason%22 );%0A  %7D%0A%0A  @Test%0A  public void fail_verboseErrorMessages_false()%0A    throws Exception%0A  %7B%0A    final ArezConfig.DynamicProvider provider = (ArezConfig.DynamicProvider) ArezConfig.getProvider();%0A    provider.setVerboseErrorMessages( false );%0A%0A    final IllegalStateException exception =%0A      expectThrows( IllegalStateException.class, () -%3E Guards.fail( () -%3E %22My Failure Reason%22 ) );%0A%0A    assertEquals( exception.getMessage(), null );%0A  %7D%0A%0A  @Test%0A  public void fail_checkInvariants_false()%0A    throws Exception%0A  %7B%0A    final ArezConfig.DynamicProvider provider = (ArezConfig.DynamicProvider) ArezConfig.getProvider();%0A    provider.setCheckInvariants( false );%0A%0A    // No failure%0A    Guards.fail( () -%3E %22My Failure Reason%22 );%0A  %7D%0A%0A  @Test%0A  public void invariant_passed()%0A    throws Exception%0A  %7B%0A    Guards.invariant( () -%3E true, () -%3E %22My Failure Reason%22 );%0A  %7D%0A%0A  @Test%0A  public void invariant_failed()%0A    throws Exception%0A  %7B%0A    final IllegalStateException exception =%0A      expectThrows( IllegalStateException.class, () -%3E Guards.invariant( () -%3E false, () -%3E %22My Failure Reason%22 ) );%0A%0A    assertEquals( exception.getMessage(), %22My Failure Reason%22 );%0A  %7D%0A%0A  @Test%0A  public void invariant_condition_throws_exception()%0A    throws Exception%0A  %7B%0A    final IllegalStateException exception =%0A      expectThrows( IllegalStateException.class, () -%3E Guards.invariant( () -%3E %7B%0A        throw new RuntimeException( %22X%22 );%0A      %7D, () -%3E %22My Failure Reason%22 ) );%0A%0A    final String message = exception.getMessage();%0A    assertTrue( message.startsWith( %22Error checking condition.%5Cn%22 +%0A                                    %22Message: My Failure Reason%5Cn%22 +%0A                                    %22Throwable:%5Cn%22 +%0A                                    %22java.lang.RuntimeException: X%22 ) );%0A  %7D%0A%0A  @Test%0A  public void invariant_verboseErrorMessages_false()%0A    throws Exception%0A  %7B%0A    final ArezConfig.DynamicProvider provider = (ArezConfig.DynamicProvider) ArezConfig.getProvider();%0A    provider.setVerboseErrorMessages( false );%0A%0A    final IllegalStateException exception =%0A      expectThrows( IllegalStateException.class, () -%3E Guards.invariant( () -%3E false, () -%3E %22My Failure Reason%22 ) );%0A%0A    assertEquals( exception.getMessage(), null );%0A  %7D%0A%0A  @Test%0A  public void invariant_checkInvariants_false()%0A    throws Exception%0A  %7B%0A    final ArezConfig.DynamicProvider provider = (ArezConfig.DynamicProvider) ArezConfig.getProvider();%0A    provider.setCheckInvariants( false );%0A%0A    // No failure%0A    Guards.invariant( () -%3E false, () -%3E %22My Failure Reason%22 );%0A  %7D%0A%7D%0A

Add some tests for guards code