1 |
3a515b92
|
cagy
|
var inspect = require('../');
|
2 |
|
|
var test = require('tape');
|
3 |
|
|
|
4 |
|
|
test('function', function (t) {
|
5 |
|
|
t.plan(1);
|
6 |
|
|
var obj = [1, 2, function f(n) { return n; }, 4];
|
7 |
|
|
t.equal(inspect(obj), '[ 1, 2, [Function: f], 4 ]');
|
8 |
|
|
});
|
9 |
|
|
|
10 |
|
|
test('function name', function (t) {
|
11 |
|
|
t.plan(1);
|
12 |
|
|
var f = (function () {
|
13 |
|
|
return function () {};
|
14 |
|
|
}());
|
15 |
|
|
f.toString = function () { return 'function xxx () {}'; };
|
16 |
|
|
var obj = [1, 2, f, 4];
|
17 |
|
|
t.equal(inspect(obj), '[ 1, 2, [Function: xxx], 4 ]');
|
18 |
|
|
});
|
19 |
|
|
|
20 |
|
|
test('anon function', function (t) {
|
21 |
|
|
var f = (function () {
|
22 |
|
|
return function () {};
|
23 |
|
|
}());
|
24 |
|
|
var obj = [1, 2, f, 4];
|
25 |
|
|
t.equal(inspect(obj), '[ 1, 2, [Function], 4 ]');
|
26 |
|
|
|
27 |
|
|
t.end();
|
28 |
|
|
});
|