Set Function.name for funcs in variables and properties as per spec.
Implements correct Function.name for cases like following:
* `var x = function () { ... }`
* `var obj = {prop: function () { ... }}`
This commit is contained in:
27
test/fixtures/transformation/spec-function-name/actual.js
vendored
Normal file
27
test/fixtures/transformation/spec-function-name/actual.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var obj = {
|
||||
f: function () {
|
||||
(function f() {
|
||||
console.log(f);
|
||||
})();
|
||||
},
|
||||
|
||||
g: function () {
|
||||
console.log(g);
|
||||
},
|
||||
|
||||
h: function () {
|
||||
console.log(h);
|
||||
},
|
||||
|
||||
m: function () {
|
||||
doSmth();
|
||||
}
|
||||
};
|
||||
|
||||
var f = function () {
|
||||
console.log(f, g);
|
||||
};
|
||||
|
||||
var g = function () {
|
||||
doSmth();
|
||||
};
|
||||
42
test/fixtures/transformation/spec-function-name/expected.js
vendored
Normal file
42
test/fixtures/transformation/spec-function-name/expected.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
var _selfGlobal = typeof global === "undefined" ? self : global;
|
||||
var obj = {
|
||||
f: function f() {
|
||||
(function f() {
|
||||
console.log(f);
|
||||
})();
|
||||
},
|
||||
|
||||
g: (function () {
|
||||
function _getOuter() {
|
||||
return g;
|
||||
}
|
||||
|
||||
return function g() {
|
||||
console.log(_getOuter());
|
||||
};
|
||||
})(),
|
||||
|
||||
h: function h() {
|
||||
console.log(_selfGlobal.h);
|
||||
},
|
||||
|
||||
m: function m() {
|
||||
doSmth();
|
||||
}
|
||||
};
|
||||
|
||||
var f = (function () {
|
||||
function _getOuter() {
|
||||
return f;
|
||||
}
|
||||
|
||||
return function f() {
|
||||
console.log(_getOuter(), g);
|
||||
};
|
||||
})();
|
||||
|
||||
var g = function g() {
|
||||
doSmth();
|
||||
};
|
||||
3
test/fixtures/transformation/spec-function-name/options.json
vendored
Normal file
3
test/fixtures/transformation/spec-function-name/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"whitelist": ["spec.functionName"]
|
||||
}
|
||||
Reference in New Issue
Block a user