<commit_before>require('source-map-support').install()

var ava = require('ava')
var sinon = require('sinon')
var Promise = require('bluebird')

Promise.longStackTraces()

var wrap = function (fn) {
  return function (t) {
    // a sinon sandbox for spies, stubs and mocks
    var sandbox = sinon.sandbox.create({
      injectInto: t,
      properties: ['spy', 'stub', 'mock']
    })

    // returning a promise makes AVA run it asynchronously
    return Promise.method(fn)(t).then(() => {
      // Only verify sandbox if we didn't get another response
      sandbox.verifyAndRestore()
    }).catch((e) => {
      if (e && e.stack) {
        var lines = e.stack.split('\n')
        var i = 0
        var out = ''

        // find first zopf occurence in stack trace
        while (i < lines.length) {
          var line = lines[i]
          if (/node_modules.zopf/.test(line)) {
            i--
            break
          }
          i++
        }

        throw lines.slice(0, i).filter(function (x) {
          return !/node_modules.bluebird/.test(x)
        }).join('\n')
      } else {
        throw e
      }
    })
  }
}

/**
 * Ran concurrently, write tests accordingly!
 */
var zopf = function (title, fn) {
  if (typeof title !== 'string') {
    fn = title
    title = null
  }

  ava(title, wrap(fn))
}

/**
 * To use as a last resort, when mocking global resources -
 * usually a sign of test smell
 */
zopf.serial = function (title, fn) {
  if (typeof title !== 'string') {
    fn = title
    title = null
  }

  ava.serial(title, wrap(fn))
}

module.exports = zopf
<commit_msg>:lipstick:<commit_after>require('source-map-support').install()

var ava = require('ava')
var sinon = require('sinon')
var Promise = require('bluebird')

Promise.longStackTraces()

var wrap = function (fn) {
  return function (t) {
    // a sinon sandbox for spies, stubs and mocks
    var sandbox = sinon.sandbox.create({
      injectInto: t,
      properties: ['spy', 'stub', 'mock']
    })

    // returning a promise makes AVA run it asynchronously
    return Promise.method(fn)(t).then(() => {
      // Only verify sandbox if we didn't get another response
      sandbox.verifyAndRestore()
    }).catch((e) => {
      if (e && e.stack) {
        var lines = e.stack.split('\n')
        var i = 0

        // find first zopf occurence in stack trace
        while (i < lines.length) {
          var line = lines[i]
          if (/node_modules.zopf/.test(line)) {
            i--
            break
          }
          i++
        }

        throw lines.slice(0, i).filter(function (x) {
          return !/node_modules.bluebird/.test(x)
        }).join('\n')
      } else {
        throw e
      }
    })
  }
}

/**
 * Ran concurrently, write tests accordingly!
 */
var zopf = function (title, fn) {
  if (typeof title !== 'string') {
    fn = title
    title = null
  }

  ava(title, wrap(fn))
}

/**
 * To use as a last resort, when mocking global resources -
 * usually a sign of test smell
 */
zopf.serial = function (title, fn) {
  if (typeof title !== 'string') {
    fn = title
    title = null
  }

  ava.serial(title, wrap(fn))
}

module.exports = zopf

{'fraction_non_alphanumeric': 0.1440785307156428, 'fraction_numerical': 0.001266624445851805, 'mean_word_length': 2.0940254652301666, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1125866', 'n_tokens_mistral': 1032, 'n_tokens_neox': 1004, 'n_words': 292}