<commit_before>(function(global, undefined) {
"use strict";

var Mocha = global.Mocha;
var Suite = Mocha.Suite;
var Test = Mocha.Test;

var assertFns = {
  ok: function(val) {
    if (!val) {
      throw new Error("Expected " + val + " to be truthy");
    }
  },
  equal: function(val1, val2) {
    if (val1 != val2) {
      throw new Error("Expected " + val1 + " to equal " + val2);
    }
  },
  notStrictEqual: function(val1, val2) {
    if (val1 !== val2) {
      throw new Error("Expected " + val1 + " to strictly equal " + val2);
    }
  }
};

/**
 * QUnit-style interface:
 *
 *     module('Array');
 *
 *     test('#length', function() {
 *       var arr = [1,2,3];
 *       ok(arr.length == 3);
 *     });
 *
 *     test('#indexOf()', function() {
 *       var arr = [1,2,3];
 *       ok(arr.indexOf(1) == 0);
 *       ok(arr.indexOf(2) == 1);
 *       ok(arr.indexOf(3) == 2);
 *     });
 *
 *     suite('String');
 *
 *     test('#length', function() {
 *       ok('foo'.length == 3);
 *     });
 *
 */

var ui = function(suite) {
  var suites = [suite];

  var assertionCount = 0;
  var inModule = false;
  var expectedAssertions;
  var deferrals = 0;
  var currentDoneFn;
  var checkingDeferrals;

  suite.on('pre-require', function(realContext) {

    /**
     * Execute before running tests.
     */
    var context = {};
    var assert = {};

    /**
     * Describe a "suite" with the given `title`.
     */

    context.module = function(title, opts) {
      if (suites.length > 1) suites.shift();
      var suite = Suite.create(suites[0], title);
      suites.unshift(suite);

      suite.beforeEach(function() {
        checkingDeferrals = false;
        deferrals = 0;
        inModule = true;
        assertionCount = 0;
      });
      if (opts) {
        suite.beforeEach(function() { for (var k in opts) this[k] = opts[k] });
        if (opts.setup) suite.beforeEach(opts.setup.bind(this, assert));
        if (opts.teardown) suite.afterEach(opts.teardown.bind(this, assert));
      }
      suite.afterEach(function(done) {
        done(checkAssertionCount());
      });
    };

    /**
    * Call this after each assertion to increment the assertion count
    * (for custom assertion types)
    */
    context.afterAssertion = function() {
      assertionCount++;
    };

    /** The number of assertions to expect in the current test case */
    context.expect = function(n) {
      if (!arguments.length) {
        return expectedAssertions;
      }
      expectedAssertions = n;
    };
<commit_msg>Add support for async setup and teardown functions<commit_after>(function(global, undefined) {
"use strict";

var Mocha = global.Mocha;
var Suite = Mocha.Suite;
var Test = Mocha.Test;

var assertFns = {
  ok: function(val) {
    if (!val) {
      throw new Error("Expected " + val + " to be truthy");
    }
  },
  equal: function(val1, val2) {
    if (val1 != val2) {
      throw new Error("Expected " + val1 + " to equal " + val2);
    }
  },
  notStrictEqual: function(val1, val2) {
    if (val1 !== val2) {
      throw new Error("Expected " + val1 + " to strictly equal " + val2);
    }
  }
};

/**
 * QUnit-style interface:
 *
 *     module('Array');
 *
 *     test('#length', function() {
 *       var arr = [1,2,3];
 *       ok(arr.length == 3);
 *     });
 *
 *     test('#indexOf()', function() {
 *       var arr = [1,2,3];
 *       ok(arr.indexOf(1) == 0);
 *       ok(arr.indexOf(2) == 1);
 *       ok(arr.indexOf(3) == 2);
 *     });
 *
 *     suite('String');
 *
 *     test('#length', function() {
 *       ok('foo'.length == 3);
 *     });
 *
 */

var ui = function(suite) {
  var suites = [suite];

  var assertionCount = 0;
  var inModule = false;
  var expectedAssertions;
  var deferrals = 0;
  var currentDoneFn;
  var checkingDeferrals;

  suite.on('pre-require', function(realContext) {

    /**
     * Execute before running tests.
     */
    var context = {};
    var assert = {};

    /**
     * Describe a "suite" with the given `title`.
     */

    context.module = function(title, opts) {
      if (suites.length > 1) suites.shift();
      var suite = Suite.create(suites[0], title);
      suites.unshift(suite);

      suite.beforeEach(function() {
        checkingDeferrals = false;
        deferrals = 0;
        inModule = true;
        assertionCount = 0;
      });
      if (opts) {
        suite.beforeEach(function() { for (var k in opts) this[k] = opts[k] });
        if (opts.setup) {
          suite.beforeEach(function(done) {
            stop();
            currentDoneFn = done;
            opts.setup(assert);
            start();
          });
        }
        if (opts.teardown) {
          suite.afterEach(function(done) {
            stop();
            currentDoneFn = done;
            opts.teardown(assert);
            start();
          });
        }
      }
      suite.afterEach(function(done) {
        done(checkAssertionCount());
      });
    };

    /**
    * Call this after each assertion to increment the assertion count
    * (for custom assertion types)
    */
    context.afterAssertion = function() {
      assertionCount++;
    };

    /** The number of assertions to expect in the current test case */
    context.expect = function(n) {
      if (!arguments.length) {
        return expectedAssertions;
      }
      expectedAssertions = n;
    };

{'fraction_non_alphanumeric': 0.15678203928905518, 'fraction_numerical': 0.01197380729653882, 'mean_word_length': 2.1190198366394397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3355685', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1701, 'n_words': 403}