You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
722 B

4 years ago
  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. });