![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/functions-have-names/test/ |
'use strict';
var test = require('tape');
var hasNames = require('../');
test('named functions', function (t) {
function f() {} // eslint-disable-line func-style
var g = function h() {};
t.equal(typeof hasNames, 'function', 'is a function');
t.equal(hasNames(), f.name === 'f' && g.name === 'h', 'functions have names or not as expected');
t.end();
});
var oDP = Object.defineProperty;
if (oDP) {
try {
oDP({}, 'a', { value: 1 });
} catch (e) {
oDP = null;
}
}
test('functionsHaveConfigurableNames', function (t) {
t.equal(typeof hasNames.functionsHaveConfigurableNames, 'function', 'is a function');
if (hasNames()) {
var fn = function f() {};
if (oDP) {
try {
oDP(fn, 'name', { configurable: true, value: 'foo' });
} catch (e) {}
if (fn.name === 'f') {
t.equal(hasNames.functionsHaveConfigurableNames(), false, 'function names are not configurable');
} else if (fn.name === 'foo') {
t.equal(hasNames.functionsHaveConfigurableNames(), true, 'function names are not configurable');
} else {
t.fail('functions have names, but something surprising has happened. Please report this!');
}
} else {
t.equal(hasNames.functionsHaveConfigurableNames(), false, 'function names are not configurable');
}
} else {
t.equal(hasNames.functionsHaveConfigurableNames(), false, 'functions do not have names');
}
t.end();
});
test('boundFunctionsHaveNames', function (t) {
t.equal(typeof hasNames.boundFunctionsHaveNames, 'function', 'is a function');
var fn = function f() {};
if (typeof fn.bind !== 'function') {
t.equal(hasNames.boundFunctionsHaveNames(), false, 'bound functions do not have names, because .bind does not exist');
} else if (hasNames()) {
t.equal(hasNames.boundFunctionsHaveNames(), fn.bind().name !== '', 'bound functions have names');
} else {
t.equal(hasNames.boundFunctionsHaveNames(), false, 'bound functions do not have names, because none do');
}
t.end();
});