• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const Countdown = require('../common/countdown');
6const fixtures = require('../common/fixtures');
7const { execFile } = require('child_process');
8
9let done = '';
10const countdown = new Countdown(2, () => done = true);
11assert.strictEqual(countdown.remaining, 2);
12countdown.dec();
13assert.strictEqual(countdown.remaining, 1);
14countdown.dec();
15assert.strictEqual(countdown.remaining, 0);
16assert.strictEqual(done, true);
17
18const failFixtures = [
19  [
20    fixtures.path('failcounter.js'),
21    'Mismatched <anonymous> function calls. Expected exactly 1, actual 0.',
22  ],
23];
24
25for (const p of failFixtures) {
26  const [file, expected] = p;
27  execFile(process.argv[0], [file], common.mustCall((ex, stdout, stderr) => {
28    assert.ok(ex);
29    assert.strictEqual(stderr, '');
30    const firstLine = stdout.split('\n').shift();
31    assert.strictEqual(firstLine, expected);
32  }));
33}
34