<commit_before>/*global describe, it, browser, expect, exports */
/*eslint-env node */
/*eslint strict: ["error", "global"] */
'use strict';
var fs = require('fs');

function load(file) {
    var contents = fs.readFileSync(__dirname + '/' + file);
    return JSON.parse(contents);
}

function buildAttribute(element) {
    if (element instanceof Array) {
        return element.map(function (element) {
            return buildAttribute(element);
        }).join('');
    } else {
        return '[data-k-b-testhook-' + element.type + '="' + element.value + '"]';
    }
}
function buildSelector(path) {
    return path.map(function (element) {
        return buildAttribute(element);
    }).join(' ');
}
function extend(path, elements) {
    var newPath = path.map(function (el) {
        return el;
    });
    elements.forEach(function (element) {
        newPath.push(element);
    });
    return newPath;
}
function makeSelector(base, selector) {
    if (selector instanceof Array) {
        selector = {
            type: 'relative',
            path: selector
        };
    }
    var fullPath;
    switch (selector.type) {
    case 'relative':
        fullPath = extend(base, selector.path);
        break;
    case 'absolute':
        fullPath = selector.path;
        break;
    }
    return buildSelector(fullPath);
   
}
function info() {
    let args = Array.prototype.slice.call(arguments);
    process.stdout.write(args.join(' ') + '\n');
}
function doTask(spec, task, testData) {
    if (task.selector) {
        var selector = makeSelector(spec.baseSelector, task.selector);
        var result = true;
        if (task.wait) {
            result = browser.waitForExist(selector, task.wait);
        } if (task.waitForText) {
            result = browser.waitForText(selector, task.waitForText);
        } else if (task.waitUntilText) {
            result = browser.waitUntil(function () {
                try {
                    var text = browser.getText(selector);
                    return (text === task.waitUntilText.value);
                } catch (ex) {
                    return false;
                }
            }, task.waitUntilText.wait);
        } else if (task.exists) {
            result = browser.isExisting(selector);
            expect(result).toBe(true);
        }

        if (!result) {
            return;
        }

        // only proceed with a further action if succeeded so far.
        if (task.text) {
            let text = browser.getText(selector);
            expect(text).toEqual(task.text);
        } else if (task.match) {
            let toMatch = browser.getText(selector);
            expect(toMatch).toMatch(new RegExp(task.text));
        } else if (task.number) {
            let toCompare = browser.getText(selector);
            expect(toCompare).toBeDefined();
            let theNumber = Number(toCompare.replace(/,/g, ''));
           
            Object.keys(task.number).forEach(function (comparison) {
                var comparisonValue = task.number[comparison];
                switch (comparison) {
                case 'greaterThan':
                    expect(theNumber).toBeGreaterThan(comparisonValue);
                    break;
                case 'greaterThanOrEqual':
                    expect(theNumber).toBeGreaterThanOrEqual(comparisonValue);
                    break;                    
                case 'lessThan':
                    expect(theNumber).toBeLessThan(comparisonValue);
                    break;
                case 'lessThanOrEqual':
                    expect(theNumber).toBeLessThanOrEqual(comparisonValue);
                    break;                    
                case 'equal':
                    expect(theNumber).toEqual(comparisonValue);
                    break;                
                }
            });
        }

        // Actions
        if (task.action) {
            switch (task.action) {<commit_msg>add test condition for node count for selector [SCT-644] - supports, e.g., a given # of repeated items occuring<commit_after>/*global describe, it, browser, expect, exports */
/*eslint-env node */
/*eslint strict: ["error", "global"] */
'use strict';
var fs = require('fs');

function load(file) {
    var contents = fs.readFileSync(__dirname + '/' + file);
    return JSON.parse(contents);
}

function buildAttribute(element) {
    if (element instanceof Array) {
        return element.map(function (element) {
            return buildAttribute(element);
        }).join('');
    } else {
        return '[data-k-b-testhook-' + element.type + '="' + element.value + '"]';
    }
}
function buildSelector(path) {
    return path.map(function (element) {
        return buildAttribute(element);
    }).join(' ');
}
function extend(path, elements) {
    var newPath = path.map(function (el) {
        return el;
    });
    elements.forEach(function (element) {
        newPath.push(element);
    });
    return newPath;
}
function makeSelector(base, selector) {
    if (selector instanceof Array) {
        selector = {
            type: 'relative',
            path: selector
        };
    }
    var fullPath;
    switch (selector.type) {
    case 'relative':
        fullPath = extend(base, selector.path);
        break;
    case 'absolute':
        fullPath = selector.path;
        break;
    }
    return buildSelector(fullPath);
   
}
function info() {
    let args = Array.prototype.slice.call(arguments);
    process.stdout.write(args.join(' ') + '\n');
}
function doTask(spec, task, testData) {
    if (task.selector) {
        var selector = makeSelector(spec.baseSelector, task.selector);
        var result = true;
        if (task.wait) {
            result = browser.waitForExist(selector, task.wait);
        } if (task.waitForText) {
            result = browser.waitForText(selector, task.waitForText);
        } else if (task.waitUntilText) {
            result = browser.waitUntil(function () {
                try {
                    var text = browser.getText(selector);
                    return (text === task.waitUntilText.value);
                } catch (ex) {
                    return false;
                }
            }, task.waitUntilText.wait);
        } else if (task.exists) {
            result = browser.isExisting(selector);
            expect(result).toBe(true);
        }

        if (!result) {
            return;
        }

        // only proceed with a further action if succeeded so far.
        if (task.text) {
            let text = browser.getText(selector);
            expect(text).toEqual(task.text);
        } else if (task.match) {
            let toMatch = browser.getText(selector);
            expect(toMatch).toMatch(new RegExp(task.text));
        } else if (task.number) {
            let toCompare = browser.getText(selector);
            expect(toCompare).toBeDefined();
            let theNumber = Number(toCompare.replace(/,/g, ''));
           
            Object.keys(task.number).forEach(function (comparison) {
                var comparisonValue = task.number[comparison];
                switch (comparison) {
                case 'greaterThan':
                    expect(theNumber).toBeGreaterThan(comparisonValue);
                    break;
                case 'greaterThanOrEqual':
                    expect(theNumber).toBeGreaterThanOrEqual(comparisonValue);
                    break;                    
                case 'lessThan':
                    expect(theNumber).toBeLessThan(comparisonValue);
                    break;
                case 'lessThanOrEqual':
                    expect(theNumber).toBeLessThanOrEqual(comparisonValue);
                    break;                    
                case 'equal':
                    expect(theNumber).toEqual(comparisonValue);
                    break;                
                }
            });
        } else if (task.count) {
            // count the elements which matched this selector
            let toCompare = browser.elements(selector).value.length;
            expect(toCompare).toBeDefined();
           
            Object.keys(task.count).forEach(function (comparison) {
                var comparisonValue = task.count[comparison];
                switch (comparison) {
                case 'greaterThan':
                    expect(toCompare).toBeGreaterThan(comparisonValue);
                    break;
                case 'greaterThanOrEqual':
                    expect(toCompare).toBeGreaterThanOrEqual(comparisonValue);
                    break;                    
                case 'lessThan':
                    expect(toCompare).toBeLessThan(comparisonValue);
                    break;
                case 'lessThanOrEqual':
                    expect(toCompare).toBeLessThanOrEqual(comparisonValue);
                    break;                    
                case 'equal':
                    expect(toCompare).toEqual(comparisonValue);
                    break;                
                }
            });
        }

        // Actions
        if (task.action) {
            switch (task.action) {
{'fraction_non_alphanumeric': 0.1137109118740433, 'fraction_numerical': 0.0003280122457905095, 'mean_word_length': 1.6307161345987922, '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': '3095404', 'n_tokens_mistral': 2382, 'n_tokens_neox': 2268, 'n_words': 487}