<commit_before>var generate = require("../lib/6to5/generator");
var traverse = require("../lib/6to5/traverse");
var assert   = require("assert");
var util     = require("../lib/6to5/util");
var fs       = require("fs");
var _        = require("lodash");

var fixturesLoc = __dirname + "/fixtures/generation";

suite("generation", function () {
  test("completeness", function () {
    _.each(traverse.VISITOR_KEYS, function (keys, type) {
      assert.ok(!!generate.CodeGenerator.prototype[type], type + " should exist");
    });

    _.each(generate.CodeGenerator.prototype, function (fn, type) {
      if (!/[A-Z]/.test(type[0])) return;
      assert.ok(traverse.VISITOR_KEYS[type], type + " should not exist");
    });
  });

  _.each(fs.readdirSync(fixturesLoc), function (suiteName) {
    if (suiteName[0] === ".") return;

    var suiteLoc = fixturesLoc + "/" + suiteName;

    suite(suiteName, function () {
      _.each(fs.readdirSync(suiteLoc), function (testName) {
        if (testName[0] === ".") return;

        var testLoc = suiteLoc + "/" + testName;

        test(testName, function () {
          var expectedLoc = testLoc + "/expected.js";
          var actualLoc   = testLoc + "/actual.js";

          var expected = fs.readFileSync(expectedLoc, "utf8");
          var actual   = fs.readFileSync(actualLoc, "utf8");

          var actualAst = util.parseNoProperties(actualLoc, actual);
          actual        = generate(actualAst).code;
          actualAst     = util.parseNoProperties(actualLoc, actual);

          var expectedAst = util.parseNoProperties(expectedLoc, expected);

          assert.deepEqual(actualAst, expectedAst);
        });
      });
    });
  });
});<commit_msg>fix test generation actual ast<commit_after>var generate = require("../lib/6to5/generator");
var traverse = require("../lib/6to5/traverse");
var assert   = require("assert");
var util     = require("../lib/6to5/util");
var fs       = require("fs");
var _        = require("lodash");

var fixturesLoc = __dirname + "/fixtures/generation";

suite("generation", function () {
  test("completeness", function () {
    _.each(traverse.VISITOR_KEYS, function (keys, type) {
      assert.ok(!!generate.CodeGenerator.prototype[type], type + " should exist");
    });

    _.each(generate.CodeGenerator.prototype, function (fn, type) {
      if (!/[A-Z]/.test(type[0])) return;
      assert.ok(traverse.VISITOR_KEYS[type], type + " should not exist");
    });
  });

  _.each(fs.readdirSync(fixturesLoc), function (suiteName) {
    if (suiteName[0] === ".") return;

    var suiteLoc = fixturesLoc + "/" + suiteName;

    suite(suiteName, function () {
      _.each(fs.readdirSync(suiteLoc), function (testName) {
        if (testName[0] === ".") return;

        var testLoc = suiteLoc + "/" + testName;

        test(testName, function () {
          var expectedLoc = testLoc + "/expected.js";
          var actualLoc   = testLoc + "/actual.js";

          var expected = fs.readFileSync(expectedLoc, "utf8");
          var actual   = fs.readFileSync(actualLoc, "utf8");

          var actualAst = util.parseNoProperties(actualLoc, actual);
          actual        = generate(actual, actualAst).code;
          actualAst     = util.parseNoProperties(actualLoc, actual);

          var expectedAst = util.parseNoProperties(expectedLoc, expected);

          assert.deepEqual(actualAst, expectedAst);
        });
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.16138412329165455, 'fraction_numerical': 0.00639720849084036, 'mean_word_length': 2.865168539325843, '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': '307176', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1020, 'n_words': 205}