<commit_before>/* global console, mocha, mochaPhantomJS */
mocha.setup('bdd');
mocha.reporter('html');

// PhantomJS doesn't support bind yet
Function.prototype.bind = Function.prototype.bind || function (thisp) {
  var fn = this;
  return function () {
    return fn.apply(thisp, arguments);
  };
};

(function () { // begin local scope

var useBuilt, baseUrl, testBase, search = window.location.search;

// use built version if query string contains "built" parameter
useBuilt = !!search.match(/[?&]?built(=[^&]*)?(&|$)/);

if (useBuilt) {
    baseUrl = '_build/src';
    testBase = "../../";
} else {
    baseUrl = 'src';
    testBase = "../";
}
console.log("loading Vellum from " + baseUrl);

// comment these to use built versions
define("jquery", [testBase + 'bower_components/jquery/dist/jquery'], function () { return window.jQuery; });
define("jquery-ui", ["jquery", testBase + 'bower_components/jquery-ui/jquery-ui'], function () {});
define("jquery.bootstrap", ["jquery", testBase + 'lib/bootstrap'], function () {});

require.config({
    baseUrl: baseUrl,
    paths: {
        "jquery.vellum": "main",
        "tests": testBase + "tests"
    }
});

// load jquery.vellum before loading tests because some tests depend on
// jquery.vellum components and would try to load them at the wrong path
// (this is only important when using the built version)
require(['jquery', 'jquery.vellum'], function ($) {
    // define our own paths for test dependencies that are also dependencies of
    // vellum that get excluded from the built version of vellum, to ensure that
    // the built version is tested correctly
    require.config({
        // handle potential slow free heroku dynos
        waitSeconds: 60,
        paths: {
            'static': testBase + 'tests/static',
            'chai': testBase + 'bower_components/chai/chai',
            'equivalent-xml': testBase + 'bower_components/equivalent-xml-js/src/equivalent-xml'
        },
        shim: {
            'equivalent-xml': {
                deps: ['underscore'],
                exports: 'EquivalentXml'
            }
        }
    });

    if (useBuilt) {
        require.config({
            paths: {
                'text': '../bower_components/requirejs-text',
                // for some reason this is necessary in firefox only for built
                // version test page.  It shouldn't be
                'tpl': '../bower_components/requirejs-tpl',
                // https://github.com/guybedford/require-css/issues/133 
                //'css': 'error',
                'less': 'error',
                'json': 'error'
            }
        });
        $('head').append('<link rel="stylesheet" type="text/css" href="_build/style.css">');
    }

    require([
        'tests/options',

        // tests for profiling load times
        // (disabled by default because they take a long time)
        //'tests/profiling',

        // register tests on global mocha instance as side-effect
        'tests/base',
        'tests/core',
        'tests/form',
        'tests/logic',
        'tests/parser',
        'tests/questionTypes',
        'tests/exporter',
        'tests/widgets',
        'tests/writer',
        'tests/commtrack',
        'tests/javaRosa',
        'tests/modeliteration',
        'tests/intentManager',
        'tests/diffDataParent',
        'tests/formdesigner.ignoreButRetain',
        'tests/formdesigner.lock',
        'tests/itemset',
        'tests/tsv',
        'tests/xml'
    ], function (
        options
    ) {
        var session = window.sessionStorage;

        function runTests() {
            function showTestResults() {
                $(".sidebar .nav #resultsTab a").click();
            }
            if (window.mochaPhantomJS) {
                mochaPhantomJS.run();
            } else {
                $(".sidebar #mocha-stats").remove();
                mocha.run();
                // move progress indicator into sidebar
                $("#mocha-stats").css({
                    "margin-top": "3em",
                    position: "relative",
                    left: 0,
                    top: 0
                }).appendTo(".sidebar");
                $("#mocha-stats li").css({display: "block"});
                $("#mocha-stats li.progress").css({height: "40px"});
                $("#mocha-stats li.passes a").click(showTestResults);<commit_msg>Fix test result links on stand-alone test page<commit_after>/* global console, mocha, mochaPhantomJS */
mocha.setup('bdd');
mocha.reporter('html');

// PhantomJS doesn't support bind yet
Function.prototype.bind = Function.prototype.bind || function (thisp) {
  var fn = this;
  return function () {
    return fn.apply(thisp, arguments);
  };
};

(function () { // begin local scope

var useBuilt, baseUrl, testBase, search = window.location.search;

// use built version if query string contains "built" parameter
useBuilt = !!search.match(/[?&]?built(=[^&]*)?(&|$)/);

if (useBuilt) {
    baseUrl = '_build/src';
    testBase = "../../";
} else {
    baseUrl = 'src';
    testBase = "../";
}
console.log("loading Vellum from " + baseUrl);

// comment these to use built versions
define("jquery", [testBase + 'bower_components/jquery/dist/jquery'], function () { return window.jQuery; });
define("jquery-ui", ["jquery", testBase + 'bower_components/jquery-ui/jquery-ui'], function () {});
define("jquery.bootstrap", ["jquery", testBase + 'lib/bootstrap'], function () {});

require.config({
    baseUrl: baseUrl,
    paths: {
        "jquery.vellum": "main",
        "tests": testBase + "tests"
    }
});

// load jquery.vellum before loading tests because some tests depend on
// jquery.vellum components and would try to load them at the wrong path
// (this is only important when using the built version)
require(['jquery', 'jquery.vellum'], function ($) {
    // define our own paths for test dependencies that are also dependencies of
    // vellum that get excluded from the built version of vellum, to ensure that
    // the built version is tested correctly
    require.config({
        // handle potential slow free heroku dynos
        waitSeconds: 60,
        paths: {
            'static': testBase + 'tests/static',
            'chai': testBase + 'bower_components/chai/chai',
            'equivalent-xml': testBase + 'bower_components/equivalent-xml-js/src/equivalent-xml'
        },
        shim: {
            'equivalent-xml': {
                deps: ['underscore'],
                exports: 'EquivalentXml'
            }
        }
    });

    if (useBuilt) {
        require.config({
            paths: {
                'text': '../bower_components/requirejs-text',
                // for some reason this is necessary in firefox only for built
                // version test page.  It shouldn't be
                'tpl': '../bower_components/requirejs-tpl',
                // https://github.com/guybedford/require-css/issues/133 
                //'css': 'error',
                'less': 'error',
                'json': 'error'
            }
        });
        $('head').append('<link rel="stylesheet" type="text/css" href="_build/style.css">');
    }

    require([
        'tests/options',

        // tests for profiling load times
        // (disabled by default because they take a long time)
        //'tests/profiling',

        // register tests on global mocha instance as side-effect
        'tests/base',
        'tests/core',
        'tests/form',
        'tests/logic',
        'tests/parser',
        'tests/questionTypes',
        'tests/exporter',
        'tests/widgets',
        'tests/writer',
        'tests/commtrack',
        'tests/javaRosa',
        'tests/modeliteration',
        'tests/intentManager',
        'tests/diffDataParent',
        'tests/formdesigner.ignoreButRetain',
        'tests/formdesigner.lock',
        'tests/itemset',
        'tests/tsv',
        'tests/xml'
    ], function (
        options
    ) {
        var session = window.sessionStorage;

        function runTests() {
            function showTestResults() {
                $(".sidebar .nav #resultsTab a").click();
                return false;
            }
            if (window.mochaPhantomJS) {
                mochaPhantomJS.run();
            } else {
                $(".sidebar #mocha-stats").remove();
                mocha.run();
                // move progress indicator into sidebar
                $("#mocha-stats").css({
                    "margin-top": "3em",
                    position: "relative",
                    left: 0,
                    top: 0
                }).appendTo(".sidebar");
                $("#mocha-stats li").css({display: "block"});
                $("#mocha-stats li.progress").css({height: "40px"});
                $("#mocha-stats li.passes a").click(showTestResults);
{'fraction_non_alphanumeric': 0.14587809566889065, 'fraction_numerical': 0.0022616759018432657, 'mean_word_length': 1.960830264479411, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '6365532', 'n_tokens_mistral': 2542, 'n_tokens_neox': 2410, 'n_words': 614}