<commit_before>var util = require('util');
// Returns a function that takes a test and returns an iterator for copies
// of test for each scenario required.
// Currently only strictness is supported.
module.exports = function(opts) {
    return function(test) {
        return strictnessTests(test, opts);
    }
}

function strictnessTests(test, opts) {
    var tests = [];
    var index = 0;
    var copy;

    if(!test.attrs.flags.onlyStrict) {
        // BT: Enable by default once test262 is strict-clean.
        copy = util._extend({}, test);
        copy.attrs = util._extend({}, test.attrs);
        test.strictMode = false;
        tests.push(copy);
    }

    if(!test.attrs.flags.noStrict && opts.testStrict) {
        var copy = util._extend({}, test);
        copy.attrs = util._extend({}, test.attrs);
        copy.attrs.description += ' (Strict Mode)'
        copy.strictMode = true;
        tests.push(copy);
    }

    return {
        next: function() {
            if(index === tests.length) return { done: true }

            return { done: false, value: tests[index++] }
        }
    }
}
<commit_msg>Fix scenario expansion with onlyStrict flag<commit_after>var util = require('util');
// Returns a function that takes a test and returns an iterator for copies
// of test for each scenario required.
// Currently only strictness is supported.
module.exports = function(opts) {
    return function(test) {
        return strictnessTests(test, opts);
    }
}

function strictnessTests(test, opts) {
    var tests = [];
    var index = 0;
    var copy;

    if(!test.attrs.flags.onlyStrict) {
        // BT: Enable by default once test262 is strict-clean.
        copy = util._extend({}, test);
        copy.attrs = util._extend({}, test.attrs);
        test.strictMode = false;
        tests.push(copy);
    }

    if(test.attrs.flags.onlyStrict || (!test.attrs.flags.noStrict && opts.testStrict)) {
        var copy = util._extend({}, test);
        copy.attrs = util._extend({}, test.attrs);
        copy.attrs.description += ' (Strict Mode)'
        copy.strictMode = true;
        tests.push(copy);
    }

    return {
        next: function() {
            if(index === tests.length) return { done: true }

            return { done: false, value: tests[index++] }
        }
    }
}

{'fraction_non_alphanumeric': 0.1330732553099263, 'fraction_numerical': 0.0034677069787602947, 'mean_word_length': 2.3497822931785195, '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': '4354449', 'n_tokens_mistral': 677, 'n_tokens_neox': 662, 'n_words': 186}