<commit_before>'use strict';

const createTestCase = require('./index');

const errHandle = e => console.log(e.stack) && process.exit(1);
const shouldReject = () => console.log((new Error('should have rejected')).stack) && process.exit(1);

const good = [
  createTestCase(() => {}),
  createTestCase(() => 'foo'),
  createTestCase(() => Promise.resolve()),
  createTestCase(() => Promise.resolve('foo')),
  createTestCase(Promise.resolve()),
  createTestCase(Promise.resolve('foo')),
  createTestCase(cb => cb()),
  createTestCase(cb => setTimeout(cb, 50), { timeout: 100 })
];

const bad = [
  createTestCase(Promise.reject(new Error('foo'))),
  createTestCase(() => Promise.reject(new Error('foo'))),
  createTestCase(() => { throw new Error('foo'); }),
  createTestCase(() =>
    new Promise(() => { process.nextTick(() => { throw new Error('foo'); }); })
  ),
  createTestCase(cb => cb(new Error('foo'))),
  createTestCase(cb => { throw new Error('foo'); }),
  createTestCase(cb => setTimeout(cb, 100), { timeout: 50 })
];

good.reduce((accum, curr) =>
  accum.then(() => curr()), Promise.resolve())
  .then(() => bad.reduce((accum, curr) =><commit_msg>remove unhandled rejection warning in test<commit_after>'use strict';

const createTestCase = require('./index');

const errHandle = e => console.log(e.stack) && process.exit(1);
const shouldReject = () => console.log((new Error('should have rejected')).stack) && process.exit(1);

const good = [
  createTestCase(() => {}),
  createTestCase(() => 'foo'),
  createTestCase(() => Promise.resolve()),
  createTestCase(() => Promise.resolve('foo')),
  createTestCase(Promise.resolve()),
  createTestCase(Promise.resolve('foo')),
  createTestCase(cb => cb()),
  createTestCase(cb => setTimeout(cb, 50), { timeout: 100 })
];

const rejecting = Promise.reject(new Error('foo'));
rejecting.catch(() => { /* avoid unhandled rejection warnings */ });

const bad = [
  createTestCase(rejecting),
  createTestCase(() => rejecting),
  createTestCase(() => { throw new Error('foo'); }),
  createTestCase(() =>
    new Promise(() => { process.nextTick(() => { throw new Error('foo'); }); })
  ),
  createTestCase(cb => cb(new Error('foo'))),
  createTestCase(cb => { throw new Error('foo'); }),
  createTestCase(cb => setTimeout(cb, 100), { timeout: 50 })
];

good.reduce((accum, curr) =>
  accum.then(() => curr()), Promise.resolve())
  .then(() => bad.reduce((accum, curr) =>
{'fraction_non_alphanumeric': 0.2218091697645601, 'fraction_numerical': 0.009913258983890954, 'mean_word_length': 5.242268041237113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 44, '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': '2412873', 'n_tokens_mistral': 730, 'n_tokens_neox': 717, 'n_words': 158}