polyfill.js 725 B

1234567891011121314151617181920212223
  1. "use strict";
  2. module.exports = function (T, a) {
  3. var obj1 = {}, obj2 = {}, obj3 = {}, arr = [[obj1, "raz"], [obj2, "dwa"]], map = new T(arr);
  4. a(map instanceof T, true, "WeakMap");
  5. a(map.has(obj1), true, "Has: true");
  6. a(map.get(obj1), "raz", "Get: contains");
  7. a(map.has(obj3), false, "Has: false");
  8. a(map.get(obj3), undefined, "Get: doesn't contain");
  9. a(map.set(obj3, "trzy"), map, "Set: return");
  10. a(map.has(obj3), true, "Add");
  11. a(map.delete({}), false, "Delete: false");
  12. a(map.delete(obj1), true, "Delete: true");
  13. a(map.get(obj1), undefined, "Get: after delete");
  14. a(map.has(obj1), false, "Has: after delete");
  15. a.h1("Empty initialization");
  16. map = new T();
  17. map.set(obj1, "bar");
  18. a(map.get(obj1), "bar");
  19. };