<commit_before>"use strict";
const jsc = require('jsverify');

var runall = async function(actions, state, model) {
    for (var idx = 0 ; idx != actions.length ; ++idx) {
        var ac = actions[idx];
        if (ac.check(model)) {
            ac.hasStarted = true;
            if (! await ac.run(state, model)) {
                return false;
            }
        }
    }
    return true;
};

var forallImpl = function(arbSeed, arbCommands, warmup, teardown) {
    var testNumber = 0;
    return jsc.forall(arbSeed, arbCommands, async function(seed, commands) {
        var actions = commands.map(c => c.command);
        var {state, model} = await warmup(seed);
        var result = await runall(actions, state, model);
        await teardown();
        return result;
    });
};

var DEFAULT_SEED_GEN = jsc.constant(undefined);
var DEFAULT_WARMUP = seed => new Object({state: {}, model: {}});
var DEFAULT_TEARDOWN = () => {};

var isGenerator = function(obj) {
    return obj !== undefined && obj.generator !== undefined;
};
var forall = function(...params) {
    if (params.length === 0 || ! isGenerator(params[0])) {
        throw "forall requires at least a commands generator as first argument";
    }
    if (! isGenerator(params[1])) {
        return forallImpl(DEFAULT_SEED_GEN, params[0], params[1] || DEFAULT_WARMUP, params[2] || DEFAULT_TEARDOWN);
    }
    return forallImpl(params[0], params[1], params[2] || DEFAULT_WARMUP, params[3] || DEFAULT_TEARDOWN);
};

module.exports = {
    forall: forall
};
<commit_msg>remove unused testNumber from forall<commit_after>"use strict";
const jsc = require('jsverify');

var runall = async function(actions, state, model) {
    for (var idx = 0 ; idx != actions.length ; ++idx) {
        var ac = actions[idx];
        if (ac.check(model)) {
            ac.hasStarted = true;
            if (! await ac.run(state, model)) {
                return false;
            }
        }
    }
    return true;
};

var forallImpl = function(arbSeed, arbCommands, warmup, teardown) {
    return jsc.forall(arbSeed, arbCommands, async function(seed, commands) {
        var actions = commands.map(c => c.command);
        var {state, model} = await warmup(seed);
        var result = await runall(actions, state, model);
        await teardown();
        return result;
    });
};

var DEFAULT_SEED_GEN = jsc.constant(undefined);
var DEFAULT_WARMUP = seed => new Object({state: {}, model: {}});
var DEFAULT_TEARDOWN = () => {};

var isGenerator = function(obj) {
    return obj !== undefined && obj.generator !== undefined;
};
var forall = function(...params) {
    if (params.length === 0 || ! isGenerator(params[0])) {
        throw "forall requires at least a commands generator as first argument";
    }
    if (! isGenerator(params[1])) {
        return forallImpl(DEFAULT_SEED_GEN, params[0], params[1] || DEFAULT_WARMUP, params[2] || DEFAULT_TEARDOWN);
    }
    return forallImpl(params[0], params[1], params[2] || DEFAULT_WARMUP, params[3] || DEFAULT_TEARDOWN);
};

module.exports = {
    forall: forall
};

{'fraction_non_alphanumeric': 0.14131812420785805, 'fraction_numerical': 0.007287705956907478, 'mean_word_length': 2.6624129930394433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1264993', 'n_tokens_mistral': 968, 'n_tokens_neox': 965, 'n_words': 247}