Skip to content

Commit 12f4025

Browse files
committed
test: eventemmiter asyncresource throw invalid this
1 parent 82f6b0c commit 12f4025

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/parallel/test-eventemitter-asyncresource.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010
const {
1111
deepStrictEqual,
1212
strictEqual,
13+
throws
1314
} = require('assert');
1415

1516
const {
@@ -130,3 +131,46 @@ function makeHook(trackedTypes) {
130131
],
131132
]));
132133
})().then(common.mustCall());
134+
135+
// Member methods ERR_INVALID_THIS
136+
{
137+
throws(
138+
() => {
139+
EventEmitterAsyncResource.prototype.emit();
140+
},
141+
{
142+
code: 'ERR_INVALID_THIS',
143+
}
144+
);
145+
146+
throws(
147+
() => {
148+
EventEmitterAsyncResource.prototype.emitDestroy();
149+
},
150+
{
151+
code: 'ERR_INVALID_THIS',
152+
}
153+
);
154+
155+
throws(
156+
() => Reflect.get(EventEmitterAsyncResource.prototype, 'asyncId', {}),
157+
{
158+
code: 'ERR_INVALID_THIS',
159+
}
160+
);
161+
162+
throws(
163+
() =>
164+
Reflect.get(EventEmitterAsyncResource.prototype, 'triggerAsyncId', {}),
165+
{
166+
code: 'ERR_INVALID_THIS',
167+
}
168+
);
169+
170+
throws(
171+
() => Reflect.get(EventEmitterAsyncResource.prototype, 'asyncResource', {}),
172+
{
173+
code: 'ERR_INVALID_THIS',
174+
}
175+
);
176+
}

0 commit comments

Comments
 (0)