mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-23 18:48:40 -05:00
Always run all fourslash tests in high fidelity typing mode.
We want to verify after every edit that our incremental data is correct.
This commit is contained in:
@@ -96,19 +96,6 @@ module FourSlash {
|
||||
end: number;
|
||||
}
|
||||
|
||||
export enum IncrementalEditValidation {
|
||||
None,
|
||||
SyntacticOnly,
|
||||
Complete
|
||||
}
|
||||
|
||||
export enum TypingFidelity {
|
||||
/// Performs typing and formatting (if formatting is enabled)
|
||||
Low,
|
||||
/// Performs typing, checks completion lists, signature help, and formatting (if enabled)
|
||||
High
|
||||
}
|
||||
|
||||
var entityMap: ts.Map<string> = {
|
||||
'&': '&',
|
||||
'"': '"',
|
||||
@@ -279,9 +266,6 @@ module FourSlash {
|
||||
|
||||
public cancellationToken: TestCancellationToken;
|
||||
|
||||
public editValidation = IncrementalEditValidation.Complete;
|
||||
public typingFidelity = TypingFidelity.Low;
|
||||
|
||||
private scenarioActions: string[] = [];
|
||||
private taoInvalidReason: string = null;
|
||||
|
||||
@@ -1305,38 +1289,7 @@ module FourSlash {
|
||||
this.scenarioActions.push('<InsertText><![CDATA[' + text + ']]></InsertText>');
|
||||
}
|
||||
|
||||
if (this.typingFidelity === TypingFidelity.Low) {
|
||||
return this.typeLowFidelity(text);
|
||||
} else {
|
||||
return this.typeHighFidelity(text);
|
||||
}
|
||||
}
|
||||
|
||||
private typeLowFidelity(text: string) {
|
||||
var offset = this.currentCaretPosition;
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
// Make the edit
|
||||
var ch = text.charAt(i);
|
||||
this.languageServiceShimHost.editScript(this.activeFile.fileName, offset, offset, ch);
|
||||
this.updateMarkersForEdit(this.activeFile.fileName, offset, offset, ch);
|
||||
this.checkPostEditInvariants();
|
||||
offset++;
|
||||
|
||||
// Handle post-keystroke formatting
|
||||
if (this.enableFormatting) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move the caret to wherever we ended up
|
||||
this.currentCaretPosition = offset;
|
||||
|
||||
this.fixCaretPosition();
|
||||
this.checkPostEditInvariants();
|
||||
return this.typeHighFidelity(text);
|
||||
}
|
||||
|
||||
// Enters lines of text at the current caret position, invoking
|
||||
@@ -1380,7 +1333,6 @@ module FourSlash {
|
||||
this.currentCaretPosition = offset;
|
||||
|
||||
this.fixCaretPosition();
|
||||
|
||||
this.checkPostEditInvariants();
|
||||
}
|
||||
|
||||
@@ -1410,10 +1362,6 @@ module FourSlash {
|
||||
}
|
||||
|
||||
private checkPostEditInvariants() {
|
||||
if (this.editValidation === IncrementalEditValidation.None) {
|
||||
return;
|
||||
}
|
||||
|
||||
var incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName);
|
||||
var incrementalSyntaxDiagnostics = JSON.stringify(Utils.convertDiagnostics(incrementalSourceFile.getSyntacticDiagnostics()));
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
//// }
|
||||
|
||||
edit.disableFormatting();
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.SyntacticOnly);
|
||||
|
||||
goTo.marker('check');
|
||||
verify.quickInfoIs('module Mod');
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////module A {
|
||||
//// /*var*/
|
||||
////}
|
||||
////module /*check*/A {
|
||||
//// var p;
|
||||
////}
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.SyntacticOnly);
|
||||
|
||||
goTo.marker('check');
|
||||
verify.quickInfoExists();
|
||||
|
||||
goTo.marker('var');
|
||||
edit.insert('var o;');
|
||||
|
||||
goTo.marker('check');
|
||||
verify.quickInfoExists();
|
||||
|
||||
////}
|
||||
|
||||
goTo.marker('check');
|
||||
verify.quickInfoExists();
|
||||
|
||||
goTo.marker('var');
|
||||
edit.insert('var o;');
|
||||
|
||||
goTo.marker('check');
|
||||
verify.quickInfoExists();
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
////second.start();
|
||||
////second.stop();
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
goTo.file("findAllRefsOnDefinition-import.ts");
|
||||
goTo.marker("1");
|
||||
|
||||
@@ -38,4 +36,3 @@ verifyOperationIsCancelled(() => verify.referencesCountIs(0) );
|
||||
cancellation.resetCancelled();
|
||||
goTo.marker("1");
|
||||
verify.referencesCountIs(2);
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed
|
||||
edit.insert('');
|
||||
|
||||
diagnostics.setTypingFidelity(TypingFidelity.High);
|
||||
|
||||
goTo.marker('1');
|
||||
verify.completionListContains('foo');
|
||||
verify.completionListContains('foo2');
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed
|
||||
edit.insert('');
|
||||
diagnostics.setTypingFidelity(TypingFidelity.High);
|
||||
|
||||
goTo.marker('1');
|
||||
verify.completionListContains('foo');
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
//// var f4 = <T>(x: T/**/ ) => {
|
||||
//// }
|
||||
|
||||
// Turn off edit validation. We don't want semantic diagnostics to run until we explicit call it.
|
||||
fs.diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
fs.goTo.marker();
|
||||
|
||||
// Replace the "T" type with the non-existent type 'V'.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
////var x = Object.create(/**/
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
goTo.marker();
|
||||
verify.not.completionListIsEmpty();
|
||||
edit.insert("nu");
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
//// }
|
||||
////}
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
verify.numberOfErrorsInCurrentFile(0);
|
||||
|
||||
// Edit and bind and resolve only var decl
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
////second.start();
|
||||
////second.stop();
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
goTo.file("findAllRefsOnDefinition-import.ts");
|
||||
goTo.marker("1");
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
////var start: Second.Test.start;
|
||||
////var stop: Second.Test.stop;
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
goTo.file("findAllRefsOnDefinition2-import.ts");
|
||||
goTo.marker("1");
|
||||
|
||||
|
||||
@@ -31,19 +31,6 @@
|
||||
|
||||
declare var FourSlash;
|
||||
|
||||
enum IncrementalEditValidation {
|
||||
None = FourSlash.IncrementalEditValidation.None,
|
||||
SyntacticOnly = FourSlash.IncrementalEditValidation.SyntacticOnly,
|
||||
Complete = FourSlash.IncrementalEditValidation.Complete
|
||||
}
|
||||
|
||||
enum TypingFidelity {
|
||||
/** Performs typing and formatting (if formatting is enabled) */
|
||||
Low = FourSlash.TypingFidelity.Low,
|
||||
/** Performs typing, checks completion lists, signature help, and formatting (if enabled) */
|
||||
High = FourSlash.TypingFidelity.High
|
||||
}
|
||||
|
||||
// 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
|
||||
enum EmitReturnStatus {
|
||||
@@ -101,14 +88,6 @@ module FourSlashInterface {
|
||||
public validateTypesAtPositions(...positions: number[]) {
|
||||
return FourSlash.currentTestState.verifyTypesAgainstFullCheckAtPositions(positions);
|
||||
}
|
||||
|
||||
public setEditValidation(validation: IncrementalEditValidation) {
|
||||
FourSlash.currentTestState.editValidation = validation;
|
||||
}
|
||||
|
||||
public setTypingFidelity(fidelity: TypingFidelity) {
|
||||
FourSlash.currentTestState.typingFidelity = fidelity;
|
||||
}
|
||||
}
|
||||
|
||||
export class goTo {
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
////var bbb: string;
|
||||
/////*1*/
|
||||
|
||||
// Disable test triggered type check
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
goTo.marker("1");
|
||||
verify.completionListContains("aaa");
|
||||
verify.completionListContains("bbb");
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
/////*1*/
|
||||
////interface Foo {
|
||||
//// setISO8601(dString): Date;
|
||||
////}
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
////}
|
||||
|
||||
// Do resolve without typeCheck
|
||||
goTo.marker('1');
|
||||
@@ -14,4 +12,4 @@ edit.insert("alert(");
|
||||
verify.currentSignatureHelpIs("alert(message?: any): void");
|
||||
|
||||
// TypeCheck
|
||||
verify.errorExistsAfterMarker('1');
|
||||
verify.errorExistsAfterMarker('1');
|
||||
@@ -20,7 +20,5 @@
|
||||
// Force a syntax tree ot be created.
|
||||
verify.noMatchingBracePositionInCurrentFile(0);
|
||||
|
||||
// make sure we check the tree after every edit.
|
||||
diagnostics.setTypingFidelity(TypingFidelity.High);
|
||||
goTo.marker('1');
|
||||
edit.insert('Fo');
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
//// }
|
||||
////}
|
||||
////var val = new c1();
|
||||
////var b = val.p1;
|
||||
/////*1*/b;
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
////var b = val.p1;
|
||||
/////*1*/b;
|
||||
|
||||
// Resolve without typeCheck
|
||||
goTo.marker('1');
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
//// }
|
||||
////}
|
||||
////var val = new c1("hello");
|
||||
/////*1*/val;
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
/////*1*/val;
|
||||
|
||||
// Do resolve without typeCheck
|
||||
goTo.marker('1');
|
||||
|
||||
@@ -19,13 +19,10 @@
|
||||
//// });
|
||||
////}
|
||||
////var val = foo(["myString1", "myString2"]);
|
||||
/////*1*/val;
|
||||
/////*1*/val;
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
// Do resolve without typeCheck
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs("(var) val: string");
|
||||
|
||||
// TypeCheck
|
||||
verify.numberOfErrorsInCurrentFile(1);
|
||||
verify.numberOfErrorsInCurrentFile(1);
|
||||
@@ -16,7 +16,5 @@
|
||||
//// var /*1*/r4 = a(1, true);
|
||||
////}
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs("(var) r4: number");
|
||||
verify.quickInfoIs("(var) r4: number");
|
||||
@@ -12,8 +12,6 @@
|
||||
//// var r/*2*/4 = b.b/*1*/ar; // string
|
||||
////}
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs("(property) B<string>.bar: string", undefined);
|
||||
edit.deleteAtCaret(1);
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
//// var r = a.fo/*1*/o + a.bar;
|
||||
////}
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs("(property) M2.A.foo: string", undefined);
|
||||
verify.numberOfErrorsInCurrentFile(0);
|
||||
@@ -10,6 +10,5 @@
|
||||
////}
|
||||
////new class/*1*/InheritingSpecializedClass();
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
goTo.marker('1');
|
||||
verify.quickInfoExists();
|
||||
@@ -2,13 +2,12 @@
|
||||
|
||||
// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file0.ts
|
||||
////declare function fn(x: string, y: number);
|
||||
|
||||
|
||||
// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file1.ts
|
||||
////declare function fn(x: string);
|
||||
|
||||
|
||||
// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file2.ts
|
||||
////fn(/*1*/
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
goTo.marker('1');
|
||||
////fn(/*1*/
|
||||
|
||||
goTo.marker('1');
|
||||
verify.signatureHelpCountIs(2);
|
||||
@@ -8,7 +8,6 @@
|
||||
//// }
|
||||
////}
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
goTo.marker("1");
|
||||
edit.insert("super(");
|
||||
verify.currentSignatureHelpIs("B(x: string): B");
|
||||
@@ -13,8 +13,6 @@
|
||||
//// }
|
||||
////
|
||||
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.SyntacticOnly);
|
||||
|
||||
goTo.marker('addParam');
|
||||
|
||||
edit.insert(", X");
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
/////*start*/class Point implements /*IPointRef*/IPoint {
|
||||
//// getDist() {
|
||||
//// ssss;
|
||||
//// }
|
||||
////}/*end*/
|
||||
|
||||
// make sure no typeCheck is triggered after edit
|
||||
diagnostics.setEditValidation(IncrementalEditValidation.None);
|
||||
|
||||
// Edit to invalidate the intial typeCheck state
|
||||
goTo.eof();
|
||||
edit.insertLine("");
|
||||
|
||||
// Attempt to resolve a symbol
|
||||
goTo.marker("IPointRef");
|
||||
verify.quickInfoIs(""); // not found
|
||||
|
||||
// trigger typecheck after the partial resolve, we should see errors
|
||||
verify.errorExistsAfterMarker("IPointRef");
|
||||
|
||||
goTo.eof();
|
||||
edit.insertLine("");
|
||||
|
||||
// one more time with full typecheck
|
||||
verify.errorExistsAfterMarker("IPointRef");
|
||||
|
||||
////}/*end*/
|
||||
|
||||
// Edit to invalidate the intial typeCheck state
|
||||
goTo.eof();
|
||||
edit.insertLine("");
|
||||
|
||||
// Attempt to resolve a symbol
|
||||
goTo.marker("IPointRef");
|
||||
verify.quickInfoIs(""); // not found
|
||||
|
||||
// trigger typecheck after the partial resolve, we should see errors
|
||||
verify.errorExistsAfterMarker("IPointRef");
|
||||
|
||||
goTo.eof();
|
||||
edit.insertLine("");
|
||||
|
||||
// one more time with full typecheck
|
||||
verify.errorExistsAfterMarker("IPointRef");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user