<commit_before>var subject = require('..');
var assert = require('assert');

describe('patterns', function() {
  it('exposes the default patterns', function() {
    assert.equal(typeof subject.patterns['p'], 'function');
    assert.equal(typeof subject.patterns['f'], 'function');
    assert.equal(typeof subject.patterns['n'], 'function');
    assert.equal(typeof subject.patterns['d'], 'function');
    assert.equal(typeof subject.patterns['x'], 'function');
    assert.equal(typeof subject.patterns['X'], 'function');
    assert.equal(typeof subject.patterns['s'], 'function');
    assert.equal(typeof subject.patterns['%'], 'function');
  });
  it('throws if an undefined pattern is given', function() {
    assert.throws(function() {
      subject(__filename, '%q');
    }, 'Unknown pathmap specifier q in "%q"');
  });
});<commit_msg>Test adding new patterns<commit_after>var subject = require('..');
var assert = require('assert');

describe('patterns', function() {
  it('exposes the default patterns', function() {
    assert.equal(typeof subject.patterns['p'], 'function');
    assert.equal(typeof subject.patterns['f'], 'function');
    assert.equal(typeof subject.patterns['n'], 'function');
    assert.equal(typeof subject.patterns['d'], 'function');
    assert.equal(typeof subject.patterns['x'], 'function');
    assert.equal(typeof subject.patterns['X'], 'function');
    assert.equal(typeof subject.patterns['s'], 'function');
    assert.equal(typeof subject.patterns['%'], 'function');
  });
  it('throws if an undefined pattern is given', function() {
    assert.throws(function() {
      subject('a/b/c/d/file.txt', '%q');
    }, 'Unknown pathmap specifier q in "%q"');
  });
  it('allows new patterns to be added', function() {
    subject.patterns['z'] = function() {
      return 'ZZZ';
    };
    assert.equal(subject('a/b/c/d/file.txt', '%d/%z%x'), 'a/b/c/d/ZZZ.txt');
    delete subject.patterns['z'];
  });
});
{'fraction_non_alphanumeric': 0.20392359318533815, 'fraction_numerical': 0.0, 'mean_word_length': 4.633720930232558, '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': '7102737', 'n_tokens_mistral': 584, 'n_tokens_neox': 580, 'n_words': 127}