//create a scope so we don't pollute global
(function() {
    var testName;

    window.getCoverage = function(){

        var report = {};
        if (_$jscoverage) for (var file in _$jscoverage) {
            if (!_$jscoverage.hasOwnProperty(file)) continue;

            var coverage = _$jscoverage[file];
            report[file] = {};
            report[file].source = coverage.source;
            report[file].file = file;
            report[file].coverage = {};
            for (var i = 0; i < coverage.source.length; i++) {
                if (coverage[i] != undefined) {
                    report[file].coverage[i] = coverage[i];
                }
            }

        }

        return JSON['stringify' in JSON ? 'stringify' : 'encode'](report);

    };

    //arg: { name }
    QUnit.moduleStart = function(t) {
        console.log('Module "' + t.name + '"');
    };

    //arg: { name }
    QUnit.moduleDone = function(t) {
        console.log('Module completed: ' + (0 === t.failed ? 'pass' : 'FAIL'));
        console.log('');
    };

    //arg: { name }
    QUnit.testStart = function(t) {
        testName = t.name;
    };

    //arg: { name, failed, passed, total }
    QUnit.testDone = function(t) {
        console.log('Test "' + t.name + '" completed: ' + (0 === t.failed ? 'pass' : 'FAIL'))
    };

    //{ result, actual, expected, message }
    QUnit.log = function(t) {
        if (!t.result) {
            console.log('Test "' + testName + '" assertion failed. Expected <' + t.expected + '> Actual <' + t.actual + '>' + (t.message ? ': \'' + t.message + '\'' : ''));
        }
    };

    QUnit.done = function(t) {
    };

}());