mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
Signed-off-by: freida-code <150387862+freida-code@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/65270 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
18 lines
479 B
JavaScript
18 lines
479 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
for (const i of [1, false, '', {}, []]) {
|
|
assert.throws(() => AsyncLocalStorage.bind(i), {
|
|
code: 'ERR_INVALID_ARG_TYPE'
|
|
});
|
|
}
|
|
|
|
const fn = common.mustCall(AsyncLocalStorage.bind(() => 123));
|
|
assert.strictEqual(fn(), 123);
|
|
|
|
const fn2 = AsyncLocalStorage.bind(common.mustCall((arg) => assert.strictEqual(arg, 'test')));
|
|
fn2('test');
|