polyfill.js 768 B

1234567891011121314151617181920212223242526272829
  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. if (typeof symbol !== 'symbol') {
  17. a.deep(Object.getOwnPropertyDescriptor(x, symbol), { configurable: true, enumerable: false,
  18. value: 'foo', writable: true });
  19. }
  20. symbol = T.for('marko');
  21. a(isSymbol(symbol), true);
  22. a(T.for('marko'), symbol);
  23. a(T.keyFor(symbol), 'marko');
  24. };