<commit_before>var path = require('path');
var util = require('util');
var _ = require('underscore');
var test = require('tap').test;
var yaml = require('./yaml');


// Test that only provides JS repr.
exports.withJs = function(name, js) {
  exports.dumpAndLoad(name, js);
};

// Test that provides both YAML and JS repr.
exports.withYamlAndJs = function(name, js) {
  exports.load(name, js);
  exports.dumpAndLoad(name, js);
};


// Load YAML and compare with expected JS repr.
exports.load = function(name, tags, expected) {
  if (expected === undefined) {
    expected = tags;
    tags = undefined;
  }

  test(name, function(t) {
    var file = path.resolve(module.filename, '..', 'tests', name + '.yaml');
    var input = yaml.loadFileSync(file, tags);

    t.ok(_.isEqual(input, expected), 'load YAML', {
      input: input,
      expected: util.inspect(expected)
    });
    t.end();
  });
};


// Dump JS to YAML, load again, and compare the two.
exports.dumpAndLoad = function(name, input) {
  test(name, function(t) {
    var data = yaml.dump.apply(null, input);
    var output = yaml.load(data);
    t.ok(_.isEqual(input, output), 'dump & load YAML', {
      inputJs: util.inspect(input),
      yaml: data,
      outputJs: util.inspect(output)
    });
    t.end();
  });
};<commit_msg>Better formatting of test 'load' failure.<commit_after>var path = require('path');
var util = require('util');
var _ = require('underscore');
var test = require('tap').test;
var yaml = require('./yaml');


// Test that only provides JS repr.
exports.withJs = function(name, js) {
  exports.dumpAndLoad(name, js);
};

// Test that provides both YAML and JS repr.
exports.withYamlAndJs = function(name, js) {
  exports.load(name, js);
  exports.dumpAndLoad(name, js);
};


// Load YAML and compare with expected JS repr.
exports.load = function(name, tags, expected) {
  if (expected === undefined) {
    expected = tags;
    tags = undefined;
  }

  test(name, function(t) {
    var file = path.resolve(module.filename, '..', 'tests', name + '.yaml');
    var input = yaml.loadFileSync(file, tags);

    t.ok(_.isEqual(input, expected), 'load YAML', {
      input: util.inspect(input),
      expected: util.inspect(expected)
    });
    t.end();
  });
};


// Dump JS to YAML, load again, and compare the two.
exports.dumpAndLoad = function(name, input) {
  test(name, function(t) {
    var data = yaml.dump.apply(null, input);
    var output = yaml.load(data);
    t.ok(_.isEqual(input, output), 'dump & load YAML', {
      inputJs: util.inspect(input),
      yaml: data,
      outputJs: util.inspect(output)
    });
    t.end();
  });
};
{'fraction_non_alphanumeric': 0.1662870159453303, 'fraction_numerical': 0.0, 'mean_word_length': 3.3338815789473686, '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': '2164724', 'n_tokens_mistral': 909, 'n_tokens_neox': 866, 'n_words': 233}