<commit_before>_unitTests = [];
_unitTestsResults = [];
_unitTestsMessages = [];

function unitTestWriter() {}
unitTestWriter.addResult = function( result ) {
  _unitTestsResults.push( result );
}
unitTestWriter.addMessage = function( observed, expected, message ) {
  _unitTestsMessages.push( {
      observed : observed,
      expected : expected,
      message : message
  } );
}
unitTestWriter.print = function () {
  var buffer = '';
  var iteration = 0;
  for ( var i = 0; i < _unitTestsResults.length; i++ ) {
    iteration++;
    buffer += _unitTestsResults[i];

    if ( iteration > 10 ) {
      console.log( buffer );  
      iteration = 0;
      buffer = '';
    }
  }

  if ( buffer !== '' ) {
    console.log( buffer );  
  }

  if ( _unitTestsMessages.length > 0 ) {
    for ( var i = 0; i < _unitTestsMessages.length; i++ ) {
      var result = _unitTestsMessages[i];
      console.log( result.message + ' Expected ' + result.expected + ' got ' + result.observed );
    }  
  } else {
    console.log( 'All tests passed!' );
  }
}

function isAUnitTest() {
  this.setup    = function () {};
  this.teardown = function () {};

  this.assertValueEqualsExpected = function ( observed, expected, message ) {
    if ( observed !== expected ) {
      message = message ? message : '';
      unitTestWriter.addMessage( observed, expected, message );
      return -1;
    }
  }

  _unitTests.push( this );
}

function runUnitTests() {
  for ( var i = 0; i < _unitTests.length; i++ ) {
    var test = _unitTests[i];

    test.setup();

    for ( var part in test ) {
      if ( test.hasOwnProperty( part ) ) {
        if ( typeof test[part] === 'function' && 
             part.indexOf('test') === 0 ) {
          var good = test[part]();

          if ( good === false ) {
            unitTestWriter.addResult( 'F' );
          } else {
            unitTestWriter.addResult( '.' );  
          }
        }
      }
    }

    test.teardown();
  }

  unitTestWriter.print();
}<commit_msg>Have unit tests clean up after being run<commit_after>_unitTests = [];
_unitTestsResults = [];
_unitTestsMessages = [];

function unitTestWriter() {}
unitTestWriter.addResult = function( result ) {
  _unitTestsResults.push( result );
}
unitTestWriter.addMessage = function( observed, expected, message ) {
  _unitTestsMessages.push( {
      observed : observed,
      expected : expected,
      message : message
  } );
}
unitTestWriter.print = function () {
  var buffer = '';
  var iteration = 0;
  for ( var i = 0; i < _unitTestsResults.length; i++ ) {
    iteration++;
    buffer += _unitTestsResults[i];

    if ( iteration > 10 ) {
      console.log( buffer );  
      iteration = 0;
      buffer = '';
    }
  }

  if ( buffer !== '' ) {
    console.log( buffer );  
  }

  if ( _unitTestsMessages.length > 0 ) {
    for ( var i = 0; i < _unitTestsMessages.length; i++ ) {
      var result = _unitTestsMessages[i];
      console.log( result.message + ' Expected ' + result.expected + ' got ' + result.observed );
    }  
  } else {
    console.log( 'All tests passed!' );
  }
}

function isAUnitTest() {
  this.setup    = function () {};
  this.teardown = function () {};

  this.assertValueEqualsExpected = function ( observed, expected, message ) {
    if ( observed !== expected ) {
      message = message ? message : '';
      unitTestWriter.addMessage( observed, expected, message );
      return -1;
    }
  }

  _unitTests.push( this );
}

function runUnitTests() {
  for ( var i = 0; i < _unitTests.length; i++ ) {
    var test = _unitTests[i];

    test.setup();

    for ( var part in test ) {
      if ( test.hasOwnProperty( part ) ) {
        if ( typeof test[part] === 'function' && 
             part.indexOf('test') === 0 ) {
          var good = test[part]();

          if ( good === false ) {
            unitTestWriter.addResult( 'F' );
          } else {
            unitTestWriter.addResult( '.' );  
          }
        }
      }
    }

    test.teardown();
  }

  unitTestWriter.print();

  // Clean up
  _unitTests = [];
  _unitTestsMessages = [];
  _unitTestsResults = [];
}
{'fraction_non_alphanumeric': 0.14682926829268292, 'fraction_numerical': 0.004878048780487805, 'mean_word_length': 2.331437855402112, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '7459148', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1262, 'n_words': 290}