2020-01-28 13:08:03 +08:00
|
|
|
var inspect = require('../');
|
|
|
|
var test = require('tape');
|
|
|
|
|
|
|
|
test('type error', function (t) {
|
|
|
|
t.plan(1);
|
2020-03-07 11:45:40 +08:00
|
|
|
var aerr = new TypeError();
|
2020-01-28 13:08:03 +08:00
|
|
|
aerr.foo = 555;
|
2020-03-07 11:45:40 +08:00
|
|
|
aerr.bar = [1, 2, 3];
|
|
|
|
|
2020-01-28 13:08:03 +08:00
|
|
|
var berr = new TypeError('tuv');
|
|
|
|
berr.baz = 555;
|
2020-03-07 11:45:40 +08:00
|
|
|
|
|
|
|
var cerr = new SyntaxError();
|
2020-01-28 13:08:03 +08:00
|
|
|
cerr.message = 'whoa';
|
|
|
|
cerr['a-b'] = 5;
|
2020-03-07 11:45:40 +08:00
|
|
|
|
2020-01-28 13:08:03 +08:00
|
|
|
var obj = [
|
2020-03-07 11:45:40 +08:00
|
|
|
new TypeError(),
|
2020-01-28 13:08:03 +08:00
|
|
|
new TypeError('xxx'),
|
2020-03-07 11:45:40 +08:00
|
|
|
aerr,
|
|
|
|
berr,
|
|
|
|
cerr
|
2020-01-28 13:08:03 +08:00
|
|
|
];
|
|
|
|
t.equal(inspect(obj), '[ ' + [
|
|
|
|
'[TypeError]',
|
|
|
|
'[TypeError: xxx]',
|
|
|
|
'{ [TypeError] foo: 555, bar: [ 1, 2, 3 ] }',
|
|
|
|
'{ [TypeError: tuv] baz: 555 }',
|
|
|
|
'{ [SyntaxError: whoa] message: \'whoa\', \'a-b\': 5 }'
|
|
|
|
].join(', ') + ' ]');
|
|
|
|
});
|