polyfill.js 806 B

1234567891011121314151617181920212223242526272829303132
  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"), obj = {};
  7. defineProperty(obj, symbol, d("foo"));
  8. a(obj.test, undefined, "Name");
  9. a(obj[symbol], "foo", "Get");
  10. a(obj instanceof t, false);
  11. a(isSymbol(symbol), true, "Symbol");
  12. a(isSymbol(t.iterator), true, "iterator");
  13. a(isSymbol(t.toStringTag), true, "toStringTag");
  14. obj = {};
  15. obj[symbol] = "foo";
  16. if (typeof symbol !== "symbol") {
  17. a.deep(Object.getOwnPropertyDescriptor(obj, symbol), {
  18. configurable: true,
  19. enumerable: false,
  20. value: "foo",
  21. writable: true
  22. });
  23. }
  24. symbol = t.for("marko");
  25. a(isSymbol(symbol), true);
  26. a(t.for("marko"), symbol);
  27. a(t.keyFor(symbol), "marko");
  28. };