From 09caacd4cfceef2fb382689a58729f7ac9cd696d Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 21 Jul 2015 15:29:12 -0700 Subject: [PATCH 1/6] Move declarations to top of tests\cases\fourslash.ts --- tests/cases/fourslash/fourslash.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index a0463073d8c..b963e9a573c 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -1,3 +1,21 @@ +/// + +// declare var FourSlash; +// module ts { +// export interface SymbolDisplayPart { +// text: string; +// kind: string; +// } +// } + +// DO NOT EDIT ABOVE THIS LINE! +// We want type-completion while we edit this file, but at compile time we don't want to include the above reference +// because we are compiling this file in "--out" mode and don't want to rope in the entire codebase +// for each fourslash test. +// So, the compile script manually modifies the aboce code so that we compile correctly. + +//--------------------------------------------- + // Welcome to the FourSlash syntax guide! // A line in the source text is indicated by four slashes (////) @@ -29,7 +47,7 @@ // type 'fs.' as an alternate way of accessing the top-level objects // (e.g. 'fs.goTo.eof();') -declare var FourSlash; +//--------------------------------------- // Return code used by getEmitOutput function to indicate status of the function // It is a duplicate of the one in types.ts to expose it to testcases in fourslash @@ -698,12 +716,7 @@ module fs { export var format = new FourSlashInterface.format(); export var cancellation = new FourSlashInterface.cancellation(); } -module ts { - export interface SymbolDisplayPart { - text: string; - kind: string; - } -} + function verifyOperationIsCancelled(f) { FourSlash.verifyOperationIsCancelled(f); } From b244d0d26307d3241453f6359c4dd3cb1cd339c6 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 21 Jul 2015 15:31:30 -0700 Subject: [PATCH 2/6] fixed a reference in a test --- tests/cases/fourslash/addDeclareToFunction.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/cases/fourslash/addDeclareToFunction.ts b/tests/cases/fourslash/addDeclareToFunction.ts index 46e5d123632..a31713fc56f 100644 --- a/tests/cases/fourslash/addDeclareToFunction.ts +++ b/tests/cases/fourslash/addDeclareToFunction.ts @@ -1,7 +1,8 @@ +/// + //// /*1*/function parseInt(s/*2*/:string):number; goTo.marker('2'); edit.deleteAtCaret(':string'.length); goTo.marker('1'); -edit.insert('declare '); - +edit.insert('declare '); \ No newline at end of file From d7e6fba4d3a24c641b47a694c4bc8b1a217cb717 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 21 Jul 2015 16:20:17 -0700 Subject: [PATCH 3/6] fixed some warts --- src/harness/fourslash.ts | 13 +++++-------- tests/cases/fourslash/fourslash.ts | 25 +++---------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 02ca17cefd7..272f4c1c1dd 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1875,7 +1875,7 @@ module FourSlash { } } - private verifyProjectInfo(expected: string[]) { + public verifyProjectInfo(expected: string[]) { if (this.testType === FourSlashTestType.Server) { let actual = (this.languageService).getProjectInfo( this.activeFile.fileName, @@ -2057,11 +2057,8 @@ module FourSlash { return result; } - public verifGetScriptLexicalStructureListContains( - name: string, - kind: string, - markerPosition?: number) { - this.taoInvalidReason = 'verifGetScriptLexicalStructureListContains impossible'; + public verifyGetScriptLexicalStructureListContains(name: string, kind: string) { + this.taoInvalidReason = 'verifyGetScriptLexicalStructureListContains impossible'; let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); @@ -2263,7 +2260,7 @@ module FourSlash { return 'line ' + (pos.line + 1) + ', col ' + pos.character; } - private getMarkerByName(markerName: string) { + public getMarkerByName(markerName: string) { let markerPos = this.testData.markerPositions[markerName]; if (markerPos === undefined) { let markerNames: string[] = []; @@ -2738,4 +2735,4 @@ module FourSlash { fileName: fileName }; } -} +} \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index b963e9a573c..3abb7f1cee4 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -1,4 +1,4 @@ -/// +/// // declare var FourSlash; // module ts { @@ -60,7 +60,6 @@ enum EmitReturnStatus { } module FourSlashInterface { - declare var FourSlash; export interface Marker { fileName: string; @@ -219,15 +218,6 @@ module FourSlashInterface { FourSlash.currentTestState.verifyReferencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess); } - public implementorsCountIs(count: number) { - FourSlash.currentTestState.verifyImplementorsCountIs(count); - } - - // Add tests for this. - public currentParameterIsVariable() { - FourSlash.currentTestState.verifyCurrentParameterIsVariable(!this.negative); - } - public signatureHelpPresent() { FourSlash.currentTestState.verifySignatureHelpPresent(!this.negative); } @@ -379,14 +369,11 @@ module FourSlashInterface { FourSlash.currentTestState.verifyNoMatchingBracePosition(bracePosition); } - public setVerifyDocComments(val: boolean) { - FourSlash.currentTestState.setVerifyDocComments(val); - } - public getScriptLexicalStructureListCount(count: number) { FourSlash.currentTestState.verifyGetScriptLexicalStructureListCount(count); } + // TODO: figure out what to do with the unused arguments. public getScriptLexicalStructureListContains( name: string, kind: string, @@ -394,13 +381,7 @@ module FourSlashInterface { parentName?: string, isAdditionalSpan?: boolean, markerPosition?: number) { - FourSlash.currentTestState.verifGetScriptLexicalStructureListContains( - name, - kind, - fileName, - parentName, - isAdditionalSpan, - markerPosition); + FourSlash.currentTestState.verifyGetScriptLexicalStructureListContains(name, kind); } public navigationItemsListCount(count: number, searchValue: string, matchKind?: string) { From 851d361a7dfa4527dd4006de395eb8af68f8bdb9 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 21 Jul 2015 18:08:41 -0700 Subject: [PATCH 4/6] Move message after guide --- tests/cases/fourslash/fourslash.ts | 44 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 3abb7f1cee4..31817fb6890 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -1,21 +1,3 @@ -/// - -// declare var FourSlash; -// module ts { -// export interface SymbolDisplayPart { -// text: string; -// kind: string; -// } -// } - -// DO NOT EDIT ABOVE THIS LINE! -// We want type-completion while we edit this file, but at compile time we don't want to include the above reference -// because we are compiling this file in "--out" mode and don't want to rope in the entire codebase -// for each fourslash test. -// So, the compile script manually modifies the aboce code so that we compile correctly. - -//--------------------------------------------- - // Welcome to the FourSlash syntax guide! // A line in the source text is indicated by four slashes (////) @@ -48,6 +30,32 @@ // (e.g. 'fs.goTo.eof();') //--------------------------------------- +// When editting this file, and only while editing this file, enable the reference comments +// and comment out the declarations in this section to get proper type information. +// Undo these changes before compiling/committing/editing any other fourslash tests. +// The test suite will likely crash if you try 'jake runtests' with reference comments enabled. +// +// Explanation: +// We want type-completion while we edit this file, but at compile time/while editting fourslash tests, +// we don't want to include the following reference because we are compiling this file in "--out" mode and don't want to rope +// in the entire codebase into the compilattion each fourslash test. Additionally, we don't want to expose the +// src/harness/fourslash.ts API's (or the rest of the compiler) because they are unstable and complicate the +// fourslash testing DSL. Finally, in this case, runtime reflection is (much) faster. +// +// TODO: figure out a better solution to the API exposure problem. + +// /// +// /// + +declare var FourSlash; +module ts { + export interface SymbolDisplayPart { + text: string; + kind: string; + } +} + +//--------------------------------------------- // Return code used by getEmitOutput function to indicate status of the function // It is a duplicate of the one in types.ts to expose it to testcases in fourslash From 2f7a597dcaaf8e877ad972878b63516b43f966e1 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 21 Jul 2015 18:27:01 -0700 Subject: [PATCH 5/6] Qualification --- tests/cases/fourslash/fourslash.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 31817fb6890..0008b33673f 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -30,6 +30,7 @@ // (e.g. 'fs.goTo.eof();') //--------------------------------------- +// For API editors: // When editting this file, and only while editing this file, enable the reference comments // and comment out the declarations in this section to get proper type information. // Undo these changes before compiling/committing/editing any other fourslash tests. From c42b9f84fe9896567f467bed996825ceb9094049 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 23 Jul 2015 10:53:57 -0700 Subject: [PATCH 6/6] fixed a typo --- tests/cases/fourslash/fourslash.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 0008b33673f..cbba2e916ce 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -39,7 +39,7 @@ // Explanation: // We want type-completion while we edit this file, but at compile time/while editting fourslash tests, // we don't want to include the following reference because we are compiling this file in "--out" mode and don't want to rope -// in the entire codebase into the compilattion each fourslash test. Additionally, we don't want to expose the +// in the entire codebase into the compilation each fourslash test. Additionally, we don't want to expose the // src/harness/fourslash.ts API's (or the rest of the compiler) because they are unstable and complicate the // fourslash testing DSL. Finally, in this case, runtime reflection is (much) faster. //