<commit_before>'use strict';

const fs = require('fs');
const path = require('path');
const async = require('async');

// Enable should on Object prototype
const should = require('should');

const parser = require('../../build/grammar.js');

const BASE = './test/grammar/';

describe('The parser', function() {

  let files = [];

  // We want to compare compiled setlX files with matching js files
  const rfiles = fs.readdirSync(path.join(BASE, 'files')).map(path.parse);


  // Split setlX and JS files
  let setlx = rfiles
    .filter(e => e.ext === '.stlx')
    .map(e => e.name);
  let js = rfiles
    .filter(e => e.ext === '.js')
    .map(e => e.name);

  // add files to list, when both - setlX and JS - are present
  setlx.forEach(e => {
    if(js.indexOf(e) >= 0) {
      files.push( e );
    }
  });

  files.forEach(( file ) => {
    it('should transpile ' + file + ' correctly', done => {
      async.map([
          path.join(BASE, 'files', file + '.stlx'),
          path.join(BASE, 'files', file + '.js')
        ],
        fs.readFile,
        (err, arr) => {
          if ( err ) throw err;

          let setlxCode = arr[0].toString();
          let jsCode = arr[1].toString().replace(/\r\n/g, '\n');

          let parsed = parser.parse(setlxCode);

          parsed.should.be.ok().and.a.String();
          parsed.should.equal(jsCode);

          done();
        }<commit_msg>improve coding style and fix eslint errors<commit_after>'use strict';

const fs = require('fs');
const path = require('path');
const async = require('async');

// Enable should on Object prototype
require('should');

const parser = require('../../build/grammar.js');

const BASE = './test/grammar/';

describe('The parser', function() {

  const files = [];

  // We want to compare compiled setlX files with matching js files
  const rfiles = fs.readdirSync(path.join(BASE, 'files')).map(path.parse);


  // Split setlX and JS files
  const setlx = rfiles
    .filter( file => file.ext === '.stlx' )
    .map( file => file.name );
  const js = rfiles
    .filter( file => file.ext === '.js' )
    .map( file => file.name );

  // add files to list, when both - setlX and JS - are present
  setlx.forEach(fileName => {
    if ( js.indexOf(fileName) >= 0 ) {
      files.push( fileName );
    }
  });

  files.forEach(file => {
    it('should transpile ' + file + ' correctly', done => {
      async.map([
        path.join(BASE, 'files', file + '.stlx'),
        path.join(BASE, 'files', file + '.js'),
      ],
        fs.readFile,
        (err, arr) => {
          if ( err ) throw err;

          const setlxCode = arr[0].toString();
          const jsCode = arr[1].toString().replace(/\r\n/g, '\n');

          const parsed = parser.parse(setlxCode);

          parsed.should.be.ok().and.a.String();
          parsed.should.equal(jsCode);

          done();
        }
{'fraction_non_alphanumeric': 0.17845939351690485, 'fraction_numerical': 0.0020913210177762286, 'mean_word_length': 2.3256083429895713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '2858434', 'n_tokens_mistral': 948, 'n_tokens_neox': 913, 'n_words': 244}