<commit_before>require('proof')(16, prove)

// Limited language that is ment to match specific entries in addition to
// winnowing by package and level. Select first by package name, then winnow by
// level or specifically by values in payload. Equality is coercive. Relative
// comparisons convert to numbers.
function prove (okay) {
    var Acceptor = require('..'), acceptor
    try {
    acceptor = new Acceptor(false, [{
        path: '.',
        test: [{ path: 'id', test: [{}] }]
    }])
    } catch (e) {
        okay(e.message, 'invalid test', 'invalid test')
    }
    acceptor = new Acceptor(false, [])
    okay(!acceptor.accept([{ qualifier: 'example' }]), 'default drop')
    acceptor = new Acceptor(true, [])
    okay(acceptor.accept([{ qualifier: 'example' }]), 'default accept')
    acceptor = new Acceptor(false, [{
        path: '.',
        level: 'warn',
        accept: true
    }, {
        path: '.example.timer',
        level: 'debug',
        accept: true
    }, {
        path: '.example.equals',
        test: [{ path: "[?tag == 'send']" }],
        accept: true
    }, {
        path: '.example.regex',
        test: [{ path: 'tag', regex: '/a/' }],
        accept: true
    }, {
        path: '.example.and',
        test: [{ path: 'id', regex: '/a/' }, { path: 'tag', equals: 'send' }],
        accept: true
    }])
    okay(acceptor.accept([{ qualifier: 'anything', level: 'err' }]), 'level')
    okay(!acceptor.accept([{ qualifier: 'anything', level: 'info' }]), 'level fail')
    okay(!acceptor.accept([{ qualifier: 'example.equals'}]), 'equals missing')
    okay(!acceptor.accept([{ qualifier: 'example.equals', tag: 'receive' }]), 'equals unequal')
    okay(!acceptor.accept([{ qualifier: 'example.equals', tag: [ 'receive' ] }]), 'equals not in array')
    okay(acceptor.accept([{ qualifier: 'example.equals', tag: 'send' }]), 'equals equal')
    okay(acceptor.accept([{ qualifier: 'example.equals', tag: [ 'send' ] }]), 'equals in array')
    okay(!acceptor.accept([{ qualifier: 'example.regex' }]), 'regex missing')
    okay(!acceptor.accept([{ qualifier: 'example.regex', tag: 'b' }]), 'regex fail')
    okay(!acceptor.accept([{ qualifier: 'example.regex', tag: [ 'b' ] }]), 'regex array fail')<commit_msg>Fix Acceptor test.<commit_after>require('proof')(16, prove)

// Limited language that is ment to match specific entries in addition to
// winnowing by package and level. Select first by package name, then winnow by
// level or specifically by values in payload. Equality is coercive. Relative
// comparisons convert to numbers.
function prove (okay) {
    var Acceptor = require('..'), acceptor
    try {
    acceptor = new Acceptor(false, [{
        path: '.',
        test: [{ path: 'id', test: [{}] }]
    }])
    } catch (e) {
        okay(e.message, 'invalid test', 'invalid test')
    }
    acceptor = new Acceptor(false, [])
    okay(!acceptor.accept([{ qualifier: 'example' }]), 'default drop')
    acceptor = new Acceptor(true, [])
    okay(acceptor.accept([{ qualifier: 'example' }]), 'default accept')
    acceptor = new Acceptor(false, [{
        path: '.',
        level: 'warn',
        accept: true
    }, {
        path: '.example.timer',
        level: 'debug',
        accept: true
    }, {
        path: '.example.equals',
        test: [{ path: 'tag', equals: 'send' }],
        accept: true
    }, {
        path: '.example.regex',
        test: [{ path: 'tag', regex: '/a/' }],
        accept: true
    }, {
        path: '.example.and',
        test: [{ path: 'id', regex: '/a/' }, { path: 'tag', equals: 'send' }],
        accept: true
    }])
    okay(acceptor.accept([{ qualifier: 'anything', level: 'err' }]), 'level')
    okay(!acceptor.accept([{ qualifier: 'anything', level: 'info' }]), 'level fail')
    okay(!acceptor.accept([{ qualifier: 'example.equals'}]), 'equals missing')
    okay(!acceptor.accept([{ qualifier: 'example.equals', tag: 'receive' }]), 'equals unequal')
    okay(!acceptor.accept([{ qualifier: 'example.equals', tag: [ 'receive' ] }]), 'equals not in array')
    okay(acceptor.accept([{ qualifier: 'example.equals', tag: 'send' }]), 'equals equal')
    okay(acceptor.accept([{ qualifier: 'example.equals', tag: [ 'send' ] }]), 'equals in array')
    okay(!acceptor.accept([{ qualifier: 'example.regex' }]), 'regex missing')
    okay(!acceptor.accept([{ qualifier: 'example.regex', tag: 'b' }]), 'regex fail')
    okay(!acceptor.accept([{ qualifier: 'example.regex', tag: [ 'b' ] }]), 'regex array fail')
{'fraction_non_alphanumeric': 0.1950244335850733, 'fraction_numerical': 0.000888494002665482, 'mean_word_length': 3.078804347826087, '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': '1190808', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1417, 'n_words': 390}