Skip to content

Commit 8bf51b9

Browse files
committed
add tests for duplicate accessors
Signed-off-by: Kubilay Kahveci <[email protected]>
1 parent 894aa3f commit 8bf51b9

File tree

5 files changed

+179
-2
lines changed

5 files changed

+179
-2
lines changed

tests/baselines/reference/privateNameDuplicateField.errors.txt

+42-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@ tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.t
1010
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(30,5): error TS2300: Duplicate identifier '#foo'.
1111
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(31,5): error TS2300: Duplicate identifier '#foo'.
1212
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(32,9): error TS2300: Duplicate identifier '#foo'.
13+
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(36,9): error TS2300: Duplicate identifier '#foo'.
14+
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(37,9): error TS2300: Duplicate identifier '#foo'.
15+
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(41,9): error TS2300: Duplicate identifier '#foo'.
16+
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(42,9): error TS2300: Duplicate identifier '#foo'.
17+
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(46,9): error TS2300: Duplicate identifier '#foo'.
18+
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(47,9): error TS2300: Duplicate identifier '#foo'.
19+
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(48,9): error TS2300: Duplicate identifier '#foo'.
20+
tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts(49,9): error TS2300: Duplicate identifier '#foo'.
1321

1422

15-
==== tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts (12 errors) ====
23+
==== tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts (20 errors) ====
1624
class A {
1725
#foo = "foo";
1826
#foo = "foo";
@@ -70,4 +78,37 @@ tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.t
7078
~~~~
7179
!!! error TS2300: Duplicate identifier '#foo'.
7280
}
81+
82+
class A7 {
83+
get #foo() { return ""; }
84+
~~~~
85+
!!! error TS2300: Duplicate identifier '#foo'.
86+
get #foo() { return ""; }
87+
~~~~
88+
!!! error TS2300: Duplicate identifier '#foo'.
89+
}
90+
91+
class A8 {
92+
set #foo(a: string) {}
93+
~~~~
94+
!!! error TS2300: Duplicate identifier '#foo'.
95+
set #foo(a: string) {}
96+
~~~~
97+
!!! error TS2300: Duplicate identifier '#foo'.
98+
}
99+
100+
class A9 {
101+
get #foo() { return ""; }
102+
~~~~
103+
!!! error TS2300: Duplicate identifier '#foo'.
104+
set #foo(a: string) {}
105+
~~~~
106+
!!! error TS2300: Duplicate identifier '#foo'.
107+
get #foo() { return ""; }
108+
~~~~
109+
!!! error TS2300: Duplicate identifier '#foo'.
110+
set #foo(a: string) {}
111+
~~~~
112+
!!! error TS2300: Duplicate identifier '#foo'.
113+
}
73114

tests/baselines/reference/privateNameDuplicateField.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,28 @@ class A6 {
3232
#foo() { return ""}
3333
get #foo() { return ""}
3434
}
35+
36+
class A7 {
37+
get #foo() { return ""; }
38+
get #foo() { return ""; }
39+
}
40+
41+
class A8 {
42+
set #foo(a: string) {}
43+
set #foo(a: string) {}
44+
}
45+
46+
class A9 {
47+
get #foo() { return ""; }
48+
set #foo(a: string) {}
49+
get #foo() { return ""; }
50+
set #foo(a: string) {}
51+
}
3552

3653

3754
//// [privateNameDuplicateField.js]
3855
"use strict";
39-
var _A_foo, _A_foo_1, _A2_foo, _A2_foo_1, _A2_instances, _A3_foo, _A3_foo_get, _A3_instances, _A4_foo, _A4_foo_1, _A4_instances, _A5_foo, _A5_foo_get, _A5_instances, _A6_foo, _A6_foo_1, _A6_foo_get, _A6_instances;
56+
var _A_foo, _A_foo_1, _A2_foo, _A2_foo_1, _A2_instances, _A3_foo, _A3_foo_get, _A3_instances, _A4_foo, _A4_foo_1, _A4_instances, _A5_foo, _A5_foo_get, _A5_instances, _A6_foo, _A6_foo_1, _A6_foo_get, _A6_instances, _A7_foo_get, _A7_foo_get_1, _A7_instances, _A8_foo_set, _A8_foo_set_1, _A8_instances, _A9_foo_get, _A9_foo_set, _A9_foo_get_1, _A9_foo_set_1, _A9_instances;
4057
class A {
4158
constructor() {
4259
_A_foo_1.set(this, "foo");
@@ -74,3 +91,21 @@ class A6 {
7491
}
7592
}
7693
_A6_foo = new WeakMap(), _A6_instances = new WeakSet(), _A6_foo_get = function _A6_foo_get() { return ""; };
94+
class A7 {
95+
constructor() {
96+
_A7_instances.add(this);
97+
}
98+
}
99+
_A7_instances = new WeakSet(), _A7_foo_get_1 = function _A7_foo_get_1() { return ""; }, _A7_foo_get_1 = function _A7_foo_get_1() { return ""; };
100+
class A8 {
101+
constructor() {
102+
_A8_instances.add(this);
103+
}
104+
}
105+
_A8_instances = new WeakSet(), _A8_foo_set_1 = function _A8_foo_set_1(a) { }, _A8_foo_set_1 = function _A8_foo_set_1(a) { };
106+
class A9 {
107+
constructor() {
108+
_A9_instances.add(this);
109+
}
110+
}
111+
_A9_instances = new WeakSet(), _A9_foo_get_1 = function _A9_foo_get_1() { return ""; }, _A9_foo_set_1 = function _A9_foo_set_1(a) { }, _A9_foo_get_1 = function _A9_foo_get_1() { return ""; }, _A9_foo_set_1 = function _A9_foo_set_1(a) { };

tests/baselines/reference/privateNameDuplicateField.symbols

+40
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,43 @@ class A6 {
6565
>#foo : Symbol(A6.#foo, Decl(privateNameDuplicateField.ts, 30, 23))
6666
}
6767

68+
class A7 {
69+
>A7 : Symbol(A7, Decl(privateNameDuplicateField.ts, 32, 1))
70+
71+
get #foo() { return ""; }
72+
>#foo : Symbol(A7.#foo, Decl(privateNameDuplicateField.ts, 34, 10))
73+
74+
get #foo() { return ""; }
75+
>#foo : Symbol(A7.#foo, Decl(privateNameDuplicateField.ts, 35, 29))
76+
}
77+
78+
class A8 {
79+
>A8 : Symbol(A8, Decl(privateNameDuplicateField.ts, 37, 1))
80+
81+
set #foo(a: string) {}
82+
>#foo : Symbol(A8.#foo, Decl(privateNameDuplicateField.ts, 39, 10))
83+
>a : Symbol(a, Decl(privateNameDuplicateField.ts, 40, 13))
84+
85+
set #foo(a: string) {}
86+
>#foo : Symbol(A8.#foo, Decl(privateNameDuplicateField.ts, 40, 26))
87+
>a : Symbol(a, Decl(privateNameDuplicateField.ts, 41, 13))
88+
}
89+
90+
class A9 {
91+
>A9 : Symbol(A9, Decl(privateNameDuplicateField.ts, 42, 1))
92+
93+
get #foo() { return ""; }
94+
>#foo : Symbol(A9.#foo, Decl(privateNameDuplicateField.ts, 44, 10), Decl(privateNameDuplicateField.ts, 45, 29))
95+
96+
set #foo(a: string) {}
97+
>#foo : Symbol(A9.#foo, Decl(privateNameDuplicateField.ts, 44, 10), Decl(privateNameDuplicateField.ts, 45, 29))
98+
>a : Symbol(a, Decl(privateNameDuplicateField.ts, 46, 13))
99+
100+
get #foo() { return ""; }
101+
>#foo : Symbol(A9.#foo, Decl(privateNameDuplicateField.ts, 46, 26))
102+
103+
set #foo(a: string) {}
104+
>#foo : Symbol(A9.#foo, Decl(privateNameDuplicateField.ts, 47, 29))
105+
>a : Symbol(a, Decl(privateNameDuplicateField.ts, 48, 13))
106+
}
107+

tests/baselines/reference/privateNameDuplicateField.types

+44
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,47 @@ class A6 {
7777
>"" : ""
7878
}
7979

80+
class A7 {
81+
>A7 : A7
82+
83+
get #foo() { return ""; }
84+
>#foo : string
85+
>"" : ""
86+
87+
get #foo() { return ""; }
88+
>#foo : string
89+
>"" : ""
90+
}
91+
92+
class A8 {
93+
>A8 : A8
94+
95+
set #foo(a: string) {}
96+
>#foo : string
97+
>a : string
98+
99+
set #foo(a: string) {}
100+
>#foo : string
101+
>a : string
102+
}
103+
104+
class A9 {
105+
>A9 : A9
106+
107+
get #foo() { return ""; }
108+
>#foo : string
109+
>"" : ""
110+
111+
set #foo(a: string) {}
112+
>#foo : string
113+
>a : string
114+
115+
get #foo() { return ""; }
116+
>#foo : string
117+
>"" : ""
118+
119+
set #foo(a: string) {}
120+
>#foo : string
121+
>a : string
122+
}
123+

tests/cases/conformance/classes/members/privateNames/privateNameDuplicateField.ts

+17
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,20 @@ class A6 {
3434
#foo() { return ""}
3535
get #foo() { return ""}
3636
}
37+
38+
class A7 {
39+
get #foo() { return ""; }
40+
get #foo() { return ""; }
41+
}
42+
43+
class A8 {
44+
set #foo(a: string) {}
45+
set #foo(a: string) {}
46+
}
47+
48+
class A9 {
49+
get #foo() { return ""; }
50+
set #foo(a: string) {}
51+
get #foo() { return ""; }
52+
set #foo(a: string) {}
53+
}

0 commit comments

Comments
 (0)