mixin-prototypes.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. 'use strict';
  2. module.exports = function (t, a) {
  3. var o, o1, o2, x, y = {}, z = {};
  4. o = { inherited: true, visible: 23 };
  5. o1 = Object.create(o);
  6. o1.visible = z;
  7. o1.nonremovable = 'raz';
  8. Object.defineProperty(o1, 'hidden', { value: 'hidden' });
  9. o2 = Object.defineProperties({}, { nonremovable: { value: y } });
  10. o2.other = 'other';
  11. try { t(o2, o1); } catch (ignore) {}
  12. a(o2.visible, z, "Enumerable");
  13. a(o1.hidden, 'hidden', "Not Enumerable");
  14. a(o2.propertyIsEnumerable('visible'), true, "Enumerable is enumerable");
  15. a(o2.propertyIsEnumerable('hidden'), false,
  16. "Not enumerable is not enumerable");
  17. a(o2.inherited, true, "Extend deep");
  18. a(o2.nonremovable, y, "Do not overwrite non configurable");
  19. a(o2.other, 'other', "Own kept");
  20. x = {};
  21. t(x, o2);
  22. try { t(x, o1); } catch (ignore) {}
  23. a(x.visible, z, "Enumerable");
  24. a(x.hidden, 'hidden', "Not Enumerable");
  25. a(x.propertyIsEnumerable('visible'), true, "Enumerable is enumerable");
  26. a(x.propertyIsEnumerable('hidden'), false,
  27. "Not enumerable is not enumerable");
  28. a(x.inherited, true, "Extend deep");
  29. a(x.nonremovable, y, "Ignored non configurable");
  30. a(x.other, 'other', "Other");
  31. x.visible = 3;
  32. a(x.visible, 3, "Writable is writable");
  33. x = {};
  34. t(x, o1);
  35. a.throws(function () {
  36. x.hidden = 3;
  37. }, "Not writable is not writable");
  38. x = {};
  39. t(x, o1);
  40. delete x.visible;
  41. a.ok(!x.hasOwnProperty('visible'), "Configurable is configurable");
  42. x = {};
  43. t(x, o1);
  44. a.throws(function () {
  45. delete x.hidden;
  46. }, "Not configurable is not configurable");
  47. x = Object.defineProperty({}, 'foo',
  48. { configurable: false, writable: true, enumerable: false, value: 'bar' });
  49. try { t(x, { foo: 'lorem' }); } catch (ignore) {}
  50. a(x.foo, 'bar', "Writable, not enumerable");
  51. };