Skip to content

Commit d6de3e1

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

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////var x = "[|string|]";
4+
////function f(a = "[|initial value|]") { }
5+
6+
const ranges = test.ranges();
7+
for (let r of ranges) {
8+
goTo.position(r.start);
9+
verify.occurrencesAtPositionCount(0);
10+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////const /*1*/a = 10;
4+
////function foo() {
5+
//// const /*2*/b = /*3*/a;
6+
//// if (b) {
7+
//// const /*4*/b1 = 10;
8+
//// }
9+
////}
10+
////module m {
11+
//// const /*5*/c = 10;
12+
//// export const /*6*/d = 10;
13+
//// if (c) {
14+
//// const /*7*/e = 10;
15+
//// }
16+
////}
17+
////const /*8*/f: () => number = () => 10;
18+
////const /*9*/g = /*10*/f;
19+
/////*11*/f();
20+
////const /*12*/h: { (a: string): number; (a: number): string; } = a => a;
21+
////const /*13*/i = /*14*/h;
22+
/////*15*/h(10);
23+
/////*16*/h("hello");
24+
25+
var marker = 0;
26+
function verifyConst(name: string, typeDisplay: ts.SymbolDisplayPart[], optionalNameDisplay?: ts.SymbolDisplayPart[], optionalKindModifiers?: string) {
27+
marker++;
28+
goTo.marker(marker.toString());
29+
verify.verifyQuickInfoDisplayParts("const", optionalKindModifiers || "", { start: test.markerByName(marker.toString()).position, length: name.length },
30+
[{ text: "const", kind: "keyword" },
31+
{ text: " ", kind: "space" }].concat(optionalNameDisplay || [{ text: name, kind: "localName" }]).concat(
32+
{ text: ":", kind: "punctuation" }, { text: " ", kind: "space" }).concat(typeDisplay),
33+
[]);
34+
}
35+
36+
var numberTypeDisplay: ts.SymbolDisplayPart[] = [{ text: "number", kind: "keyword" }];
37+
38+
verifyConst("a", numberTypeDisplay);
39+
verifyConst("b", numberTypeDisplay);
40+
verifyConst("a", numberTypeDisplay);
41+
verifyConst("b1", numberTypeDisplay);
42+
verifyConst("c", numberTypeDisplay);
43+
verifyConst("d", numberTypeDisplay, [{ text: "m", kind: "moduleName" }, { text: ".", kind: "punctuation" }, { text: "d", kind: "localName" }], "export");
44+
verifyConst("e", numberTypeDisplay);
45+
46+
var functionTypeReturningNumber: ts.SymbolDisplayPart[] = [{ text: "(", kind: "punctuation" }, { text: ")", kind: "punctuation" },
47+
{ text: " ", kind: "space" }, { text: "=>", kind: "punctuation" }, { text: " ", kind: "space" }, { text: "number", kind: "keyword" }];
48+
verifyConst("f", functionTypeReturningNumber);
49+
verifyConst("g", functionTypeReturningNumber);
50+
verifyConst("f", functionTypeReturningNumber);
51+
verifyConst("f", functionTypeReturningNumber);
52+
53+
54+
function getFunctionType(parametertype: string, returnType: string, isArrow?: boolean): ts.SymbolDisplayPart[] {
55+
var functionTypeDisplay = [{ text: "(", kind: "punctuation" }, { text: "a", kind: "parameterName" }, { text: ":", kind: "punctuation" },
56+
{ text: " ", kind: "space" }, { text: parametertype, kind: "keyword" }, { text: ")", kind: "punctuation" }];
57+
58+
if (isArrow) {
59+
functionTypeDisplay = functionTypeDisplay.concat({ text: " ", kind: "space" }, { text: "=>", kind: "punctuation" });
60+
}
61+
else {
62+
functionTypeDisplay = functionTypeDisplay.concat({ text: ":", kind: "punctuation" });
63+
}
64+
65+
return functionTypeDisplay.concat({ text: " ", kind: "space" }, { text: returnType, kind: "keyword" });
66+
}
67+
68+
var typeLiteralWithOverloadCall: ts.SymbolDisplayPart[] = [{ text: "{", kind: "punctuation" }, { text: "\n", kind: "lineBreak" },
69+
{ text: " ", kind: "space" }].concat(getFunctionType("string", "number")).concat(
70+
{ text: ";", kind: "punctuation" }, { text: "\n", kind: "lineBreak" },
71+
{ text: " ", kind: "space" }).concat(getFunctionType("number", "string")).concat(
72+
{ text: ";", kind: "punctuation" }, { text: "\n", kind: "lineBreak" }, { text: "}", kind: "punctuation" });
73+
74+
verifyConst("h", typeLiteralWithOverloadCall);
75+
verifyConst("i", typeLiteralWithOverloadCall);
76+
verifyConst("h", typeLiteralWithOverloadCall);
77+
78+
var overloadDisplay: ts.SymbolDisplayPart[] = [{ text: " ", kind: "space" }, { text: "(", kind: "punctuation" },
79+
{ text: "+", kind: "operator" }, { text: "1", kind: "numericLiteral" },
80+
{ text: " ", kind: "space" }, { text: "overload", kind: "text" }, { text: ")", kind: "punctuation" }];
81+
82+
verifyConst("h", getFunctionType("number", "string", /*isArrow*/true).concat(overloadDisplay));
83+
verifyConst("h", getFunctionType("string", "number", /*isArrow*/true).concat(overloadDisplay));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// References to a unknown index property
4+
5+
////var a;
6+
////a[/**/"blah"];
7+
8+
goTo.marker("");
9+
verify.referencesAre([]);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////var y: "string" = "string;
4+
////var x = "/*1*/string";
5+
////function f(a = "/*2*/initial value") { }
6+
7+
8+
goTo.marker("1");
9+
verify.renameInfoFailed();
10+
11+
goTo.marker("2");
12+
verify.renameInfoFailed();

0 commit comments

Comments
 (0)