forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-async-wrap-uid.js
More file actions
51 lines (41 loc) · 915 Bytes
/
test-async-wrap-uid.js
File metadata and controls
51 lines (41 loc) · 915 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
require('../common');
const fs = require('fs');
const assert = require('assert');
const async_wrap = process.binding('async_wrap');
const storage = new Map();
async_wrap.setupHooks({ init, pre, post });
async_wrap.enable();
function init(uid) {
storage.set(uid, {
init: true,
pre: false,
post: false,
});
}
function pre(uid) {
storage.get(uid).pre = true;
}
function post(uid) {
storage.get(uid).post = true;
}
fs.access(__filename, function(err) {
assert.ifError(err);
});
fs.access(__filename, function(err) {
assert.ifError(err);
});
async_wrap.disable();
process.once('exit', function() {
assert.strictEqual(storage.size, 2);
for (const item of storage) {
const uid = item[0];
const value = item[1];
assert.strictEqual(typeof uid, 'number');
assert.deepStrictEqual(value, {
init: true,
pre: true,
post: true,
});
}
});