11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst Countdown = require('../common/countdown');
61cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
71cb0ef41Sopenharmony_ciconst { execFile } = require('child_process');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cilet done = '';
101cb0ef41Sopenharmony_ciconst countdown = new Countdown(2, () => done = true);
111cb0ef41Sopenharmony_ciassert.strictEqual(countdown.remaining, 2);
121cb0ef41Sopenharmony_cicountdown.dec();
131cb0ef41Sopenharmony_ciassert.strictEqual(countdown.remaining, 1);
141cb0ef41Sopenharmony_cicountdown.dec();
151cb0ef41Sopenharmony_ciassert.strictEqual(countdown.remaining, 0);
161cb0ef41Sopenharmony_ciassert.strictEqual(done, true);
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciconst failFixtures = [
191cb0ef41Sopenharmony_ci  [
201cb0ef41Sopenharmony_ci    fixtures.path('failcounter.js'),
211cb0ef41Sopenharmony_ci    'Mismatched <anonymous> function calls. Expected exactly 1, actual 0.',
221cb0ef41Sopenharmony_ci  ],
231cb0ef41Sopenharmony_ci];
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_cifor (const p of failFixtures) {
261cb0ef41Sopenharmony_ci  const [file, expected] = p;
271cb0ef41Sopenharmony_ci  execFile(process.argv[0], [file], common.mustCall((ex, stdout, stderr) => {
281cb0ef41Sopenharmony_ci    assert.ok(ex);
291cb0ef41Sopenharmony_ci    assert.strictEqual(stderr, '');
301cb0ef41Sopenharmony_ci    const firstLine = stdout.split('\n').shift();
311cb0ef41Sopenharmony_ci    assert.strictEqual(firstLine, expected);
321cb0ef41Sopenharmony_ci  }));
331cb0ef41Sopenharmony_ci}
34