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.

28 lines
702 B

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