4
1

polyfill.js 728 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. var d = require('d')
  3. , isSymbol = require('../is-symbol')
  4. , defineProperty = Object.defineProperty;
  5. module.exports = function (T, a) {
  6. var symbol = T('test'), x = {};
  7. defineProperty(x, symbol, d('foo'));
  8. a(x.test, undefined, "Name");
  9. a(x[symbol], 'foo', "Get");
  10. a(x instanceof T, false);
  11. a(isSymbol(symbol), true, "Symbol");
  12. a(isSymbol(T.iterator), true, "iterator");
  13. a(isSymbol(T.toStringTag), true, "toStringTag");
  14. x = {};
  15. x[symbol] = 'foo';
  16. a.deep(Object.getOwnPropertyDescriptor(x, symbol), { configurable: true, enumerable: false,
  17. value: 'foo', writable: true });
  18. symbol = T.for('marko');
  19. a(isSymbol(symbol), true);
  20. a(T.for('marko'), symbol);
  21. a(T.keyFor(symbol), 'marko');
  22. };