2020-01-28 13:08:03 +08:00
|
|
|
var inspect = require('../');
|
|
|
|
var test = require('tape');
|
|
|
|
|
|
|
|
test('function', function (t) {
|
|
|
|
t.plan(1);
|
2020-03-07 11:45:40 +08:00
|
|
|
var obj = [1, 2, function f(n) { return n; }, 4];
|
2020-01-28 13:08:03 +08:00
|
|
|
t.equal(inspect(obj), '[ 1, 2, [Function: f], 4 ]');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('function name', function (t) {
|
|
|
|
t.plan(1);
|
|
|
|
var f = (function () {
|
2020-03-07 11:45:40 +08:00
|
|
|
return function () {};
|
2020-01-28 13:08:03 +08:00
|
|
|
}());
|
2020-03-07 11:45:40 +08:00
|
|
|
f.toString = function () { return 'function xxx () {}'; };
|
|
|
|
var obj = [1, 2, f, 4];
|
2020-01-28 13:08:03 +08:00
|
|
|
t.equal(inspect(obj), '[ 1, 2, [Function: xxx], 4 ]');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('anon function', function (t) {
|
|
|
|
var f = (function () {
|
2020-03-07 11:45:40 +08:00
|
|
|
return function () {};
|
2020-01-28 13:08:03 +08:00
|
|
|
}());
|
2020-03-07 11:45:40 +08:00
|
|
|
var obj = [1, 2, f, 4];
|
2020-01-28 13:08:03 +08:00
|
|
|
t.equal(inspect(obj), '[ 1, 2, [Function], 4 ]');
|
|
|
|
|
|
|
|
t.end();
|
|
|
|
});
|