Skip to content

Commit f73b4be

Browse files
committed
Revert "Remove failing fourslash tests (may need to be restored and fixed)"
This reverts commit 2f9c9c9.
1 parent d6de3e1 commit f73b4be

File tree

3 files changed

+619
-0
lines changed

3 files changed

+619
-0
lines changed
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////class /*1*/c</*2*/T> {
4+
//// /*3*/constructor(/*4*/a: /*5*/T) {
5+
//// }
6+
//// /*6*/method</*7*/U>(/*8*/a: /*9*/U, /*10*/b: /*11*/T) {
7+
//// return /*12*/a;
8+
//// }
9+
////}
10+
////var /*13*/cInstance = new /*14*/c("Hello");
11+
////var /*15*/cVal = /*16*/c;
12+
/////*17*/cInstance./*18*/method("hello", "cello");
13+
////class /*19*/c2</*20*/T extends /*21*/c<string>> {
14+
//// /*22*/constructor(/*23*/a: /*24*/T) {
15+
//// }
16+
//// /*25*/method</*26*/U extends /*27*/c<string>>(/*28*/a: /*29*/U, /*30*/b: /*31*/T) {
17+
//// return /*32*/a;
18+
//// }
19+
////}
20+
////var /*33*/cInstance1 = new /*34*/c2(/*35*/cInstance);
21+
////var /*36*/cVal2 = /*37*/c2;
22+
/////*38*/cInstance1./*39*/method(/*40*/cInstance, /*41*/cInstance);
23+
24+
var marker = 0;
25+
var markerName: string;
26+
27+
function goToMarker() {
28+
marker++;
29+
markerName = marker.toString();
30+
goTo.marker(markerName);
31+
}
32+
33+
function getTypeParameterDisplay(instanceType: ts.SymbolDisplayPart[],
34+
name: string, optionalExtends?: ts.SymbolDisplayPart[]) {
35+
return instanceType ||
36+
function () {
37+
var typeParameterDisplay = [{ text: name, kind: "typeParameterName" }];
38+
if (optionalExtends) {
39+
typeParameterDisplay.push({ text: " ", kind: "space" }, { text: "extends", kind: "keyword" },
40+
{ text: " ", kind: "space" });
41+
typeParameterDisplay = typeParameterDisplay.concat(optionalExtends);
42+
}
43+
return typeParameterDisplay
44+
} ();
45+
}
46+
47+
function getClassDisplay(name: string, optionalInstanceType?: ts.SymbolDisplayPart[],
48+
optionalExtends?: ts.SymbolDisplayPart[]) {
49+
var classDisplay = [{ text: name, kind: "className" }, { text: "<", kind: "punctuation" }];
50+
classDisplay = classDisplay.concat(getTypeParameterDisplay(optionalInstanceType, "T", optionalExtends));
51+
classDisplay.push({ text: ">", kind: "punctuation" });
52+
return classDisplay;
53+
}
54+
55+
function verifyClassDisplay(name: string, optionalExtends?: ts.SymbolDisplayPart[]) {
56+
goToMarker();
57+
58+
verify.verifyQuickInfoDisplayParts("class", "", { start: test.markerByName(markerName).position, length: name.length },
59+
[{ text: "class", kind: "keyword" }, { text: " ", kind: "space" }].concat(
60+
getClassDisplay(name, undefined, optionalExtends)), []);
61+
}
62+
63+
function verifyTypeParameter(name: string, inDisplay: ts.SymbolDisplayPart[]) {
64+
goToMarker();
65+
66+
var typeParameterDisplay = [{ text: "(", kind: "punctuation" }, { text: "type parameter", kind: "text" }, { text: ")", kind: "punctuation" },
67+
{ text: " ", kind: "space" }, { text: name, kind: "typeParameterName" },
68+
{ text: " ", kind: "space" }, { text: "in", kind: "keyword" }, { text: " ", kind: "space" }];
69+
typeParameterDisplay = typeParameterDisplay.concat(inDisplay);
70+
71+
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName(markerName).position, length: name.length },
72+
typeParameterDisplay, []);
73+
}
74+
75+
function verifyConstructor(name: string, optionalInstanceType?: ts.SymbolDisplayPart[],
76+
optionalExtends?: ts.SymbolDisplayPart[]) {
77+
goToMarker();
78+
var constructorDisplay = [{ text: "constructor", kind: "keyword" },
79+
{ text: " ", kind: "space" }];
80+
constructorDisplay = constructorDisplay.concat(getClassDisplay(name, optionalInstanceType, optionalExtends));
81+
82+
constructorDisplay.push({ text: "(", kind: "punctuation" }, { text: "a", kind: "parameterName" },
83+
{ text: ":", kind: "punctuation" }, { text: " ", kind: "space" });
84+
85+
constructorDisplay = constructorDisplay.concat(
86+
getTypeParameterDisplay(optionalInstanceType, "T"));
87+
88+
constructorDisplay.push({ text: ")", kind: "punctuation" },
89+
{ text: ":", kind: "punctuation" }, { text: " ", kind: "space" });
90+
91+
constructorDisplay = constructorDisplay.concat(getClassDisplay(name, optionalInstanceType));
92+
93+
verify.verifyQuickInfoDisplayParts("constructor", "", { start: test.markerByName(markerName).position, length: optionalInstanceType ? name.length : "constructor".length },
94+
constructorDisplay, []);
95+
}
96+
97+
function verifyParameter(name: string, type: string, optionalExtends?: ts.SymbolDisplayPart[]) {
98+
goToMarker();
99+
var parameterDisplay = [{ text: "(", kind: "punctuation" }, { text: "parameter", kind: "text" }, { text: ")", kind: "punctuation" },
100+
{ text: " ", kind: "space" }, { text: name, kind: "parameterName" }, { text: ":", kind: "punctuation" },
101+
{ text: " ", kind: "space" }, { text: type, kind: "typeParameterName" }];
102+
if (optionalExtends) {
103+
parameterDisplay.push({ text: " ", kind: "space" }, { text: "extends", kind: "keyword" },
104+
{ text: " ", kind: "space" });
105+
parameterDisplay = parameterDisplay.concat(optionalExtends);
106+
}
107+
verify.verifyQuickInfoDisplayParts("parameter", "", { start: test.markerByName(markerName).position, length: name.length },
108+
parameterDisplay, []);
109+
}
110+
111+
function getMethodDisplay(name: string, className: string,
112+
optionalInstanceType?: ts.SymbolDisplayPart[], optionalExtends?: ts.SymbolDisplayPart[]) {
113+
var functionDisplay = getClassDisplay(className, optionalInstanceType, optionalExtends);
114+
115+
functionDisplay.push({ text: ".", kind: "punctuation" }, { text: name, kind: "methodName" },
116+
{ text: "<", kind: "punctuation" });
117+
118+
functionDisplay = functionDisplay.concat(
119+
getTypeParameterDisplay(optionalInstanceType, "U", optionalExtends));
120+
121+
functionDisplay.push({ text: ">", kind: "punctuation" }, { text: "(", kind: "punctuation" },
122+
{ text: "a", kind: "parameterName" }, { text: ":", kind: "punctuation" },
123+
{ text: " ", kind: "space" });
124+
functionDisplay = functionDisplay.concat(
125+
getTypeParameterDisplay(optionalInstanceType, "U"));
126+
functionDisplay.push({ text: ",", kind: "punctuation" },
127+
{ text: " ", kind: "space" }, { text: "b", kind: "parameterName" },
128+
{ text: ":", kind: "punctuation" }, { text: " ", kind: "space" });
129+
functionDisplay = functionDisplay.concat(
130+
getTypeParameterDisplay(optionalInstanceType, "T"));
131+
132+
functionDisplay.push({ text: ")", kind: "punctuation" },
133+
{ text: ":", kind: "punctuation" }, { text: " ", kind: "space" });
134+
135+
functionDisplay = functionDisplay.concat(
136+
getTypeParameterDisplay(optionalInstanceType, "U"));
137+
138+
return functionDisplay;
139+
}
140+
141+
function verifyMethodDisplay(name: string, className: string,
142+
optionalInstanceType?: ts.SymbolDisplayPart[], optionalExtends?: ts.SymbolDisplayPart[]) {
143+
goToMarker();
144+
var functionDisplay = [{ text: "(", kind: "punctuation" }, { text: "method", kind: "text" },
145+
{ text: ")", kind: "punctuation" }, { text: " ", kind: "space" }].concat(
146+
getMethodDisplay(name, className, optionalInstanceType, optionalExtends));
147+
148+
verify.verifyQuickInfoDisplayParts("method", "",
149+
{ start: test.markerByName(markerName).position, length: name.length },
150+
functionDisplay, []);
151+
}
152+
153+
function verifyClassInstance(name: string, typeDisplay: ts.SymbolDisplayPart[]) {
154+
goToMarker();
155+
verify.verifyQuickInfoDisplayParts("var", "", { start: test.markerByName(markerName).position, length: name.length },
156+
[{ text: "var", kind: "keyword" },
157+
{ text: " ", kind: "space" }, { text: name, kind: "localName" }, { text: ":", kind: "punctuation" },
158+
{ text: " ", kind: "space" }].concat(typeDisplay),
159+
[]);
160+
}
161+
162+
function verifyVarTypeOf(name: string, typeOfSymbol: ts.SymbolDisplayPart) {
163+
goToMarker();
164+
verify.verifyQuickInfoDisplayParts("var", "", { start: test.markerByName(markerName).position, length: name.length },
165+
[{ text: "var", kind: "keyword" },
166+
{ text: " ", kind: "space" }, { text: name, kind: "localName" }, { text: ":", kind: "punctuation" },
167+
{ text: " ", kind: "space" }, { text: "typeof", kind: "keyword" },
168+
{ text: " ", kind: "space" }].concat(typeOfSymbol),
169+
[]);
170+
}
171+
172+
var stringTypeDisplay = [{ text: "string", kind: "keyword" }];
173+
var extendsTypeDisplay = getClassDisplay("c", stringTypeDisplay);
174+
175+
// Declaration
176+
verifyClassDisplay("c");
177+
verifyTypeParameter("T", getClassDisplay("c"));
178+
179+
// Constructor declaration
180+
verifyConstructor("c");
181+
verifyParameter("a", "T");
182+
verifyTypeParameter("T", getClassDisplay("c"));
183+
184+
// Method declaration
185+
verifyMethodDisplay("method", "c");
186+
verifyTypeParameter("U", getMethodDisplay("method", "c"));
187+
verifyParameter("a", "U");
188+
verifyTypeParameter("U", getMethodDisplay("method", "c"));
189+
verifyParameter("b", "T");
190+
verifyTypeParameter("T", getClassDisplay("c"));
191+
verifyParameter("a", "U");
192+
193+
// Instance creation
194+
verifyClassInstance("cInstance", getClassDisplay("c", stringTypeDisplay));
195+
verifyConstructor("c", stringTypeDisplay);
196+
197+
// typeof assignment
198+
verifyVarTypeOf("cVal", { text: "c", kind: "className" });
199+
verifyClassDisplay("c");
200+
201+
// Method call
202+
verifyClassInstance("cInstance", getClassDisplay("c", stringTypeDisplay));
203+
verifyMethodDisplay("method", "c", stringTypeDisplay);
204+
205+
// With constraint
206+
// Declaration
207+
verifyClassDisplay("c2", getClassDisplay("c", stringTypeDisplay));
208+
verifyTypeParameter("T", getClassDisplay("c2", /*instanceType*/undefined, extendsTypeDisplay));
209+
verifyClassDisplay("c");
210+
211+
// Constructor declaration
212+
verifyConstructor("c2", /*instanceType*/undefined, extendsTypeDisplay);
213+
verifyParameter("a", "T", extendsTypeDisplay);
214+
verifyTypeParameter("T", getClassDisplay("c2", /*instanceType*/undefined, extendsTypeDisplay));
215+
216+
// Method declaration
217+
verifyMethodDisplay("method", "c2", /*instance*/undefined, extendsTypeDisplay);
218+
verifyTypeParameter("U", getMethodDisplay("method", "c2", /*instance*/undefined, extendsTypeDisplay));
219+
verifyClassDisplay("c");
220+
verifyParameter("a", "U", extendsTypeDisplay);
221+
verifyTypeParameter("U", getMethodDisplay("method", "c2", /*instance*/undefined, extendsTypeDisplay));
222+
verifyParameter("b", "T", extendsTypeDisplay);
223+
verifyTypeParameter("T", getClassDisplay("c2", /*instanceType*/undefined, extendsTypeDisplay));
224+
verifyParameter("a", "U", extendsTypeDisplay);
225+
226+
// Instance creation
227+
verifyClassInstance("cInstance1", getClassDisplay("c2", extendsTypeDisplay));
228+
verifyConstructor("c2", extendsTypeDisplay);
229+
verifyClassInstance("cInstance", getClassDisplay("c", stringTypeDisplay));
230+
231+
// typeof assignment
232+
verifyVarTypeOf("cVal2", { text: "c2", kind: "className" });
233+
verifyClassDisplay("c2", getClassDisplay("c", stringTypeDisplay));
234+
235+
// Method call
236+
verifyClassInstance("cInstance1", getClassDisplay("c2", extendsTypeDisplay));
237+
verifyMethodDisplay("method", "c2", extendsTypeDisplay);
238+
verifyClassInstance("cInstance", getClassDisplay("c", stringTypeDisplay));
239+
verifyClassInstance("cInstance", getClassDisplay("c", stringTypeDisplay));
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
4+
////function /*1*/foo</*2*/U>(/*3*/a: /*4*/U) {
5+
//// return /*5*/a;
6+
////}
7+
/////*6*/foo("Hello");
8+
////function /*7*/foo2</*8*/U extends string>(/*9*/a: /*10*/U) {
9+
//// return /*11*/a;
10+
////}
11+
/////*12*/foo2("hello");
12+
13+
var marker = 0;
14+
var markerName: string;
15+
16+
function goToMarker() {
17+
marker++;
18+
markerName = marker.toString();
19+
goTo.marker(markerName);
20+
}
21+
22+
function getTypeParameterDisplay(instanceType: ts.SymbolDisplayPart[],
23+
name: string, optionalExtends?: ts.SymbolDisplayPart[]) {
24+
return instanceType ||
25+
function () {
26+
var typeParameterDisplay = [{ text: name, kind: "typeParameterName" }];
27+
if (optionalExtends) {
28+
typeParameterDisplay.push({ text: " ", kind: "space" }, { text: "extends", kind: "keyword" },
29+
{ text: " ", kind: "space" });
30+
typeParameterDisplay = typeParameterDisplay.concat(optionalExtends);
31+
}
32+
return typeParameterDisplay
33+
} ();
34+
}
35+
36+
function verifyTypeParameter(name: string, inDisplay: ts.SymbolDisplayPart[]) {
37+
goToMarker();
38+
39+
var typeParameterDisplay = [{ text: "(", kind: "punctuation" }, { text: "type parameter", kind: "text" }, { text: ")", kind: "punctuation" },
40+
{ text: " ", kind: "space" }, { text: name, kind: "typeParameterName" },
41+
{ text: " ", kind: "space" }, { text: "in", kind: "keyword" }, { text: " ", kind: "space" }];
42+
typeParameterDisplay = typeParameterDisplay.concat(inDisplay);
43+
44+
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName(markerName).position, length: name.length },
45+
typeParameterDisplay, []);
46+
}
47+
48+
function verifyParameter(name: string, typeParameterName: string, optionalExtends?: ts.SymbolDisplayPart[]) {
49+
goToMarker();
50+
var parameterDisplay = [{ text: "(", kind: "punctuation" }, { text: "parameter", kind: "text" }, { text: ")", kind: "punctuation" },
51+
{ text: " ", kind: "space" }, { text: name, kind: "parameterName" }, { text: ":", kind: "punctuation" },
52+
{ text: " ", kind: "space" }, { text: typeParameterName, kind: "typeParameterName" }];
53+
if (optionalExtends) {
54+
parameterDisplay.push({ text: " ", kind: "space" }, { text: "extends", kind: "keyword" },
55+
{ text: " ", kind: "space" });
56+
parameterDisplay = parameterDisplay.concat(optionalExtends);
57+
}
58+
verify.verifyQuickInfoDisplayParts("parameter", "", { start: test.markerByName(markerName).position, length: name.length },
59+
parameterDisplay, []);
60+
}
61+
62+
function getFunctionDisplay(name: string, optionalInstanceType?: ts.SymbolDisplayPart[],
63+
optionalExtends?: ts.SymbolDisplayPart[]) {
64+
var functionDisplay = [{ text: name, kind: "functionName" }, { text: "<", kind: "punctuation" }];
65+
66+
functionDisplay = functionDisplay.concat(
67+
getTypeParameterDisplay(optionalInstanceType, "U", optionalExtends));
68+
69+
functionDisplay.push({ text: ">", kind: "punctuation" }, { text: "(", kind: "punctuation" },
70+
{ text: "a", kind: "parameterName" }, { text: ":", kind: "punctuation" },
71+
{ text: " ", kind: "space" });
72+
73+
functionDisplay = functionDisplay.concat(
74+
getTypeParameterDisplay(optionalInstanceType, "U"));
75+
76+
functionDisplay.push({ text: ")", kind: "punctuation" }, { text: ":", kind: "punctuation" },
77+
{ text: " ", kind: "space" });
78+
79+
functionDisplay = functionDisplay.concat(
80+
getTypeParameterDisplay(optionalInstanceType, "U"));
81+
82+
return functionDisplay;
83+
}
84+
85+
function verifyFunctionDisplay(name: string, optionalInstanceType?: ts.SymbolDisplayPart[],
86+
optionalExtends?: ts.SymbolDisplayPart[]) {
87+
goToMarker();
88+
var functionDisplay = [{ text: "function", kind: "keyword" }, { text: " ", kind: "space" }].concat(
89+
getFunctionDisplay(name, optionalInstanceType, optionalExtends));
90+
91+
verify.verifyQuickInfoDisplayParts("function", "",
92+
{ start: test.markerByName(markerName).position, length: name.length },
93+
functionDisplay, []);
94+
}
95+
96+
var stringTypeDisplay = [{ text: "string", kind: "keyword" }];
97+
98+
// Declaration
99+
verifyFunctionDisplay("foo");
100+
verifyTypeParameter("U", getFunctionDisplay("foo"));
101+
verifyParameter("a", "U");
102+
verifyTypeParameter("U", getFunctionDisplay("foo"));
103+
verifyParameter("a", "U");
104+
105+
// Call
106+
verifyFunctionDisplay("foo", stringTypeDisplay);
107+
108+
// With constraint
109+
// Declaration
110+
verifyFunctionDisplay("foo2", /*instance*/ undefined, stringTypeDisplay);
111+
verifyTypeParameter("U", getFunctionDisplay("foo2", /*instance*/ undefined, stringTypeDisplay));
112+
verifyParameter("a", "U", stringTypeDisplay);
113+
verifyTypeParameter("U", getFunctionDisplay("foo2", /*instance*/ undefined, stringTypeDisplay));
114+
verifyParameter("a", "U", stringTypeDisplay);
115+
116+
// Call
117+
verifyFunctionDisplay("foo2", [{ text: "\"hello\"", kind: "stringLiteral" }]);

0 commit comments

Comments
 (0)