<commit_before>var assign = require("object-assign");

// TODO: commander ?
var esVersion = process.argv.slice(2)[0] || "es6";
var command = process.argv.slice(2)[1] || "tests";
var commandParams = process.argv.slice(4);

console.error("[DEBUG] esVersion:"+ esVersion + ",command:"+ command);

var data = require("./data-" + esVersion + ".js");

var browsers = data.browsers;
var tests = data.tests;

console.error("[DEBUG] raw:"+ tests.length + ",browsers:"+ Object.keys(browsers).length);

var browserNames = Object.keys(data.browsers).sort(); //FIXME: ie10 shell go after ie9, see getHigherBrowserVersions
//console.error("[DEBUG] browserNames:"+ browserNames);


tests = tests.reduce(extractSubtests, []);
if (command !== "tests-raw-browsers") {
    tests.forEach(addHigherBrowserVersions);
}
console.error("[DEBUG] extractSubtests:"+ tests.length + ",browsers:"+ Object.keys(browsers).length);


if (command === "browsers") {
    console.log(JSON.stringify(browsers, null, "\t"));
} else if (command === "tests" || command === "tests-raw-browsers"  ) {
	if(commandParams){
		var testFilter=commandParams[0];
		var browserFilter=commandParams[1];
		
		tests=tests.filter(function(test){
			 return (!testFilter || ~test.name.indexOf(testFilter)) && (!browserFilter || test.res[browserFilter]);
		});
	}
    console.log(JSON.stringify(tests, null, "\t"));
} else {
    console.error("Unknown command " + command);
    process.exit(1);
}



function extractSubtests(r, test) {
    if (test.subtests) {
        test.subtests.forEach(function(subtest){
            // TODO: nicer, this is old code when it was not array
            // merge subtest data with parents data
            var newTest = assign({}, test, subtest);
            newTest.name = test.name + " - " + subtest.name;<commit_msg>[FIX] unsupported browsers work at leas for es5 (sort)<commit_after>var assign = require("object-assign");

// TODO: commander ?
var esVersion = process.argv.slice(2)[0] || "es6";
var command = process.argv.slice(2)[1] || "tests";
var commandParams = process.argv.slice(4);

//console.error("[DEBUG] esVersion:"+ esVersion + ",command:"+ command);

var data = require("./data-" + esVersion + ".js");

var browsers = data.browsers;
var tests = data.tests;

//console.error("[DEBUG] raw:"+ tests.length + ",browsers:"+ Object.keys(browsers).length);

var browserNames = Object.keys(data.browsers); // in es5 data they seem to be sorted well
// if not implement correct sorting (beware ie10 vs ie9 ;-)
//console.error("[DEBUG] browserNames:"+ browserNames);


tests = tests.reduce(extractSubtests, []);
if (command !== "tests-raw-browsers") {
    tests.forEach(addHigherBrowserVersions);
}
//console.error("[DEBUG] extractSubtests:"+ tests.length + ",browsers:"+ Object.keys(browsers).length);


if (command === "browsers") {
    console.log(JSON.stringify(browsers, null, "\t"));
} else if (command === "tests" || command === "tests-raw-browsers"  ) {
	if(commandParams){
		var testFilter=commandParams[0];
		var browserFilter=commandParams[1];
		
		tests=tests.filter(function(test){
			 return (!testFilter || ~test.name.indexOf(testFilter)) && (!browserFilter || test.res[browserFilter]);
		});
	}
    console.log(JSON.stringify(tests, null, "\t"));
} else {
    console.error("Unknown command " + command);
    process.exit(1);
}



function extractSubtests(r, test) {
    if (test.subtests) {
        test.subtests.forEach(function(subtest){
            // TODO: nicer, this is old code when it was not array
            // merge subtest data with parents data
            var newTest = assign({}, test, subtest);
            newTest.name = test.name + " - " + subtest.name;
{'fraction_non_alphanumeric': 0.1739248775176919, 'fraction_numerical': 0.007076755579749592, 'mean_word_length': 4.090027700831025, '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': '3027911', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1152, 'n_words': 265}