exec.js 511 B

12345678910111213141516171819202122232425262728
  1. class Foo {
  2. #foo = 0;
  3. test(other) {
  4. return [
  5. this.#foo++,
  6. this.#foo,
  7. ++this.#foo,
  8. this.#foo,
  9. other.obj.#foo++,
  10. other.obj.#foo,
  11. ++other.obj.#foo,
  12. other.obj.#foo,
  13. ];
  14. }
  15. }
  16. const f = new Foo;
  17. const results = f.test({ obj: f });
  18. expect(results[0]).toBe(0);
  19. expect(results[1]).toBe(1);
  20. expect(results[2]).toBe(2);
  21. expect(results[3]).toBe(2);
  22. expect(results[4]).toBe(2);
  23. expect(results[5]).toBe(3);
  24. expect(results[6]).toBe(4);
  25. expect(results[7]).toBe(4);