From d24b3a3cbad7f00d35faeb4137f604f73277b468 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 13 Jul 2017 14:49:50 -0700 Subject: [PATCH] Add fourslash tests for function(new/this:T) syntax --- tests/cases/fourslash/codeFixChangeJSDocSyntax1.ts | 4 ++++ tests/cases/fourslash/completionInJSDocFunctionNew.ts | 10 ++++++++++ .../cases/fourslash/completionInJSDocFunctionThis.ts | 9 +++++++++ .../fourslash/findAllReferencesJSDocFunctionNew.ts | 9 +++++++++ .../fourslash/findAllReferencesJSDocFunctionThis.ts | 11 +++++++++++ tests/cases/fourslash/quickInfoJSDocFunctionNew.ts | 8 ++++++++ tests/cases/fourslash/quickInfoJSDocFunctionThis.ts | 9 +++++++++ 7 files changed, 60 insertions(+) create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax1.ts create mode 100644 tests/cases/fourslash/completionInJSDocFunctionNew.ts create mode 100644 tests/cases/fourslash/completionInJSDocFunctionThis.ts create mode 100644 tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts create mode 100644 tests/cases/fourslash/findAllReferencesJSDocFunctionThis.ts create mode 100644 tests/cases/fourslash/quickInfoJSDocFunctionNew.ts create mode 100644 tests/cases/fourslash/quickInfoJSDocFunctionThis.ts diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax1.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax1.ts new file mode 100644 index 00000000000..93107ef669b --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax1.ts @@ -0,0 +1,4 @@ +/// +//// var x: [|?|] = 12; + +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/completionInJSDocFunctionNew.ts b/tests/cases/fourslash/completionInJSDocFunctionNew.ts new file mode 100644 index 00000000000..9e19964cd25 --- /dev/null +++ b/tests/cases/fourslash/completionInJSDocFunctionNew.ts @@ -0,0 +1,10 @@ + +/// +// @allowJs: true +// @Filename: Foo.js +/////** @type {function (new: string, string): string} */ +////var f = function (s) { return /**/; } + +goTo.marker(); +verify.completionListCount(115); +verify.completionListContains('new', 'new', '', 'keyword'); diff --git a/tests/cases/fourslash/completionInJSDocFunctionThis.ts b/tests/cases/fourslash/completionInJSDocFunctionThis.ts new file mode 100644 index 00000000000..3fe02825d4c --- /dev/null +++ b/tests/cases/fourslash/completionInJSDocFunctionThis.ts @@ -0,0 +1,9 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** @type {function (this: string, string): string} */ +////var f = function (s) { return /**/; } + +goTo.marker(); +verify.completionListCount(115); +verify.completionListContains('this'); diff --git a/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts b/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts new file mode 100644 index 00000000000..e75040d1f77 --- /dev/null +++ b/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts @@ -0,0 +1,9 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** @type {function ([|new|]: string, string): string} */ +////var f; + +const [a0] = test.ranges(); +// should be: verify.referenceGroups([a0], [{ definition: "new", ranges: [a0] }]); +verify.referenceGroups([a0], undefined); diff --git a/tests/cases/fourslash/findAllReferencesJSDocFunctionThis.ts b/tests/cases/fourslash/findAllReferencesJSDocFunctionThis.ts new file mode 100644 index 00000000000..1f00e9f5647 --- /dev/null +++ b/tests/cases/fourslash/findAllReferencesJSDocFunctionThis.ts @@ -0,0 +1,11 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** @type {function (this: string, string): string} */ +////var f = function (s) { return [|this|] + s; } + +const [a0] = test.ranges(); +// should be: verify.referenceGroups([a0, a1], [{ definition: "this", ranges: [a0] }]); + +// but is currently +verify.referenceGroups([], undefined); diff --git a/tests/cases/fourslash/quickInfoJSDocFunctionNew.ts b/tests/cases/fourslash/quickInfoJSDocFunctionNew.ts new file mode 100644 index 00000000000..5fed7d9a39a --- /dev/null +++ b/tests/cases/fourslash/quickInfoJSDocFunctionNew.ts @@ -0,0 +1,8 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** @type {function (new: string, string): string} */ +////var f/**/; + +goTo.marker(); +verify.quickInfoIs('var f: new (arg1: string) => string'); diff --git a/tests/cases/fourslash/quickInfoJSDocFunctionThis.ts b/tests/cases/fourslash/quickInfoJSDocFunctionThis.ts new file mode 100644 index 00000000000..5568ff829f1 --- /dev/null +++ b/tests/cases/fourslash/quickInfoJSDocFunctionThis.ts @@ -0,0 +1,9 @@ + +/// +// @allowJs: true +// @Filename: Foo.js +/////** @type {function (this: string, string): string} */ +////var f/**/ = function (s) { return s; } + +goTo.marker(); +verify.quickInfoIs('var f: (this: string, arg1: string) => string');