Skip to content

Commit a6a6d77

Browse files
Added fourslash tests for 'this' keyword findOccs/findRefs.
1 parent e6e9979 commit a6a6d77

8 files changed

+1081
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: file1.ts
4+
////this; this;
5+
6+
// @Filename: file2.ts
7+
////this;
8+
////this;
9+
10+
// @Filename: file3.ts
11+
//// ((x = this, y) => t/**/his)(this, this);
12+
13+
goTo.file("file1.ts");
14+
goTo.marker();
15+
verify.referencesCountIs(8);
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////[|this|];
4+
////[|th/**/is|];
5+
////
6+
////function f() {
7+
//// this;
8+
//// this;
9+
//// () => this;
10+
//// () => {
11+
//// if (this) {
12+
//// this;
13+
//// }
14+
//// else {
15+
//// this.this;
16+
//// }
17+
//// }
18+
//// function inside() {
19+
//// this;
20+
//// (function (_) {
21+
//// this;
22+
//// })(this);
23+
//// }
24+
////}
25+
////
26+
////module m {
27+
//// function f() {
28+
//// this;
29+
//// this;
30+
//// () => this;
31+
//// () => {
32+
//// if (this) {
33+
//// this;
34+
//// }
35+
//// else {
36+
//// this.this;
37+
//// }
38+
//// }
39+
//// function inside() {
40+
//// this;
41+
//// (function (_) {
42+
//// this;
43+
//// })(this);
44+
//// }
45+
//// }
46+
////}
47+
////
48+
////class A {
49+
//// public b = this.method1;
50+
////
51+
//// public method1() {
52+
//// this;
53+
//// this;
54+
//// () => this;
55+
//// () => {
56+
//// if (this) {
57+
//// this;
58+
//// }
59+
//// else {
60+
//// this.this;
61+
//// }
62+
//// }
63+
//// function inside() {
64+
//// this;
65+
//// (function (_) {
66+
//// this;
67+
//// })(this);
68+
//// }
69+
//// }
70+
////
71+
//// private method2() {
72+
//// this;
73+
//// this;
74+
//// () => this;
75+
//// () => {
76+
//// if (this) {
77+
//// this;
78+
//// }
79+
//// else {
80+
//// this.this;
81+
//// }
82+
//// }
83+
//// function inside() {
84+
//// this;
85+
//// (function (_) {
86+
//// this;
87+
//// })(this);
88+
//// }
89+
//// }
90+
////
91+
//// public static staticB = this.staticMethod1;
92+
////
93+
//// public static staticMethod1() {
94+
//// this;
95+
//// this;
96+
//// () => this;
97+
//// () => {
98+
//// if (this) {
99+
//// this;
100+
//// }
101+
//// else {
102+
//// this.this;
103+
//// }
104+
//// }
105+
//// function inside() {
106+
//// this;
107+
//// (function (_) {
108+
//// this;
109+
//// })(this);
110+
//// }
111+
//// }
112+
////
113+
//// private static staticMethod2() {
114+
//// this;
115+
//// this;
116+
//// () => this;
117+
//// () => {
118+
//// if (this) {
119+
//// this;
120+
//// }
121+
//// else {
122+
//// this.this;
123+
//// }
124+
//// }
125+
//// function inside() {
126+
//// this;
127+
//// (function (_) {
128+
//// this;
129+
//// })(this);
130+
//// }
131+
//// }
132+
////}
133+
////
134+
////var x = {
135+
//// f() {
136+
//// this;
137+
//// },
138+
//// g() {
139+
//// this;
140+
//// }
141+
////}
142+
143+
test.ranges().forEach(r => {
144+
goTo.position(r.start);
145+
146+
test.ranges().forEach(range => {
147+
verify.occurrencesAtPositionContains(range, false);
148+
});
149+
});
150+
151+
goTo.marker();
152+
test.ranges().forEach(range => {
153+
verify.occurrencesAtPositionContains(range, false);
154+
});
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////this;
4+
////this;
5+
////
6+
////function f() {
7+
//// [|this|];
8+
//// [|this|];
9+
//// () => [|this|];
10+
//// () => {
11+
//// if ([|this|]) {
12+
//// [|this|];
13+
//// }
14+
//// else {
15+
//// [|t/**/his|].this;
16+
//// }
17+
//// }
18+
//// function inside() {
19+
//// this;
20+
//// (function (_) {
21+
//// this;
22+
//// })(this);
23+
//// }
24+
////}
25+
////
26+
////module m {
27+
//// function f() {
28+
//// this;
29+
//// this;
30+
//// () => this;
31+
//// () => {
32+
//// if (this) {
33+
//// this;
34+
//// }
35+
//// else {
36+
//// this.this;
37+
//// }
38+
//// }
39+
//// function inside() {
40+
//// this;
41+
//// (function (_) {
42+
//// this;
43+
//// })(this);
44+
//// }
45+
//// }
46+
////}
47+
////
48+
////class A {
49+
//// public b = this.method1;
50+
////
51+
//// public method1() {
52+
//// this;
53+
//// this;
54+
//// () => this;
55+
//// () => {
56+
//// if (this) {
57+
//// this;
58+
//// }
59+
//// else {
60+
//// this.this;
61+
//// }
62+
//// }
63+
//// function inside() {
64+
//// this;
65+
//// (function (_) {
66+
//// this;
67+
//// })(this);
68+
//// }
69+
//// }
70+
////
71+
//// private method2() {
72+
//// this;
73+
//// this;
74+
//// () => this;
75+
//// () => {
76+
//// if (this) {
77+
//// this;
78+
//// }
79+
//// else {
80+
//// this.this;
81+
//// }
82+
//// }
83+
//// function inside() {
84+
//// this;
85+
//// (function (_) {
86+
//// this;
87+
//// })(this);
88+
//// }
89+
//// }
90+
////
91+
//// public static staticB = this.staticMethod1;
92+
////
93+
//// public static staticMethod1() {
94+
//// this;
95+
//// this;
96+
//// () => this;
97+
//// () => {
98+
//// if (this) {
99+
//// this;
100+
//// }
101+
//// else {
102+
//// this.this;
103+
//// }
104+
//// }
105+
//// function inside() {
106+
//// this;
107+
//// (function (_) {
108+
//// this;
109+
//// })(this);
110+
//// }
111+
//// }
112+
////
113+
//// private static staticMethod2() {
114+
//// this;
115+
//// this;
116+
//// () => this;
117+
//// () => {
118+
//// if (this) {
119+
//// this;
120+
//// }
121+
//// else {
122+
//// this.this;
123+
//// }
124+
//// }
125+
//// function inside() {
126+
//// this;
127+
//// (function (_) {
128+
//// this;
129+
//// })(this);
130+
//// }
131+
//// }
132+
////}
133+
////
134+
////var x = {
135+
//// f() {
136+
//// this;
137+
//// },
138+
//// g() {
139+
//// this;
140+
//// }
141+
////}
142+
143+
test.ranges().forEach(r => {
144+
goTo.position(r.start);
145+
146+
test.ranges().forEach(range => {
147+
verify.occurrencesAtPositionContains(range, false);
148+
});
149+
});
150+
151+
goTo.marker();
152+
test.ranges().forEach(range => {
153+
verify.occurrencesAtPositionContains(range, false);
154+
});

0 commit comments

Comments
 (0)