FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/test/node-api/test_async_context/test.js at main · fetchapi/node · GitHub
fetchapi
/
node
Public
forked from
nodejs/node
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
test
/
node-api
/
test_async_context
/
test.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (56 loc) · 1.5 KB
Breadcrumbs
node
/
test
/
node-api
/
test_async_context
/
test.js
Copy path
File metadata and controls
63 lines (56 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
52
53
54
55
56
57
58
59
60
61
62
63
'use strict'
;
// Flags: --gc-interval=100 --gc-global
const
common
=
require
(
'../../common'
)
;
const
assert
=
require
(
'assert'
)
;
const
async_hooks
=
require
(
'async_hooks'
)
;
const
{
makeCallback
,
createAsyncResource
,
destroyAsyncResource
,
}
=
require
(
`./build/
${
common
.
buildType
}
/binding`
)
;
const
hook_result
=
{
id
:
null
,
resource
:
null
,
init_called
:
false
,
destroy_called
:
false
,
}
;
const
test_hook
=
async_hooks
.
createHook
(
{
init
:
(
id
,
type
,
triggerAsyncId
,
resource
)
=>
{
if
(
type
===
'test_async'
)
{
hook_result
.
id
=
id
;
hook_result
.
init_called
=
true
;
hook_result
.
resource
=
resource
;
}
}
,
destroy
:
(
id
)
=>
{
if
(
id
===
hook_result
.
id
)
hook_result
.
destroy_called
=
true
;
}
,
}
)
;
test_hook
.
enable
(
)
;
const
resourceWrap
=
createAsyncResource
(
/**
* set resource to NULL to generate a managed resource object
*/
undefined
,
)
;
assert
.
strictEqual
(
hook_result
.
destroy_called
,
false
)
;
const
recv
=
{
}
;
makeCallback
(
resourceWrap
,
recv
,
function
callback
(
)
{
assert
.
strictEqual
(
hook_result
.
destroy_called
,
false
)
;
assert
.
strictEqual
(
hook_result
.
resource
,
async_hooks
.
executionAsyncResource
(
)
,
)
;
assert
.
strictEqual
(
this
,
recv
)
;
setImmediate
(
(
)
=>
{
assert
.
strictEqual
(
hook_result
.
destroy_called
,
false
)
;
assert
.
notStrictEqual
(
hook_result
.
resource
,
async_hooks
.
executionAsyncResource
(
)
,
)
;
destroyAsyncResource
(
resourceWrap
)
;
setImmediate
(
(
)
=>
{
assert
.
strictEqual
(
hook_result
.
destroy_called
,
true
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL