shim.js 685 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var create = require('../../../object/create')
  3. , getPrototypeOf = Object.getPrototypeOf;
  4. module.exports = function (t, a) {
  5. var x = {}, y = {};
  6. if (t === null) return;
  7. a(t(x, y), x, "Return self object");
  8. a(getPrototypeOf(x), y, "Object");
  9. a.throws(function () { t(x); }, TypeError, "Undefined");
  10. a.throws(function () { t('foo'); }, TypeError, "Primitive");
  11. a(getPrototypeOf(t(x, null)), t.nullPolyfill || null, "Null");
  12. x = create(null);
  13. a.h1("Change null prototype");
  14. a(t(x, y), x, "Result");
  15. a(getPrototypeOf(x), y, "Prototype");
  16. a.h1("Set null prototype");
  17. a(t(y, null), y, "Result");
  18. a(getPrototypeOf(y), t.nullPolyfill || null, "Prototype");
  19. };