inline-cache-edge-cases.js 438 B

123456789101112131415161718
  1. test("Inline cache invalidated by deleting property from unique shape", () => {
  2. // Create an object with an unique shape by adding a huge amount of properties.
  3. let o = {};
  4. for (let x = 0; x < 1000; ++x) {
  5. o["prop" + x] = x;
  6. }
  7. function ic(o) {
  8. return o.prop2;
  9. }
  10. let first = ic(o);
  11. delete o.prop2;
  12. let second = ic(o);
  13. expect(first).toBe(2);
  14. expect(second).toBeUndefined();
  15. });