2020-08-25 23:57:08 +00:00
|
|
|
var inspect = require('../');
|
|
|
|
var test = require('tape');
|
|
|
|
|
|
|
|
test('function', function (t) {
|
|
|
|
t.plan(1);
|
|
|
|
var obj = [1, 2, function f(n) { return n; }, 4];
|
|
|
|
t.equal(inspect(obj), '[ 1, 2, [Function: f], 4 ]');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('function name', function (t) {
|
|
|
|
t.plan(1);
|
|
|
|
var f = (function () {
|
|
|
|
return function () {};
|
|
|
|
}());
|
2021-02-26 03:58:33 +00:00
|
|
|
f.toString = function toStr() { return 'function xxx () {}'; };
|
2020-08-25 23:57:08 +00:00
|
|
|
var obj = [1, 2, f, 4];
|
2021-02-26 03:58:33 +00:00
|
|
|
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)] { toString: [Function: toStr] }, 4 ]');
|
2020-08-25 23:57:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('anon function', function (t) {
|
|
|
|
var f = (function () {
|
|
|
|
return function () {};
|
|
|
|
}());
|
|
|
|
var obj = [1, 2, f, 4];
|
|
|
|
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)], 4 ]');
|
|
|
|
|
|
|
|
t.end();
|
|
|
|
});
|