<commit_before>'use strict';
let event = require('./event');
let container = require('./container');
let recorder = require('./recorder');
let getParamNames = require('./utils').getParamNames;

/**
 * Wraps test function, injects support objects from container,
 * starts promise chain with recorder, performs before/after hooks
 * through event system.
 */
module.exports.test = (test) => {
  let testFn = test.fn;
  if (!testFn) {
    return test;
  }

  test.steps = [];
  test.fn = function (done) {
    recorder.errHandler(function (err){
      event.dispatcher.emit(event.test.failed, test, err);
      recorder.add(() => done(err), true);
    });

    try {
      event.dispatcher.emit(event.test.started, test);
      let res = testFn.apply(test, getInjectedArguments(testFn));

      if (isGenerator(testFn)) {
        res.next(); // running test
        recorder.catch(); // catching possible errors in promises
        let resumeTest = function () {
          recorder.add(function (data) {
            recorder.reset(); // creating a new promise chain
            try {
              let resume = res.next(data);
              if (resume.done) {<commit_msg>small fix for generator and assert. Fixes #89<commit_after>'use strict';
let event = require('./event');
let container = require('./container');
let recorder = require('./recorder');
let getParamNames = require('./utils').getParamNames;

/**
 * Wraps test function, injects support objects from container,
 * starts promise chain with recorder, performs before/after hooks
 * through event system.
 */
module.exports.test = (test) => {
  let testFn = test.fn;
  if (!testFn) {
    return test;
  }

  test.steps = [];
  test.fn = function (done) {
    recorder.errHandler(function (err){
      event.dispatcher.emit(event.test.failed, test, err);
      recorder.add(() => done(err), true);
    });

    try {
      event.dispatcher.emit(event.test.started, test);
      let res = testFn.apply(test, getInjectedArguments(testFn));
      recorder.catch();

      if (isGenerator(testFn)) {
        try {
          res.next(); // running test
        } catch (err) {
          done(err);
          return test;
        }
        recorder.catch(); // catching possible errors in promises
        let resumeTest = function () {
          recorder.add(function (data) {
            recorder.reset(); // creating a new promise chain
            try {
              let resume = res.next(data);
              if (resume.done) {
{'fraction_non_alphanumeric': 0.13987138263665594, 'fraction_numerical': 0.0008038585209003215, 'mean_word_length': 2.5608011444921317, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2044891', 'n_tokens_mistral': 707, 'n_tokens_neox': 695, 'n_words': 192}