7152cd4988bfb0966addf66acb65b4ecc8edee6ce71bc4bf846831f23b59cb3e8729ee0c0aa6eaacc3eba0366b3dcf0122bdc83813b00f5fa7dee048bb8b0a 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. module.exports = function (getPrototypeOf, t) {
  3. t.test('nullish value', function (st) {
  4. st['throws'](function () { return getPrototypeOf(undefined); }, TypeError, 'undefined is not an object');
  5. st['throws'](function () { return getPrototypeOf(null); }, TypeError, 'null is not an object');
  6. st.end();
  7. });
  8. t['throws'](function () { getPrototypeOf(true); }, 'throws for true');
  9. t['throws'](function () { getPrototypeOf(false); }, 'throws for false');
  10. t['throws'](function () { getPrototypeOf(42); }, 'throws for 42');
  11. t['throws'](function () { getPrototypeOf(NaN); }, 'throws for NaN');
  12. t['throws'](function () { getPrototypeOf(0); }, 'throws for +0');
  13. t['throws'](function () { getPrototypeOf(-0); }, 'throws for -0');
  14. t['throws'](function () { getPrototypeOf(Infinity); }, 'throws for ∞');
  15. t['throws'](function () { getPrototypeOf(-Infinity); }, 'throws for -∞');
  16. t['throws'](function () { getPrototypeOf(''); }, 'throws for empty string');
  17. t['throws'](function () { getPrototypeOf('foo'); }, 'throws for non-empty string');
  18. t.equal(getPrototypeOf(/a/g), RegExp.prototype);
  19. t.equal(getPrototypeOf(new Date()), Date.prototype);
  20. t.equal(getPrototypeOf(function () {}), Function.prototype);
  21. t.equal(getPrototypeOf([]), Array.prototype);
  22. t.equal(getPrototypeOf({}), Object.prototype);
  23. var obj = { __proto__: null };
  24. if ('toString' in obj) {
  25. t.comment('no null objects in this engine');
  26. t.equal(getPrototypeOf(obj), Object.prototype, '"null" object has Object.prototype as [[Prototype]]');
  27. } else {
  28. t.equal(getPrototypeOf(obj), null, 'null object has null [[Prototype]]');
  29. }
  30. };