indexed-access-prototype-indirection.js 755 B

1234567891011121314151617181920212223242526272829
  1. describe("normal behavior", () => {
  2. test("regular object indexing", () => {
  3. const o = {};
  4. const p = { 0: "foo" };
  5. Object.setPrototypeOf(o, p);
  6. expect(o[0]).toBe("foo");
  7. });
  8. test("array object indexing", () => {
  9. const o = [];
  10. const p = ["foo"];
  11. Object.setPrototypeOf(o, p);
  12. expect(o[0]).toBe("foo");
  13. });
  14. test("array object hole indexing", () => {
  15. const o = [,];
  16. const p = ["foo"];
  17. Object.setPrototypeOf(o, p);
  18. expect(o[0]).toBe("foo");
  19. });
  20. test("string object indexing", () => {
  21. const o = new String("");
  22. const p = new String("a");
  23. Object.setPrototypeOf(o, p);
  24. expect(o[0]).toBe("a");
  25. });
  26. });