From c9ee88e5c4f299266dfdb0a6b8010e5ba598d010 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 16 Dec 2014 11:58:47 -0800 Subject: [PATCH] Adding incremental test. --- src/harness/fourslash.ts | 24 ++++--- .../deleteModifierBeforeVarStatement1.ts | 64 +++++++++++++++++++ 2 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 83b6a7a10e1..452e52d3ded 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1217,18 +1217,20 @@ module FourSlash { ts.forEach(fileNames, Harness.IO.log); } - public deleteChar(count = 1, cadence = 10) { + public deleteChar(count = 1) { this.scenarioActions.push(''); var offset = this.currentCaretPosition; var ch = ""; + var checkCadence = (count >> 2) + 1 + for (var i = 0; i < count; i++) { // Make the edit this.languageServiceShimHost.editScript(this.activeFile.fileName, offset, offset + 1, ch); this.updateMarkersForEdit(this.activeFile.fileName, offset, offset + 1, ch); - if (i % cadence === 0) { + if (i % checkCadence === 0) { this.checkPostEditInvariants(); } @@ -1237,7 +1239,7 @@ module FourSlash { var edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); - this.checkPostEditInvariants(); + //this.checkPostEditInvariants(); } } } @@ -1257,11 +1259,12 @@ module FourSlash { this.checkPostEditInvariants(); } - public deleteCharBehindMarker(count = 1, cadence = 10) { + public deleteCharBehindMarker(count = 1) { this.scenarioActions.push(''); var offset = this.currentCaretPosition; var ch = ""; + var checkCadence = (count >> 2) + 1 for (var i = 0; i < count; i++) { offset--; @@ -1269,7 +1272,7 @@ module FourSlash { this.languageServiceShimHost.editScript(this.activeFile.fileName, offset, offset + 1, ch); this.updateMarkersForEdit(this.activeFile.fileName, offset, offset + 1, ch); - if (i % cadence === 0) { + if (i % checkCadence === 0) { this.checkPostEditInvariants(); } @@ -1278,7 +1281,6 @@ module FourSlash { var edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); - this.checkPostEditInvariants(); } } } @@ -1304,9 +1306,11 @@ module FourSlash { // Enters lines of text at the current caret position, invoking // language service APIs to mimic Visual Studio's behavior // as much as possible - private typeHighFidelity(text: string, cadence = 10) { + private typeHighFidelity(text: string) { var offset = this.currentCaretPosition; var prevChar = ' '; + var checkCadence = (text.length >> 2) + 1; + for (var i = 0; i < text.length; i++) { // Make the edit var ch = text.charAt(i); @@ -1324,10 +1328,10 @@ module FourSlash { this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset); } - if (i % cadence === 0) { + if (i % checkCadence === 0) { this.checkPostEditInvariants(); // this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); - this.languageService.getSemanticDiagnostics(this.activeFile.fileName); + // this.languageService.getSemanticDiagnostics(this.activeFile.fileName); } // Handle post-keystroke formatting @@ -1335,7 +1339,7 @@ module FourSlash { var edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); - this.checkPostEditInvariants(); + // this.checkPostEditInvariants(); } } } diff --git a/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts b/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts new file mode 100644 index 00000000000..803d6bf66ce --- /dev/null +++ b/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts @@ -0,0 +1,64 @@ +/// + +//// +//// +//// ///////////////////////////// +//// /// Windows Script Host APIS +//// ///////////////////////////// +//// +//// declare var ActiveXObject: { new (s: string): any; }; +//// +//// interface ITextWriter { +//// WriteLine(s): void; +//// } +//// +//// declare var WScript: { +//// Echo(s): void; +//// StdErr: ITextWriter; +//// Arguments: { length: number; Item(): string; }; +//// ScriptFullName: string; +//// Quit(): number; +//// } +//// + + +goTo.file(0); + +// : +// : |--- go here +// 1: +// 2: +goTo.position(0); + +// : +// : |--- delete "\n\n///..." +// 1: +// 2: +debugger; +edit.deleteAtCaret(100); + + +// 12: +// : |--- go here +// 13: declare var WScript: { +// 14: Echo(s): void; +goTo.position(198); + +// 12: +// : |--- delete "declare..." +// 13: declare var WScript: { +// 14: Echo(s): void; +edit.deleteAtCaret(16); + + +// 9: StdErr: ITextWriter; +// : |--- go here +// 10: Arguments: { length: number; Item(): string; }; +// 11: ScriptFullName: string; +goTo.position(198); + +// 9: StdErr: ITextWriter; +// : |--- insert "Item(): string; " +// 10: Arguments: { length: number; Item(): string; }; +// 11: ScriptFullName: string; +edit.insert("Item(): string; ");