<commit_before>/*global it:true, jasmine, mocha*/
function isMochaModule(module) {
    return module && module.exports && module.exports.name === 'Mocha';
}

function isVanillaMocha() {
    var currentModule = typeof module !== 'undefined' && module;
    while (currentModule) {
        if (isMochaModule(currentModule)) {
            return true;
        } else {
            currentModule = currentModule.parent;
        }
    }
    return false;
}

function jasmineFail(err) {
    if (typeof jasmine === 'object') {
        jasmine.getEnv().fail(err);
    }
}

function jasmineSuccess(err) {
    if (typeof jasmine === 'object') {
        jasmine.getEnv().expect(true).toBe(true);
    }
}

var promiseCreated = false;

var shouldApplyPatch =
    typeof mocha !== 'undefined' ||
    (typeof jasmine !== 'undefined' && typeof jasmine.version === 'string' && jasmine.version.match(/^2\./)) ||
    isVanillaMocha();

module.exports = {
    promiseCreated: function () {
        promiseCreated = true;
    },
    applyPatch: function () {
        if (it.patchApplied) {
            return;
        }

        if (shouldApplyPatch) {
            var originalIt = it;
            it = function (title, fn) {
                if (!fn) {
                    return originalIt(title);
                }
                var async = fn.length > 0;
                var wrapper = function (done) {
                    promiseCreated = false;<commit_msg>testFrameworkPatch: Don't attempt to patch 'it' when it's not there.<commit_after>/*global it:true, jasmine, mocha*/
function isMochaModule(module) {
    return module && module.exports && module.exports.name === 'Mocha';
}

function isVanillaMocha() {
    var currentModule = typeof module !== 'undefined' && module;
    while (currentModule) {
        if (isMochaModule(currentModule)) {
            return true;
        } else {
            currentModule = currentModule.parent;
        }
    }
    return false;
}

function jasmineFail(err) {
    if (typeof jasmine === 'object') {
        jasmine.getEnv().fail(err);
    }
}

function jasmineSuccess(err) {
    if (typeof jasmine === 'object') {
        jasmine.getEnv().expect(true).toBe(true);
    }
}

var promiseCreated = false;

var shouldApplyPatch =
    typeof mocha !== 'undefined' ||
    (typeof jasmine !== 'undefined' && typeof jasmine.version === 'string' && jasmine.version.match(/^2\./)) ||
    isVanillaMocha();

module.exports = {
    promiseCreated: function () {
        promiseCreated = true;
    },
    applyPatch: function () {
        if (typeof it === 'undefined' || it.patchApplied) {
            return;
        }

        if (shouldApplyPatch) {
            var originalIt = it;
            it = function (title, fn) {
                if (!fn) {
                    return originalIt(title);
                }
                var async = fn.length > 0;
                var wrapper = function (done) {
                    promiseCreated = false;
{'fraction_non_alphanumeric': 0.13250168577208363, 'fraction_numerical': 0.0013486176668914363, 'mean_word_length': 2.084199584199584, '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': '7525470', 'n_tokens_mistral': 884, 'n_tokens_neox': 834, 'n_words': 197}