<commit_before>'use strict';

const {expect} = require('chai');;

const s = require('../spec');

const {isInt, isInteger, isString} = require('./utils');

describe('Test the or function', () => {
    it('should test the or of 1 spec', () => {
        s.def('::integer?', s.or(':x', isInteger));
        expect(s.isValid('::integer?', 12)).to.be.true;
        expect(s.isValid('::integer?', 'foobar')).to.be.false;
    });
    
    it('should test the or of 2 specs', () => {
        s.def('::name-or-id', s.or(':name', isString, ':id', isInt));
        expect(s.isValid('::name-or-id', 'abc')).to.be.true;
        expect(s.isValid('::name-or-id', 100)).to.be.true;
        expect(s.isValid('::name-or-id', 3.14)).to.be.false;
    });
});
<commit_msg>Annotate or spec<commit_after>'use strict';

const {expect} = require('chai');;

const s = require('../spec');

const {isInt, isInteger, isString} = require('./utils');

describe('Test the or function', () => {

    s.def('::name-or-id', s.or(':name', isString, ':id', isInt));

    it('should test the or of 1 spec', () => {
        s.def('::integer?', s.or(':x', isInteger));
        expect(s.isValid('::integer?', 12)).to.be.true;
        expect(s.isValid('::integer?', 'foobar')).to.be.false;
    });
    
    it('should test the or of 2 specs', () => {
        expect(s.isValid('::name-or-id', 'abc')).to.be.true;
        expect(s.isValid('::name-or-id', 100)).to.be.true;
        expect(s.isValid('::name-or-id', 3.14)).to.be.false;
    });

    it('should return tag name and conformed value', () => {
        expect(s.conform('::name-or-id', 'abc')).to.equal([]);
    });
});

{'fraction_non_alphanumeric': 0.2588739290085679, 'fraction_numerical': 0.012239902080783354, 'mean_word_length': 3.0671641791044775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '7603344', 'n_tokens_mistral': 613, 'n_tokens_neox': 598, 'n_words': 109}