<commit_before>'use strict';

var Assertion = require('../../model/assertion');
var ParameterizedAssertion = require('../../model/parameterized-assertion');
var Alias = require('../../model/alias');

var NoDSL = require('../../utils/nodsl');

var nodsl = { check: new NoDSL('ArgumentError').check };

module.exports = {
  'matches': new ParameterizedAssertion(function(context, regexp) {
    nodsl.check(
      typeof regexp === 'string' || regexp instanceof RegExp,
      'regexp must be an instance of RegExp or a string'
    );
    regexp = regexp instanceof RegExp
      ? regexp
      : new RegExp(regexp)
    ;
    this.message
      .appendText('matching')
      .appendText('/'+ regexp.source +'/'+ regexp.flags)
    ;
    return function hasProperType() {
      return regexp.test(context._value);
    };
  }),
  'matchesRegexp': new Alias('matches'),
  'matchesRegExp': new Alias('matches'),
  'match': new Alias('matches'),

  'anEmail': new Assertion(function(context) {
    this.message.appendText('an email');

    context._push();
    context.matches(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i);
    context._pop();
  }),
  'Email': new Alias('anEmail'),
  'email': new Alias('anEmail'),
};
<commit_msg>~ fixed message of .matches assertion in node4<commit_after>'use strict';

var Assertion = require('../../model/assertion');
var ParameterizedAssertion = require('../../model/parameterized-assertion');
var Alias = require('../../model/alias');

var NoDSL = require('../../utils/nodsl');

var nodsl = { check: new NoDSL('ArgumentError').check };

module.exports = {
  'matches': new ParameterizedAssertion(function(context, regexp) {
    nodsl.check(
      typeof regexp === 'string' || regexp instanceof RegExp,
      'regexp must be an instance of RegExp or a string'
    );
    regexp = regexp instanceof RegExp
      ? regexp
      : new RegExp(regexp)
    ;
    this.message
      .appendText('matching')
      .appendText('/'+ regexp.source +'/'+ (regexp.flags || ''))
    ;
    return function hasProperType() {
      return regexp.test(context._value);
    };
  }),
  'matchesRegexp': new Alias('matches'),
  'matchesRegExp': new Alias('matches'),
  'match': new Alias('matches'),

  'anEmail': new Assertion(function(context) {
    this.message.appendText('an email');

    context._push();
    context.matches(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i);
    context._pop();
  }),
  'Email': new Alias('anEmail'),
  'email': new Alias('anEmail'),
};

{'fraction_non_alphanumeric': 0.1907070707070707, 'fraction_numerical': 0.0052525252525252525, 'mean_word_length': 3.351493848857645, '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': '6419128', 'n_tokens_mistral': 808, 'n_tokens_neox': 798, 'n_words': 169}