2020-01-28 13:08:03 +08:00
|
|
|
var test = require('tape');
|
2020-03-07 11:45:40 +08:00
|
|
|
var hasSymbols = require('has-symbols')();
|
|
|
|
var utilInspect = require('../util.inspect');
|
|
|
|
|
|
|
|
var inspect = require('..');
|
2020-01-28 13:08:03 +08:00
|
|
|
|
|
|
|
test('inspect', function (t) {
|
|
|
|
t.plan(1);
|
2020-03-07 11:45:40 +08:00
|
|
|
var obj = [{ inspect: function () { return '!XYZ¡'; } }, []];
|
2020-01-28 13:08:03 +08:00
|
|
|
t.equal(inspect(obj), '[ !XYZ¡, [] ]');
|
|
|
|
});
|
2020-03-07 11:45:40 +08:00
|
|
|
|
|
|
|
test('inspect custom symbol', { skip: !hasSymbols || !utilInspect }, function (t) {
|
|
|
|
t.plan(1);
|
|
|
|
|
|
|
|
var obj = { inspect: function () { return 'string'; } };
|
|
|
|
obj[utilInspect.custom] = function () { return 'symbol'; };
|
|
|
|
|
|
|
|
t.equal(inspect([obj, []]), '[ ' + (utilInspect.custom ? 'symbol' : 'string') + ', [] ]');
|
|
|
|
});
|