-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathes.function.name.js
42 lines (37 loc) · 1.2 KB
/
es.function.name.js
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
import { DESCRIPTORS } from '../helpers/constants.js';
if (DESCRIPTORS) {
QUnit.test('Function#name', assert => {
assert.true('name' in Function.prototype);
assert.nonEnumerable(Function.prototype, 'name');
function foo() { /* empty */ }
assert.same(foo.name, 'foo');
assert.same(function () { /* empty */ }.name, '');
if (Object.freeze) {
assert.same(Object.freeze(() => { /* empty */ }).name, '');
}
function bar() { /* empty */ }
bar.toString = function () {
throw new Error();
};
assert.notThrows(() => bar.name === 'bar', 'works with redefined `.toString`');
const baz = Object(() => { /* empty */ });
baz.toString = function () {
return '';
};
assert.same(baz.name, '');
assert.same(function /*
multi-line comment */() { /* empty */ }.name, '');
function /*
multi-line comment */
foobar() { /* empty */ }
assert.same(foobar.name, 'foobar');
function // simple-line comment
foobaz() { /* empty */ }
assert.same(foobaz.name, 'foobaz');
function // simple-line comment
/* multi-line comment */quux/*
multi-line comment
*/() { /* empty */ }
assert.same(quux.name, 'quux');
});
}