Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-next-tick-ordering.js « parallel « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ea019facdd8fa037ac8d930fe6b4b0876703aedc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
require('../common');
const assert = require('assert');
let i;

const N = 30;
const done = [];

function get_printer(timeout) {
  return function() {
    console.log('Running from setTimeout ' + timeout);
    done.push(timeout);
  };
}

process.nextTick(function() {
  console.log('Running from nextTick');
  done.push('nextTick');
});

for (i = 0; i < N; i += 1) {
  setTimeout(get_printer(i), i);
}

console.log('Running from main.');


process.on('exit', function() {
  assert.strictEqual('nextTick', done[0]);
  /* Disabling this test. I don't think we can ensure the order
  for (i = 0; i < N; i += 1) {
    assert.strictEqual(i, done[i + 1]);
  }
  */
});