Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. module.exports = function runSymbolTests(t) {
  3. t.equal(typeof Symbol, 'function', 'global Symbol is a function');
  4. if (typeof Symbol !== 'function') { return false };
  5. t.notEqual(Symbol(), Symbol(), 'two symbols are not equal');
  6. /*
  7. t.equal(
  8. Symbol.prototype.toString.call(Symbol('foo')),
  9. Symbol.prototype.toString.call(Symbol('foo')),
  10. 'two symbols with the same description stringify the same'
  11. );
  12. */
  13. var foo = Symbol('foo');
  14. /*
  15. t.notEqual(
  16. String(foo),
  17. String(Symbol('bar')),
  18. 'two symbols with different descriptions do not stringify the same'
  19. );
  20. */
  21. t.equal(typeof Symbol.prototype.toString, 'function', 'Symbol#toString is a function');
  22. // t.equal(String(foo), Symbol.prototype.toString.call(foo), 'Symbol#toString equals String of the same symbol');
  23. t.equal(typeof Object.getOwnPropertySymbols, 'function', 'Object.getOwnPropertySymbols is a function');
  24. var obj = {};
  25. var sym = Symbol('test');
  26. var symObj = Object(sym);
  27. t.notEqual(typeof sym, 'string', 'Symbol is not a string');
  28. t.equal(Object.prototype.toString.call(sym), '[object Symbol]', 'symbol primitive Object#toStrings properly');
  29. t.equal(Object.prototype.toString.call(symObj), '[object Symbol]', 'symbol primitive Object#toStrings properly');
  30. var symVal = 42;
  31. obj[sym] = symVal;
  32. for (sym in obj) { t.fail('symbol property key was found in for..in of object'); }
  33. t.deepEqual(Object.keys(obj), [], 'no enumerable own keys on symbol-valued object');
  34. t.deepEqual(Object.getOwnPropertyNames(obj), [], 'no own names on symbol-valued object');
  35. t.deepEqual(Object.getOwnPropertySymbols(obj), [sym], 'one own symbol on symbol-valued object');
  36. t.equal(Object.prototype.propertyIsEnumerable.call(obj, sym), true, 'symbol is enumerable');
  37. t.deepEqual(Object.getOwnPropertyDescriptor(obj, sym), {
  38. configurable: true,
  39. enumerable: true,
  40. value: 42,
  41. writable: true
  42. }, 'property descriptor is correct');
  43. };