<commit_before>var dependencies = {
  assert: require('assert'),
  escapeRegexString: require('../index'),
};

describe('escape-regex-string', function() {
  
  it('should escape regular expression tokens within a string literal', function() {
    dependencies.assert.strictEqual(
      dependencies.escapeRegexString('- | \\ { } ( ) [ ] ^ $ + * ? .'), 
      '\\- \\| \\\\ \\{ \\} \\( \\) \\[ \\] \\^ \\$ \\+ \\* \\? \\.'
    );
    dependencies.assert.strictEqual(
      dependencies.escapeRegexString('(Phobetron pithecium)'), 
      '\\(Phobetron pithecium\\)'
    );
  });
  
  it('should use optional RegExp argument when passed instead of default', function() {
    // Remove the hyphen character from the regex pattern.
    dependencies.assert.strictEqual(
      dependencies.escapeRegexString('- | \\ { } ( ) [ ] ^ $ + * ? .', /[|\\{}()[\]^$+*?.]/g), 
      '- \\| \\\\ \\{ \\} \\( \\) \\[ \\] \\^ \\$ \\+ \\* \\? \\.'
    );
  });
  
  it('should not accept invalid arguments', function() {
    try {
      dependencies.escapeRegexString(42);
      throw new Error('Invalid first (string) argument passed but no exception thrown.');
    }
    catch (exceptionObject) {}
    try {
      dependencies.escapeRegexString('dik-dik', 42);
      throw new Error('Invalid second (RegExp) argument passed but no exception thrown.');
    }
    catch (exceptionObject) {}
  });
  
  describe('#defaultEscapeCharsRegex', function() {
    
    it('should be a non-configurable property', function() {
      try {
        dependencies.escapeRegexString.defaultEscapeCharsRegex = 3.14;
        throw new Error('Property value was changed during runtime.');
      }
      catch (exceptionObject) {}
    });
    
    it('should contain a readable RegExp object', function() {
      dependencies.assert.strictEqual(
        Object.prototype.toString.call(dependencies.escapeRegexString.defaultEscapeCharsRegex),
        '[object RegExp]'
      );
    });
    
  });
  
});<commit_msg>Very minor change. Slightly edited comment wording.<commit_after>var dependencies = {
  assert: require('assert'),
  escapeRegexString: require('../index'),
};

describe('escape-regex-string', function() {
  
  it('should escape regular expression tokens within a string literal', function() {
    dependencies.assert.strictEqual(
      dependencies.escapeRegexString('- | \\ { } ( ) [ ] ^ $ + * ? .'), 
      '\\- \\| \\\\ \\{ \\} \\( \\) \\[ \\] \\^ \\$ \\+ \\* \\? \\.'
    );
    dependencies.assert.strictEqual(
      dependencies.escapeRegexString('(Phobetron pithecium)'), 
      '\\(Phobetron pithecium\\)'
    );
  });
  
  it('should use optional RegExp argument when passed instead of default', function() {
    // Remove the hyphen character from the regex pattern.
    dependencies.assert.strictEqual(
      dependencies.escapeRegexString('- | \\ { } ( ) [ ] ^ $ + * ? .', /[|\\{}()[\]^$+*?.]/g), 
      '- \\| \\\\ \\{ \\} \\( \\) \\[ \\] \\^ \\$ \\+ \\* \\? \\.'
    );
  });
  
  it('should not accept invalid arguments', function() {
    /**
     * Define locally-scoped function to catch TypeError exceptions in the following tests.
     * @param exceptionObject Object constructed by Error or a descendant.
     * @return undefined
     */
    function rethrowExceptionIfNotTypeError(exceptionObject) {
      // Depending on short-circuit evaluation in condition.
      if (Object.prototype.toString.call(exceptionObject) !== '[object Error]'
        || exceptionObject instanceof TypeError === false
      ) {
        throw exceptionObject;
      }
    }
    
    // Attempt to pass invalid first argument.
    try {
      dependencies.escapeRegexString(42);
      throw new Error('Invalid first (string) argument passed but no exception thrown.');
    }
    catch (exceptionObject) {
      rethrowExceptionIfNotTypeError(exceptionObject);
    }
    // Attempt to pass invalid second argument.
    try {
      dependencies.escapeRegexString('dik-dik', 42);
      throw new Error('Invalid second (RegExp) argument passed but no exception thrown.');
    }
    catch (exceptionObject) {
      rethrowExceptionIfNotTypeError(exceptionObject);
    }
  });
  
  describe('.defaultEscapeCharsRegex', function() {
    
    it('should be a non-configurable property', function() {
      dependencies.escapeRegexString.defaultEscapeCharsRegex = 3.14;
      dependencies.assert.notStrictEqual(
        dependencies.escapeRegexString.defaultEscapeCharsRegex,
        3.14
      );
    });
    
    it('should contain a readable RegExp object', function() {
      dependencies.assert.strictEqual(
        Object.prototype.toString.call(dependencies.escapeRegexString.defaultEscapeCharsRegex),
        '[object RegExp]'
      );
    });
    
  });
  
});
{'fraction_non_alphanumeric': 0.16469594594594594, 'fraction_numerical': 0.0035895270270270272, 'mean_word_length': 2.5536384096024007, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4910101', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1318, 'n_words': 284}