mixin.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 {
  12. t(o2, o1);
  13. } catch (ignore) {}
  14. a(o2.visible, z, "Enumerable");
  15. a(o1.hidden, "hidden", "Not Enumerable");
  16. a(o2.propertyIsEnumerable("visible"), true, "Enumerable is enumerable");
  17. a(o2.propertyIsEnumerable("hidden"), false,
  18. "Not enumerable is not enumerable");
  19. a(o2.hasOwnProperty("inherited"), false, "Extend only own");
  20. a(o2.inherited, undefined, "Extend ony own: value");
  21. a(o2.nonremovable, y, "Do not overwrite non configurable");
  22. a(o2.other, "other", "Own kept");
  23. x = {};
  24. t(x, o2);
  25. try {
  26. t(x, o1);
  27. } catch (ignore) {}
  28. a(x.visible, z, "Enumerable");
  29. a(x.hidden, "hidden", "Not Enumerable");
  30. a(x.propertyIsEnumerable("visible"), true, "Enumerable is enumerable");
  31. a(x.propertyIsEnumerable("hidden"), false,
  32. "Not enumerable is not enumerable");
  33. a(x.hasOwnProperty("inherited"), false, "Extend only own");
  34. a(x.inherited, undefined, "Extend ony own: value");
  35. a(x.nonremovable, y, "Ignored non configurable");
  36. a(x.other, "other", "Other");
  37. x.visible = 3;
  38. a(x.visible, 3, "Writable is writable");
  39. x = {};
  40. t(x, o1);
  41. a.throws(function () {
  42. x.hidden = 3;
  43. }, "Not writable is not writable");
  44. x = {};
  45. t(x, o1);
  46. delete x.visible;
  47. a.ok(!x.hasOwnProperty("visible"), "Configurable is configurable");
  48. x = {};
  49. t(x, o1);
  50. a.throws(function () {
  51. delete x.hidden;
  52. }, "Not configurable is not configurable");
  53. x = Object.defineProperty({}, "foo",
  54. { configurable: false, writable: true, enumerable: false, value: "bar" });
  55. try {
  56. t(x, { foo: "lorem" });
  57. } catch (ignore) {}
  58. a(x.foo, "bar", "Writable, not enumerable");
  59. };