Debian Codegraph @

packages/babel-plugin-proposal-class-properties/test/fixtures/private/canonical/exec.js

raw symbols SCIP
1 class Point {
2 #x;
3 #y;
4
5 constructor(x = 0, y = 0) {
6 this.#x = +x;
7 this.#y = +y;
8 }
9
10 get x() { return this.#x }
11 set x(value) { this.#x = +value }
12
13 get y() { return this.#y }
14 set y(value) { this.#y = +value }
15
16 equals(p) { return this.#x === p.#x && this.#y === p.#y }
17
18 toString() { return `Point<${ this.#x },${ this.#y }>` }
19
20 }
21
22 const p1 = new Point(1, 2);
23 const p2 = new Point(2, 3);
24 const p3 = new Point(1, 2);
25
26 expect(p1.x).toBe(1);
27 expect(p1.y).toBe(2);
28 expect(p2.x).toBe(2);
29 expect(p2.y).toBe(3);
30 expect(p3.x).toBe(1);
31 expect(p3.y).toBe(2);
32
33 expect(p1.equals(p1)).toBe(true)
34 expect(p1.equals(p2)).toBe(false)
35 expect(p1.equals(p3)).toBe(true)
36 expect(p2.equals(p1)).toBe(false)
37 expect(p2.equals(p2)).toBe(true)
38 expect(p2.equals(p3)).toBe(false)
39 expect(p3.equals(p1)).toBe(true)
40 expect(p3.equals(p2)).toBe(false)
41 expect(p3.equals(p3)).toBe(true)
42
43 expect(p1.toString()).toBe("Point<1,2>")
44 expect(p2.toString()).toBe("Point<2,3>")
45 expect(p3.toString()).toBe("Point<1,2>")
46
47 p1.x += 1;
48 p1.y = 3;
49 p2.x -= 1;
50 p2.y = 3;
51 p3.x = 0;
52 p3.y = 0;
53
54 expect(p1.x).toBe(2);
55 expect(p1.y).toBe(3);
56 expect(p2.x).toBe(1);
57 expect(p2.y).toBe(3);
58 expect(p3.x).toBe(0);
59 expect(p3.y).toBe(0);
60
61 expect(p1.equals(p1)).toBe(true)
62 expect(p1.equals(p2)).toBe(false)
63 expect(p1.equals(p3)).toBe(false)
64 expect(p2.equals(p1)).toBe(false)
65 expect(p2.equals(p2)).toBe(true)
66 expect(p2.equals(p3)).toBe(false)
67 expect(p3.equals(p1)).toBe(false)
68 expect(p3.equals(p2)).toBe(false)
69 expect(p3.equals(p3)).toBe(true)
70
71 expect(p1.toString()).toBe("Point<2,3>")
72 expect(p2.toString()).toBe("Point<1,3>")
73 expect(p3.toString()).toBe("Point<0,0>")