err.js 722 B

12345678910111213141516171819202122232425262728293031
  1. var inspect = require('../');
  2. var test = require('tape');
  3. test('type error', function (t) {
  4. t.plan(1);
  5. var aerr = new TypeError();
  6. aerr.foo = 555;
  7. aerr.bar = [1, 2, 3];
  8. var berr = new TypeError('tuv');
  9. berr.baz = 555;
  10. var cerr = new SyntaxError();
  11. cerr.message = 'whoa';
  12. cerr['a-b'] = 5;
  13. var obj = [
  14. new TypeError(),
  15. new TypeError('xxx'),
  16. aerr,
  17. berr,
  18. cerr
  19. ];
  20. t.equal(inspect(obj), '[ ' + [
  21. '[TypeError]',
  22. '[TypeError: xxx]',
  23. '{ [TypeError] foo: 555, bar: [ 1, 2, 3 ] }',
  24. '{ [TypeError: tuv] baz: 555 }',
  25. '{ [SyntaxError: whoa] message: \'whoa\', \'a-b\': 5 }'
  26. ].join(', ') + ' ]');
  27. });