<commit_before>'use strict';

var readJsonSync = require('./');
var test = require('tape');

test('readJsonSync()', function(t) {
  t.plan(6);

  t.equal(
    readJsonSync('package.json').name, 'read-json-sync',
    'should read and parse JSON file.'
  );

  t.throws(
    readJsonSync.bind(null, 'package.json', {encoding: 'foo'}),
    /Unknown encoding/,
    'should accept fs.readFileSync options.'
  );

  t.throws(
    readJsonSync.bind(null), /path/,
    'should throw an error when it takes no arguments.'
  );

  t.throws(
    readJsonSync.bind(null, 'package.json', true), /Bad/,
    'should throw an error when it takes invalid fs.readFileSync option.'
  );

  t.throws(
    readJsonSync.bind(null, 'foo'), /ENOENT/,
    'should throw an error when the file doesn\'t exist.'
  );

  t.throws(
    readJsonSync.bind(null, 'index.js'), /Unexpected token/,
    'should throw an error when the file is not a valid JSON.'
  );
});<commit_msg>update test<commit_after>'use strict';

var readJsonSync = require('./');
var test = require('tape');

test('readJsonSync()', function(t) {
  t.plan(8);

  t.equal(readJsonSync.name, 'readJsonSync', 'should have a function name.');

  t.equal(
    readJsonSync('package.json').name, 'read-json-sync',
    'should read and parse JSON file.'
  );

  t.throws(
    readJsonSync.bind(null, 'package.json', {encoding: 'foo'}),
    /Unknown encoding/,
    'should accept fs.readFileSync options.'
  );

  t.throws(
    readJsonSync.bind(null), /path/,
    'should throw an error when it takes no arguments.'
  );

  t.throws(
    readJsonSync.bind(null, 'package.json', true), /Bad/,
    'should throw an error when it takes invalid fs.readFileSync option.'
  );

  t.throws(
    readJsonSync.bind(null, 'foo', null), /ENOENT/,
    'should throw an error when the file doesn\'t exist.'
  );

  t.throws(
    readJsonSync.bind(null, 'node_modules', {}), /EISDIR/,
    'should throw an error when the path is a directory.'
  );

  t.throws(
    readJsonSync.bind(null, 'index.js', 'utf8'), /Unexpected token/,
    'should throw an error when the file is not a valid JSON.'
  );
});
{'fraction_non_alphanumeric': 0.15943396226415094, 'fraction_numerical': 0.0014150943396226414, 'mean_word_length': 3.267605633802817, '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': '2777818', 'n_tokens_mistral': 707, 'n_tokens_neox': 706, 'n_words': 200}