<commit_before>(function(factory) {

  if (typeof define === 'function') {
    define(factory)
  }
  else if (typeof exports !== 'undefined') {
    factory(require, exports)
  }
  else {
    factory(null, (this['test'] = {}))
  }

})(function(require, exports) {


  exports.print = function(txt, style) {
    sendMessage('printResults', txt, style || 'info')
  }


  exports.assert = function (guard, message) {
    if (typeof message === 'undefined') {
      message = ''
    }

    if (guard) {
      exports.print('[PASS] ' + message, 'pass')
    } else {
      exports.print('[FAIL] ' + message, 'fail')
    }
  }


  exports.next = function() {
    setTimeout(function() {
      sendMessage('testNext')
    }, 500) // 留 500ms 空隙，使得异步操作能有时间完成。
  }


  exports.done = function() {
    exports.print('[DONE]')
    exports.next()
  }


  function error(err) {
    if (err !== 'Error loading script') {
      exports.print('[ERROR] ' + err, 'error')
    }

    exports.next()
  }


  // Catch errors
  if (typeof process !== 'undefined') {
    process.on('uncaughtException', error)
  }
  else {
    window.onerror = error
  }


  // Helpers
  // -------

  function sendMessage(fn, msg, type) {
    var p = this
    if (this != this.parent) {
      p = this.parent
    }

    if (p && p[fn]) {
      p[fn](msg, type)
    }
    else if (msg && typeof console !== 'undefined') {
      console.log(color(msg, type))
    }
  }

  // https://github.com/loopj/commonjs-ansi-color/blob/master/lib/ansi-color.js
  var ANSI_CODES = {
    'fail': 31, // red
    'error': 31, // red
    'pass': 32, // green
    'info': 36 // cyan
  }

  function color(str, type) {
    return '\033[' + ANSI_CODES[type] + 'm  ' + str + '\033[0m'
  }

});
<commit_msg>Add timeout for each test case<commit_after>(function(factory) {

  if (typeof define === 'function') {
    define(factory)
  }
  else if (typeof exports !== 'undefined') {
    factory(require, exports)
  }
  else {
    factory(null, (this['test'] = {}))
  }

})(function(require, exports) {


  exports.print = function(txt, style) {
    sendMessage('printResults', txt, style || 'info')
  }


  exports.assert = function (guard, message) {
    if (typeof message === 'undefined') {
      message = ''
    }

    if (guard) {
      exports.print('[PASS] ' + message, 'pass')
    } else {
      exports.print('[FAIL] ' + message, 'fail')
    }
  }


  exports.next = function() {
    setTimeout(function() {
      sendMessage('testNext')
    }, 500) // 留 500ms 空隙，使得异步操作能有时间完成。
  }


  exports.done = function() {
    exports.print('[DONE]')
    exports.next()
  }


  function error(err) {
    if (err !== 'Error loading script') {
      exports.print('[ERROR] ' + err, 'error')
    }

    exports.next()
  }


  // Catch errors
  if (typeof process !== 'undefined') {
    process.on('uncaughtException', error)
  }
  else {
    window.onerror = error

    // Set 10s timeout for each test case
    if (window != parent) {
      setTimeout(function() {
        error('time is out')
      }, 10000)
    }
  }


  // Helpers
  // -------

  function sendMessage(fn, msg, type) {
    var p = this
    if (this != this.parent) {
      p = this.parent
    }

    if (p && p[fn]) {
      p[fn](msg, type)
    }
    else if (msg && typeof console !== 'undefined') {
      console.log(color(msg, type))
    }
  }

  // https://github.com/loopj/commonjs-ansi-color/blob/master/lib/ansi-color.js
  var ANSI_CODES = {
    'fail': 31, // red
    'error': 31, // red
    'pass': 32, // green
    'info': 36 // cyan
  }

  function color(str, type) {
    return '\033[' + ANSI_CODES[type] + 'm  ' + str + '\033[0m'
  }

});

{'fraction_non_alphanumeric': 0.1820421571311251, 'fraction_numerical': 0.01341363263071448, 'mean_word_length': 2.3037974683544302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5779370', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1283, 'n_words': 274}