From 38005e7174b442105ba65b50209dbf6b459c2e17 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 21 Jul 2015 14:15:39 -0700 Subject: [PATCH] Add test harnesses --- src/harness/fourslash.ts | 12 ++++++++++++ src/server/client.ts | 2 +- tests/cases/fourslash/fourslash.ts | 13 +++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5c8e6bc8981..9ba15d4f8a0 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1942,6 +1942,18 @@ module FourSlash { } } + public verfiyDocCommentScaffolding(position: number, expected: ts.TextInsertion) { + let actual = this.languageService.getDocCommentScaffoldingAtPosition(this.activeFile.fileName, position); + + if (actual.newText !== expected.newText) { + this.raiseError('verfiyDocCommentScaffolding failed - expected insertion:\n' + expected.newText + 'actual insertion:\n' + actual.newText); + } + + if (actual.cursorOffset !== expected.cursorOffset) { + this.raiseError('verfiyDocCommentScaffolding failed - expected cursorOffset: ' + expected.cursorOffset + ',\tactual cursorOffset:' + actual.cursorOffset); + } + } + public verifyMatchingBracePosition(bracePosition: number, expectedMatchPosition: number) { this.taoInvalidReason = 'verifyMatchingBracePosition NYI'; diff --git a/src/server/client.ts b/src/server/client.ts index 3f6770d7144..59e3d6e8f2e 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -541,7 +541,7 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } - getDocCommentScaffoldingAtPosition(fileName: string, position: number): string { + getDocCommentScaffoldingAtPosition(fileName: string, position: number): TextInsertion { throw new Error("Not Implemented Yet."); } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index a0463073d8c..4edd46bf824 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -269,10 +269,10 @@ module FourSlashInterface { } /** - Compiles the current file and evaluates 'expr' in a context containing - the emitted output, then compares (using ===) the result of that expression - to 'value'. Do not use this function with external modules as it is not supported. - */ + * Compiles the current file and evaluates 'expr' in a context containing + * the emitted output, then compares (using ===) the result of that expression + * to 'value'. Do not use this function with external modules as it is not supported. + */ public eval(expr: string, value: any) { FourSlash.currentTestState.verifyEval(expr, value); } @@ -365,6 +365,11 @@ module FourSlashInterface { FourSlash.currentTestState.setVerifyDocComments(val); } + // Will fix in fourslash-referencing + public DocCommentScaffolding(position: number, expected: ts.TextInsertion) { + FourSlash.currentTestState.verifyDocCommentScaffolding(position, expected); + } + public getScriptLexicalStructureListCount(count: number) { FourSlash.currentTestState.verifyGetScriptLexicalStructureListCount(count); }