<commit_before>package au.com.williamhill.flywheel.socketx.util;

import java.util.concurrent.atomic.*;

import org.junit.Test;

import com.obsidiandynamics.indigo.util.*;

import junit.framework.*;

public final class AsserterTest {
  @Test
  public void testPass() {
    Asserter.wait(10).withScale(2).withIntervalMillis(1).until(() -> {});
  }
  
  @Test
  public void testPassBoolean() {
    Asserter.wait(10).withScale(2).withIntervalMillis(1).untilTrue(() -> true);
  }
  
  @Test
  public void testFail() {
    final String message = "Boom";
    try {
      Asserter.wait(20).withIntervalMillis(1).until(() -> { throw new AssertionError(message); });
      TestCase.fail("AssertionError not thrown");
    } catch (AssertionError e) {
      TestCase.assertEquals(message, e.getMessage());
    }
  }
  
  @Test
  public void testFailBoolean() {
    try {
      Asserter.wait(20).withIntervalMillis(1).untilTrue(() -> false);
      TestCase.fail("AssertionError not thrown");
    } catch (AssertionError e) {}
  }
  
  @Test
  public void testPartialFail() {
    final AtomicInteger calls = new AtomicInteger();
    Asserter.wait(0).withIntervalMillis(1).until(() -> { 
      if (calls.getAndIncrement() == 0) {
        TestSupport.sleep(1);
        throw new AssertionError("Boom"); 
      }
    });
  }
  
  @Test
  public void testInterrupted() {
    Asserter.wait(20).untilTrue(() -> {
      Thread.currentThread().interrupt();
      return false;
    });
    TestCase.assertTrue(Thread.interrupted());
  }<commit_msg>Fixed test: handling of AssertionError.<commit_after>package au.com.williamhill.flywheel.socketx.util;

import java.util.concurrent.atomic.*;

import org.junit.Test;

import com.obsidiandynamics.indigo.util.*;

import junit.framework.*;

public final class AsserterTest {
  @Test
  public void testPass() {
    Asserter.wait(10).withScale(2).withIntervalMillis(1).until(() -> {});
  }
  
  @Test
  public void testPassBoolean() {
    Asserter.wait(10).withScale(2).withIntervalMillis(1).untilTrue(() -> true);
  }
  
  @Test
  public void testFail() {
    final String message = "Boom";
    try {
      Asserter.wait(20).withIntervalMillis(1).until(() -> { throw new AssertionError(message); });
      TestCase.fail("AssertionError not thrown");
    } catch (AssertionError e) {
      TestCase.assertEquals(message, e.getMessage());
    }
  }
  
  @Test
  public void testFailBoolean() {
    try {
      Asserter.wait(20).withIntervalMillis(1).untilTrue(() -> false);
      TestCase.fail("AssertionError not thrown");
    } catch (AssertionError e) {}
  }
  
  @Test
  public void testPartialFail() {
    final AtomicInteger calls = new AtomicInteger();
    Asserter.wait(0).withIntervalMillis(1).until(() -> { 
      if (calls.getAndIncrement() == 0) {
        TestSupport.sleep(1);
        throw new AssertionError("Boom"); 
      }
    });
  }
  
  @Test
  public void testInterrupted() {
    try {
      Asserter.wait(20).untilTrue(() -> {
        Thread.currentThread().interrupt();
        return false;
      });
    } catch (AssertionError ae) {
      
    } finally {
      TestCase.assertTrue(Thread.interrupted());
    }
  }
{'fraction_non_alphanumeric': 0.1486871243277444, 'fraction_numerical': 0.012654223347042075, 'mean_word_length': 3.1279373368146213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6989246', 'n_tokens_mistral': 1022, 'n_tokens_neox': 1012, 'n_words': 179}