mixin.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. "use strict";
  2. module.exports = function (t, a) {
  3. var o, o1, o2, x, y = {}, z = {};
  4. o = { inherited: true };
  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); }
  12. catch (ignore) {}
  13. a(o2.visible, z, "Enumerable");
  14. a(o1.hidden, "hidden", "Not Enumerable");
  15. a(o2.propertyIsEnumerable("visible"), true, "Enumerable is enumerable");
  16. a(o2.propertyIsEnumerable("hidden"), false, "Not enumerable is not enumerable");
  17. a(o2.hasOwnProperty("inherited"), false, "Extend only own");
  18. a(o2.inherited, undefined, "Extend ony own: value");
  19. a(o2.nonremovable, y, "Do not overwrite non configurable");
  20. a(o2.other, "other", "Own kept");
  21. x = {};
  22. t(x, o2);
  23. try { t(x, o1); }
  24. catch (ignore) {}
  25. a(x.visible, z, "Enumerable");
  26. a(x.hidden, "hidden", "Not Enumerable");
  27. a(x.propertyIsEnumerable("visible"), true, "Enumerable is enumerable");
  28. a(x.propertyIsEnumerable("hidden"), false, "Not enumerable is not enumerable");
  29. a(x.hasOwnProperty("inherited"), false, "Extend only own");
  30. a(x.inherited, undefined, "Extend ony own: value");
  31. a(x.nonremovable, y, "Ignored non configurable");
  32. a(x.other, "other", "Other");
  33. x.visible = 3;
  34. a(x.visible, 3, "Writable is writable");
  35. x = {};
  36. t(x, o1);
  37. a.throws(function () { x.hidden = 3; }, "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 () { delete x.hidden; }, "Not configurable is not configurable");
  45. x = Object.defineProperty({}, "foo", {
  46. configurable: false,
  47. writable: true,
  48. enumerable: false,
  49. value: "bar"
  50. });
  51. try { t(x, { foo: "lorem" }); }
  52. catch (ignore) {}
  53. a(x.foo, "bar", "Writable, not enumerable");
  54. };