<commit_before>
var sl = require('..');

var list = [
    { id: 1, name: 'Adam', age: 800, gender: 'man' },
    { id: 2, name: 'Eve', age: 600, gender: 'woman' },
    { id: 3, name: 'Abel', age: 500, gender: 'man' },
    { id: 4, name: 'Caine', age: 400, gender: 'man' }
];

exports['filter gender is man'] = function (test) {
    var result = sl.filter(list, { gender: 'man' });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 3);
    
    for (var k = 0; k < result.length; k++)
        test.equal(result[k].gender, 'man');
}

exports['filter gender is woman'] = function (test) {
    var result = sl.filter(list, { gender: 'woman' });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 1);
    
    for (var k = 0; k < result.length; k++)
        test.equal(result[k].gender, 'woman');
}

exports['filter id is five'] = function (test) {
    var result = sl.filter(list, { id: 5 });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 0);
}

exports['filter id is three and gender is man'] = function (test) {
    var result = sl.filter(list, { id: 3, gender: 'man' });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 1);
    
    test.equal(result[0].id, 3);
    test.equal(result[0].gender, 'man');
}

exports['filter with function'] = function (test) {
    var result = sl.filter(list, function (item) {
        if (item.id % 2)
            return true;
        return false;
    });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 2);
    
    test.equal(result[0].id, 1);
    test.equal(result[1].id, 3);
}

<commit_msg>Filter tests refactor<commit_after>
const sl = require('..');

const list = [
    { id: 1, name: 'Adam', age: 800, gender: 'man' },
    { id: 2, name: 'Eve', age: 600, gender: 'woman' },
    { id: 3, name: 'Abel', age: 500, gender: 'man' },
    { id: 4, name: 'Caine', age: 400, gender: 'man' }
];

exports['filter gender is man'] = function (test) {
    const result = sl.filter(list, { gender: 'man' });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 3);
    
    for (let k = 0; k < result.length; k++)
        test.equal(result[k].gender, 'man');
}

exports['filter gender is woman'] = function (test) {
    const result = sl.filter(list, { gender: 'woman' });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 1);
    
    for (let k = 0; k < result.length; k++)
        test.equal(result[k].gender, 'woman');
}

exports['filter id is five'] = function (test) {
    const result = sl.filter(list, { id: 5 });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 0);
}

exports['filter id is three and gender is man'] = function (test) {
    const result = sl.filter(list, { id: 3, gender: 'man' });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 1);
    
    test.equal(result[0].id, 3);
    test.equal(result[0].gender, 'man');
}

exports['filter with function'] = function (test) {
    const result = sl.filter(list, function (item) {
        if (item.id % 2)
            return true;
        
        return false;
    });
    
    test.ok(result);
    test.ok(Array.isArray(result));
    test.equal(result.length, 2);
    
    test.equal(result[0].id, 1);
    test.equal(result[1].id, 3);
}


{'fraction_non_alphanumeric': 0.1821173889193637, 'fraction_numerical': 0.018102029621503018, 'mean_word_length': 2.392558139534884, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2304429', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1262, 'n_words': 304}