Adding incremental test.

This commit is contained in:
Cyrus Najmabadi 2014-12-16 11:58:47 -08:00
parent 0a8744e841
commit c9ee88e5c4
2 changed files with 78 additions and 10 deletions

View File

@ -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('<DeleteCharNext Count="' + count + '" />');
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('<DeleteCharPrevious Count="' + count + '" />');
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();
}
}
}

View File

@ -0,0 +1,64 @@
/// <reference path="../fourslash.ts" />
////
////
//// /////////////////////////////
//// /// 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; ");