<commit_before>/* Moch XHR library for YAHOO.util.Connect.asyncRequest */

if (typeof doctest == 'undefined') {
    throw("You must include doctest.js before doctest-yui.js");
}

/* Set in tests to change the response: */
doctest.mockYUIResponse = '';
doctest.mockYUIFailure = false;

doctest.mockYUIAsyncRequest = function (method, uri, callback, body/*optional*/) {
    writeln(method + ' '+uri);
    if (body) {
        writeln('body: '+body);
    }
    if (doctest.mockYUIFailure) {
        var res = {
            tid: null, // FIXME: set
            status: 0,
            statusText: 'Failure',
            argument: callback.argument}
        if (typeof doctest.mockYUIFailure == 'object') {
            doctest.extend(res, doctest.mockYUIFailure);
        }
        callback.failure(res);
    } else {
        res = {
            tid: null, // FIXME: set
            status: 200,
            statusText: 'OK',
            getResponseHeader: function (label) {
                return null;
            }, // FIXME: implement
            getAllResponseHeaders: function () {
                return '';
            }, // FIXME: implement
            responseText: '',
            responseXML: null,
            argument: callback.argument}
        if (typeof doctest.mockYUIResponse == 'string') {
            res.responseText = doctest.mockYUIResponse;
        } else if (typeof doctest.mockYUIResponse == 'object') {
            if (doctest.mockYUIResponse.nodeType) {
                res.responseXML = doctest.mockYUIResponse;
            } else {
                doctest.extend(res, doctest.mockYUIResponse);
            }
        }
        callback.success(res);
    }
};

doctest.uninstallMockYUI = function () {
    YAHOO.util.Connect.asyncRequest = doctest.realYUIAsyncRequest;
};

doctest.installMockYUI = function () {
    YAHOO.util.Connect.asyncRequest = doctest.mockYUIAsyncResponse;
}

try {
    var doctest.realYUIAsyncRequest = YAHOO.util.Connect.asyncRequest;
    doctest.installMockYUI();
} catch (e) {
    throw("Could not install mock YAHOO.util.Connect.asyncRequest: "+e);
}<commit_msg>[svn r2847] small fixes/bugs<commit_after>/* Moch XHR library for YAHOO.util.Connect.asyncRequest */

if (typeof doctest == 'undefined') {
    throw("You must include doctest.js before doctest-yui.js");
}

/* Set in tests to change the response: */
doctest.mockYUIResponse = '';
doctest.mockYUIFailure = false;

doctest.mockYUIAsyncRequest = function (method, uri, callback, body/*optional*/) {
    writeln(method + ' '+uri);
    if (body) {
        writeln('body: '+body);
    }
    if (doctest.mockYUIFailure) {
        var res = {
            tid: null, // FIXME: set
            status: 0,
            statusText: 'Failure',
            argument: callback.argument}
        if (typeof doctest.mockYUIFailure == 'object') {
            doctest.extend(res, doctest.mockYUIFailure);
        }
        callback.failure(res);
    } else {
        res = {
            tid: null, // FIXME: set
            status: 200,
            statusText: 'OK',
            getResponseHeader: function (label) {
                return null;
            }, // FIXME: implement
            getAllResponseHeaders: function () {
                return '';
            }, // FIXME: implement
            responseText: '',
            responseXML: null,
            argument: callback.argument}
        if (typeof doctest.mockYUIResponse == 'string') {
            res.responseText = doctest.mockYUIResponse;
        } else if (typeof doctest.mockYUIResponse == 'object') {
            if (doctest.mockYUIResponse.nodeType) {
                res.responseXML = doctest.mockYUIResponse;
            } else {
                doctest.extend(res, doctest.mockYUIResponse);
            }
        }
        callback.success(res);
    }
};

doctest.uninstallMockYUI = function () {
    YAHOO.util.Connect.asyncRequest = doctest.realYUIAsyncRequest;
};

doctest.installMockYUI = function () {
    YAHOO.util.Connect.asyncRequest = doctest.mockYUIAsyncRequest;
}

try {
    doctest.realYUIAsyncRequest = YAHOO.util.Connect.asyncRequest;
    doctest.installMockYUI();
} catch (e) {
    throw("Could not install mock YAHOO.util.Connect.asyncRequest: "+e);
}
{'fraction_non_alphanumeric': 0.11968838526912182, 'fraction_numerical': 0.0028328611898017, 'mean_word_length': 2.1292466765140325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7608831', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1264, 'n_words': 254}