Skip to content

Commit 2030655

Browse files
author
Arthur Ozga
committed
Merge pull request microsoft#3974 from Microsoft/addReferencesForFourslashInTestDir
Add references for fourslash in test dir
2 parents d3d3333 + c42b9f8 commit 2030655

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed

src/harness/fourslash.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,7 @@ module FourSlash {
18751875
}
18761876
}
18771877

1878-
private verifyProjectInfo(expected: string[]) {
1878+
public verifyProjectInfo(expected: string[]) {
18791879
if (this.testType === FourSlashTestType.Server) {
18801880
let actual = (<ts.server.SessionClient>this.languageService).getProjectInfo(
18811881
this.activeFile.fileName,
@@ -2057,11 +2057,8 @@ module FourSlash {
20572057
return result;
20582058
}
20592059

2060-
public verifGetScriptLexicalStructureListContains(
2061-
name: string,
2062-
kind: string,
2063-
markerPosition?: number) {
2064-
this.taoInvalidReason = 'verifGetScriptLexicalStructureListContains impossible';
2060+
public verifyGetScriptLexicalStructureListContains(name: string, kind: string) {
2061+
this.taoInvalidReason = 'verifyGetScriptLexicalStructureListContains impossible';
20652062

20662063
let items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
20672064

@@ -2263,7 +2260,7 @@ module FourSlash {
22632260
return 'line ' + (pos.line + 1) + ', col ' + pos.character;
22642261
}
22652262

2266-
private getMarkerByName(markerName: string) {
2263+
public getMarkerByName(markerName: string) {
22672264
let markerPos = this.testData.markerPositions[markerName];
22682265
if (markerPos === undefined) {
22692266
let markerNames: string[] = [];
@@ -2738,4 +2735,4 @@ module FourSlash {
27382735
fileName: fileName
27392736
};
27402737
}
2741-
}
2738+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
/// <reference path="fourslash.ts" />
2+
13
//// /*1*/function parseInt(s/*2*/:string):number;
24

35
goTo.marker('2');
46
edit.deleteAtCaret(':string'.length);
57
goTo.marker('1');
6-
edit.insert('declare ');
7-
8+
edit.insert('declare ');

tests/cases/fourslash/fourslash.ts

+30-27
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,34 @@
2929
// type 'fs.' as an alternate way of accessing the top-level objects
3030
// (e.g. 'fs.goTo.eof();')
3131

32+
//---------------------------------------
33+
// For API editors:
34+
// When editting this file, and only while editing this file, enable the reference comments
35+
// and comment out the declarations in this section to get proper type information.
36+
// Undo these changes before compiling/committing/editing any other fourslash tests.
37+
// The test suite will likely crash if you try 'jake runtests' with reference comments enabled.
38+
//
39+
// Explanation:
40+
// We want type-completion while we edit this file, but at compile time/while editting fourslash tests,
41+
// we don't want to include the following reference because we are compiling this file in "--out" mode and don't want to rope
42+
// in the entire codebase into the compilation each fourslash test. Additionally, we don't want to expose the
43+
// src/harness/fourslash.ts API's (or the rest of the compiler) because they are unstable and complicate the
44+
// fourslash testing DSL. Finally, in this case, runtime reflection is (much) faster.
45+
//
46+
// TODO: figure out a better solution to the API exposure problem.
47+
48+
// /// <reference path="../../../built/local/typescriptServices.d.ts"/>
49+
// /// <reference path="../../../src/harness/fourslash.ts"/>
50+
3251
declare var FourSlash;
52+
module ts {
53+
export interface SymbolDisplayPart {
54+
text: string;
55+
kind: string;
56+
}
57+
}
58+
59+
//---------------------------------------------
3360

3461
// Return code used by getEmitOutput function to indicate status of the function
3562
// It is a duplicate of the one in types.ts to expose it to testcases in fourslash
@@ -42,7 +69,6 @@ enum EmitReturnStatus {
4269
}
4370

4471
module FourSlashInterface {
45-
declare var FourSlash;
4672

4773
export interface Marker {
4874
fileName: string;
@@ -201,15 +227,6 @@ module FourSlashInterface {
201227
FourSlash.currentTestState.verifyReferencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess);
202228
}
203229

204-
public implementorsCountIs(count: number) {
205-
FourSlash.currentTestState.verifyImplementorsCountIs(count);
206-
}
207-
208-
// Add tests for this.
209-
public currentParameterIsVariable() {
210-
FourSlash.currentTestState.verifyCurrentParameterIsVariable(!this.negative);
211-
}
212-
213230
public signatureHelpPresent() {
214231
FourSlash.currentTestState.verifySignatureHelpPresent(!this.negative);
215232
}
@@ -361,28 +378,19 @@ module FourSlashInterface {
361378
FourSlash.currentTestState.verifyNoMatchingBracePosition(bracePosition);
362379
}
363380

364-
public setVerifyDocComments(val: boolean) {
365-
FourSlash.currentTestState.setVerifyDocComments(val);
366-
}
367-
368381
public getScriptLexicalStructureListCount(count: number) {
369382
FourSlash.currentTestState.verifyGetScriptLexicalStructureListCount(count);
370383
}
371384

385+
// TODO: figure out what to do with the unused arguments.
372386
public getScriptLexicalStructureListContains(
373387
name: string,
374388
kind: string,
375389
fileName?: string,
376390
parentName?: string,
377391
isAdditionalSpan?: boolean,
378392
markerPosition?: number) {
379-
FourSlash.currentTestState.verifGetScriptLexicalStructureListContains(
380-
name,
381-
kind,
382-
fileName,
383-
parentName,
384-
isAdditionalSpan,
385-
markerPosition);
393+
FourSlash.currentTestState.verifyGetScriptLexicalStructureListContains(name, kind);
386394
}
387395

388396
public navigationItemsListCount(count: number, searchValue: string, matchKind?: string) {
@@ -698,12 +706,7 @@ module fs {
698706
export var format = new FourSlashInterface.format();
699707
export var cancellation = new FourSlashInterface.cancellation();
700708
}
701-
module ts {
702-
export interface SymbolDisplayPart {
703-
text: string;
704-
kind: string;
705-
}
706-
}
709+
707710
function verifyOperationIsCancelled(f) {
708711
FourSlash.verifyOperationIsCancelled(f);
709712
}

0 commit comments

Comments
 (0)