80 lines
3.4 KiB
TypeScript
80 lines
3.4 KiB
TypeScript
/// <reference path='fourslash.ts'/>
|
|
|
|
////enum /*1*/E {
|
|
//// /*2*/"e1",
|
|
//// /*3*/'e2' = 10,
|
|
//// /*4*/"e3"
|
|
////}
|
|
////var /*5*/eInstance: /*6*/E;
|
|
/////*7*/eInstance = /*8*/E[/*9*/"e1"];
|
|
/////*10*/eInstance = /*11*/E[/*12*/"e2"];
|
|
/////*13*/eInstance = /*14*/E[/*15*/'e3'];
|
|
////const enum /*16*/constE {
|
|
//// /*17*/"e1",
|
|
//// /*18*/'e2' = 10,
|
|
//// /*19*/"e3"
|
|
////}
|
|
////var /*20*/eInstance1: /*21*/constE;
|
|
/////*22*/eInstance1 = /*23*/constE[/*24*/"e1"];
|
|
/////*25*/eInstance1 = /*26*/constE[/*27*/"e2"];
|
|
/////*28*/eInstance1 = /*29*/constE[/*30*/'e3'];
|
|
|
|
var marker = 0;
|
|
function verifyEnumDeclaration(enumName: string, instanceName: string, isConst?: boolean) {
|
|
verifyEnumDisplay();
|
|
|
|
verifyEnumMemberDisplay('"e1"', /*spanLength*/ 4, 0);
|
|
verifyEnumMemberDisplay("'e2'", /*spanLength*/ 4, 10);
|
|
verifyEnumMemberDisplay('"e3"', /*spanLength*/ 4, 11);
|
|
|
|
verifyInstance();
|
|
verifyEnumDisplay();
|
|
|
|
verifyInstance();
|
|
verifyEnumDisplay();
|
|
verifyEnumMemberDisplay('"e1"', /*spanLength*/ 4, 0);
|
|
|
|
verifyInstance();
|
|
verifyEnumDisplay();
|
|
verifyEnumMemberDisplay("'e2'", /*spanLength*/ 4, 10);
|
|
|
|
verifyInstance();
|
|
verifyEnumDisplay();
|
|
verifyEnumMemberDisplay('"e3"', /*spanLength*/ 4, 11);
|
|
|
|
function verifyEnumDisplay() {
|
|
marker++;
|
|
goTo.marker(marker.toString());
|
|
verify.verifyQuickInfoDisplayParts("enum", "", { start: test.markerByName(marker.toString()).position, length: enumName.length },
|
|
(isConst ? [{ text: "const", kind: "keyword" }, { text: " ", kind: "space" }] : []).concat(
|
|
[{ text: "enum", kind: "keyword" }, { text: " ", kind: "space" }, { text: enumName, kind: "enumName" }]),
|
|
[]);;
|
|
}
|
|
|
|
function verifyEnumMemberDisplay(enumMemberName: string, spanLength: number, initializer: number) {
|
|
marker++;
|
|
goTo.marker(marker.toString());
|
|
// Each of these names is a string literal,
|
|
// but since they're accessed by property accesses,
|
|
// we need to account for the quotes at the beginning and end.
|
|
verify.verifyQuickInfoDisplayParts("var", "", { start: test.markerByName(marker.toString()).position, length: spanLength },
|
|
[{ text: "(", kind: "punctuation" }, { text: "enum member", kind: "text" }, { text: ")", kind: "punctuation" },
|
|
{ text: " ", kind: "space" }, { text: enumName, kind: "enumName" }, { text: "[", kind: "punctuation" }, { text: enumMemberName, kind: "stringLiteral" }, { text: "]", kind: "punctuation" },
|
|
{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { text: " ", kind: "space" }, { text: initializer.toString(), kind: "numericLiteral" }],
|
|
[]);
|
|
}
|
|
|
|
function verifyInstance() {
|
|
marker++;
|
|
goTo.marker(marker.toString());
|
|
verify.verifyQuickInfoDisplayParts("var", "", { start: test.markerByName(marker.toString()).position, length: instanceName.length },
|
|
[{ text: "var", kind: "keyword" },
|
|
{ text: " ", kind: "space" }, { text: instanceName, kind: "localName" }, { text: ":", kind: "punctuation" },
|
|
{ text: " ", kind: "space" }, { text: enumName, kind: "enumName" }],
|
|
[]);
|
|
}
|
|
}
|
|
|
|
verifyEnumDeclaration("E", "eInstance");
|
|
marker = 15;
|
|
//verifyEnumDeclaration("constE", "eInstance1", /*isConst*/ true);
|