diff --git a/test/FsAutoComplete.Tests.Lsp/CoreTests.fs b/test/FsAutoComplete.Tests.Lsp/CoreTests.fs index 08c8f1e68..cfed950c5 100644 --- a/test/FsAutoComplete.Tests.Lsp/CoreTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CoreTests.fs @@ -141,10 +141,7 @@ let initTests createServer = }) let validateSymbolExists msgType symbolInfos predicate = - Expect.exists - symbolInfos - predicate - $"{msgType}s do not contain the expected symbol" + Expect.exists symbolInfos predicate $"{msgType}s do not contain the expected symbol" let allSymbolInfosExist (infos: SymbolInformation seq) predicates = predicates |> List.iter (validateSymbolExists (nameof SymbolInformation) infos) @@ -187,16 +184,12 @@ let documentSymbolTest state = | Ok(Some(U2.C1 symbolInformations)) -> Expect.equal symbolInformations.Length 15 "Document Symbol has all symbols" - allSymbolInfosExist - symbolInformations - [fun n -> n.Name = "MyDateTime" && n.Kind = SymbolKind.Class] + allSymbolInfosExist symbolInformations [ fun n -> n.Name = "MyDateTime" && n.Kind = SymbolKind.Class ] | Ok(Some(U2.C2 documentSymbols)) -> Expect.equal documentSymbols.Length 15 "Document Symbol has all symbols" - allDocumentSymbolsExist - documentSymbols - [fun n -> n.Name = "MyDateTime" && n.Kind = SymbolKind.Class] + allDocumentSymbolsExist documentSymbols [ fun n -> n.Name = "MyDateTime" && n.Kind = SymbolKind.Class ] } ] let workspaceSymbolTest state = @@ -213,8 +206,7 @@ let workspaceSymbolTest state = testList "Workspace Symbols Tests" - [ - testCaseAsync "Get Workspace Symbols Using Filename of Script File as Query" + [ testCaseAsync "Get Workspace Symbols Using Filename of Script File as Query" <| async { let! server, _path = server @@ -231,16 +223,12 @@ let workspaceSymbolTest state = | Ok(Some(U2.C1 symbolInfos)) -> Expect.equal symbolInfos.Length 1 "Workspace did not find all the expected symbols" - allSymbolInfosExist - symbolInfos - [fun n -> n.Name = "Script" && n.Kind = SymbolKind.Module] + allSymbolInfosExist symbolInfos [ fun n -> n.Name = "Script" && n.Kind = SymbolKind.Module ] | Ok(Some(U2.C2 workspaceSymbols)) -> Expect.equal workspaceSymbols.Length 1 "Workspace did not find all the expected symbols" - allWorkspaceSymbolsExist - workspaceSymbols - [fun n -> n.Name = "Script" && n.Kind = SymbolKind.Module] + allWorkspaceSymbolsExist workspaceSymbols [ fun n -> n.Name = "Script" && n.Kind = SymbolKind.Module ] } testCaseAsync "Get Workspace Symbols Using Query w/ Text" @@ -262,26 +250,22 @@ let workspaceSymbolTest state = allSymbolInfosExist symbolInfos - [ - fun n -> n.Name = "X" && n.Kind = SymbolKind.Class + [ fun n -> n.Name = "X" && n.Kind = SymbolKind.Class fun n -> n.Name = "X" && n.Kind = SymbolKind.Class fun n -> n.Name = "X.X" && n.Kind = SymbolKind.Module fun n -> n.Name = "X.Y" && n.Kind = SymbolKind.Module - fun n -> n.Name = "X.Z" && n.Kind = SymbolKind.Class - ] + fun n -> n.Name = "X.Z" && n.Kind = SymbolKind.Class ] | Ok(Some(U2.C2 workspaceSymbols)) -> Expect.equal workspaceSymbols.Length 5 "Workspace did not find all the expected symbols" allWorkspaceSymbolsExist workspaceSymbols - [ - fun n -> n.Name = "X" && n.Kind = SymbolKind.Class + [ fun n -> n.Name = "X" && n.Kind = SymbolKind.Class fun n -> n.Name = "X" && n.Kind = SymbolKind.Class fun n -> n.Name = "X.X" && n.Kind = SymbolKind.Module fun n -> n.Name = "X.Y" && n.Kind = SymbolKind.Module - fun n -> n.Name = "X.Z" && n.Kind = SymbolKind.Class - ] + fun n -> n.Name = "X.Z" && n.Kind = SymbolKind.Class ] } testCaseAsync "Get Workspace Symbols Using Query w/o Text" @@ -298,12 +282,9 @@ let workspaceSymbolTest state = match res with | Result.Error e -> failtestf "Request failed: %A" e | Ok None -> failtest "Request none" - | Ok(Some(U2.C1 res)) -> - Expect.equal res.Length 0 "Workspace found symbols when we didn't expect to find any" - | Ok(Some(U2.C2 res)) -> - Expect.equal res.Length 0 "Workspace found symbols when we didn't expect to find any" - } - ] + | Ok(Some(U2.C1 res)) -> Expect.equal res.Length 0 "Workspace found symbols when we didn't expect to find any" + | Ok(Some(U2.C2 res)) -> Expect.equal res.Length 0 "Workspace found symbols when we didn't expect to find any" + } ] let foldingTests state = @@ -438,7 +419,8 @@ let tooltipTests state = "tooltip evaluation" [ testList "tests" - [ verifyDescription "language keywords" + [ verifyDescription + "language keywords" 0u 2u [ "**Description**" @@ -450,8 +432,13 @@ let tooltipTests state = verifySignature "trigger.innerCharacter" 0u 5u "val arrayOfTuples: (int * int) array" // inner positions trigger verifySignature "uses prefix generics" 1u 5u "val listOfTuples: list" // verify we default to prefix-generics style verifySignature "struct tuple handling" 2u 5u "val listOfStructTuples: list" // verify we render struct tuples in a round-tripabble format - verifySignature "strip meaningless units of measure" 3u 5u "val floatThatShouldHaveGenericReportedInTooltip: float" // verify we strip measure annotations - verifyDescription "tooltip formatting for external library functions" + verifySignature + "strip meaningless units of measure" + 3u + 5u + "val floatThatShouldHaveGenericReportedInTooltip: float" // verify we strip measure annotations + verifyDescription + "tooltip formatting for external library functions" 4u 4u [ "**Description**" @@ -469,7 +456,8 @@ let tooltipTests state = "**Generic Parameters**" "" "* `'T` is `System.String`" ] // verify fancy descriptions for external library functions and correct backticks for multiple segments - verifyDescription "multiple generic parameters are explained" + verifyDescription + "multiple generic parameters are explained" 13u 11u [ "**Description**" @@ -491,34 +479,51 @@ let tooltipTests state = verifySignature "mixed struct and reference tuples" 15u 5u "val nestedStructTuples: int * struct (int * int)" // verify we can differentiate between struct and non-struct tuples verifySignature "units of measure are rendered nicely" 21u 9u "val speed: float" // verify we nicely-render measure annotations // verify formatting of function-parameters to values. NOTE: we want to wrap them in parens for user clarity eventually. - verifySignature "parameters that are functions are wrapped in parens for clarity" + verifySignature + "parameters that are functions are wrapped in parens for clarity" 26u 5u (concatLines [ "val funcWithFunParam:"; " f: (int -> unit) ->"; " i: int"; " -> unit" ]) // verify formatting of tuple args. NOTE: we want to wrap tuples in parens for user clarify eventually. - verifySignature "tuple args are split on each line" + verifySignature + "tuple args are split on each line" 30u 12u (concatLines [ "val funcWithTupleParam:"; " int *"; " int"; " -> int * int" ]) // verify formatting of struct tuple args in parameter tooltips. - verifySignature "struct tuple parameters are rendered correctly" + verifySignature + "struct tuple parameters are rendered correctly" 32u 12u (concatLines [ "val funcWithStructTupleParam:" " f: struct (int * int)" " -> struct (int * int)" ]) - verifySignature "tuple member parameters are gathered on single line" 36u 15u (concatLines [ "member Foo:"; " stuff: int * int * int"; " -> int" ]) - verifySignature "multiple named member parameters are split on each line" + verifySignature + "tuple member parameters are gathered on single line" + 36u + 15u + (concatLines [ "member Foo:"; " stuff: int * int * int"; " -> int" ]) + verifySignature + "multiple named member parameters are split on each line" 37u 15u (concatLines [ "member Bar:"; " a: int *"; " b: int *"; " c: int"; " -> int" ]) // verify formatting for multi-char operators - verifySignature "multi-char operator rendering" 39u 7u (concatLines [ "val ( .>> ):"; " x: int ->"; " y: int"; " -> int" ]) + verifySignature + "multi-char operator rendering" + 39u + 7u + (concatLines [ "val ( .>> ):"; " x: int ->"; " y: int"; " -> int" ]) // verify formatting for single-char operators - verifySignature "single-char operator rendering" 41u 6u (concatLines [ "val ( ^ ):"; " x: int ->"; " y: int"; " -> int" ]) + verifySignature + "single-char operator rendering" + 41u + 6u + (concatLines [ "val ( ^ ):"; " x: int ->"; " y: int"; " -> int" ]) // verify rendering of generic constraints - verifySignature "generic constraints on parameters" + verifySignature + "generic constraints on parameters" 43u 13u (concatLines @@ -527,7 +532,8 @@ let tooltipTests state = " y: 'b (requires static member ( + ))" " -> 'c" ]) //verify rendering of solved generic constraints in tooltips for members where they are solved - verifyDescription "solved generic parameters are called out in tooltip" + verifyDescription + "solved generic parameters are called out in tooltip" 45u 15u [ "**Generic Parameters**" @@ -535,7 +541,8 @@ let tooltipTests state = "* `'a` is `int`" "* `'b` is `int`" "* `'c` is `int`" ] - verifySignature "optional member parameters are rendered with leading question mark" + verifySignature + "optional member parameters are rendered with leading question mark" 48u 28u (concatLines @@ -543,77 +550,99 @@ let tooltipTests state = " body : (MailboxProcessor -> Async) *" " ?cancellationToken: System.Threading.CancellationToken" " -> MailboxProcessor" ]) - verifySignature "union case named parameters are rendered" 54u 9u "Case2 of string * newlineBefore: bool * newlineAfter: bool" - verifySignature "active pattern signatures with potentially-nullable results" + verifySignature + "union case named parameters are rendered" + 54u + 9u + "Case2 of string * newlineBefore: bool * newlineAfter: bool" + verifySignature + "active pattern signatures with potentially-nullable results" 60u 7u (concatLines +#if NET8_0 + [ "active pattern Value: " + " input: Expr" + " -> option" ]) +#else [ "active pattern Value: " " input: Expr" " -> option" ]) - verifySignature "generic constraint rendering for IWSAM" +#endif + verifySignature + "generic constraint rendering for IWSAM" 77u 5u - (concatLines [ - "val testIWSAMTest:" + (concatLines + [ "val testIWSAMTest:" " unit" - " -> Result (requires :> IWSAMTest<'e>)" - ]) - verifySignature "multiple generic constraints for IWASMs" + " -> Result (requires :> IWSAMTest<'e>)" ]) + verifySignature + "multiple generic constraints for IWASMs" 90u 25u - (concatLines [ - "static member GetAwaiter:" + (concatLines + [ "static member GetAwaiter:" " awaitable: 'Awaitable (requires member GetAwaiter)" - " -> Awaiter<^Awaiter,'TResult> (requires :> ICriticalNotifyCompletion and member IsCompleted and member GetResult)" - ]) - verifySignature "basic active pattern" + " -> Awaiter<^Awaiter,'TResult> (requires :> ICriticalNotifyCompletion and member IsCompleted and member GetResult)" ]) + verifySignature + "basic active pattern" 65u 7u (concatLines [ "active pattern DefaultValue: " " input: Expr" " -> option" ]) - verifySignature "basic active pattern with nullability awareness" + verifySignature + "basic active pattern with nullability awareness" 70u 7u (concatLines +#if NET8_0 + [ "active pattern ValueWithName: " + " input: Expr" + " -> option" ]) +#else [ "active pattern ValueWithName: " " input: Expr" " -> option" ]) - verifySignature "interface with members with and without parameter names" +#endif + verifySignature + "interface with members with and without parameter names" 96u 7u (concatLines [ "interface IWithAndWithoutParamNames" " abstract member WithParamNames: arg1: int * arg2: float -> string" " abstract member WithoutParamNames: int * string -> int" ]) - verifySignature "function with unsolved nullable parameter" 102u 7u (concatLines [ - "val usesNullable:" - " x: 't | null" - " -> 't (requires reference)" - ]) - - verifySignature "function with concrete nullable parameter" 103u 7u (concatLines [ - "val usesConcreteNullable:" - " x: string | null" - " -> String" - ]) - verifySignature "function with generic nullable return" 104u 7u (concatLines [ - "val makesNullable:" - " x: 'x" - " -> 'x | null (requires reference)" - ]) - verifySignature "function with concrete nullable return" 105u 7u (concatLines [ - "val makesConcreteNullable:" - " x: string" - " -> string | null" - ]) - verifySignature "function with nullable return from BCL call" 106u 7u (concatLines [ - "val usesBCLNullable:" - " key: string" - " -> string | null" - ])] ] +#if NET8_0_OR_GREATER + verifySignature + "function with unsolved nullable parameter" + 102u + 7u + (concatLines [ "val usesNullable:"; " x: 't | null"; " -> 't (requires reference)" ]) + verifySignature + "function with concrete nullable parameter" + 103u + 7u + (concatLines [ "val usesConcreteNullable:"; " x: string | null"; " -> String" ]) + verifySignature + "function with generic nullable return" + 104u + 7u + (concatLines [ "val makesNullable:"; " x: 'x"; " -> 'x | null (requires reference)" ]) + verifySignature + "function with concrete nullable return" + 105u + 7u + (concatLines [ "val makesConcreteNullable:"; " x: string"; " -> string | null" ]) + verifySignature + "function with nullable return from BCL call" + 106u + 7u + (concatLines [ "val usesBCLNullable:"; " key: string"; " -> string | null" ]) +#endif + ] ] let closeTests state = // Note: clear diagnostics also implies clear caches (-> remove file & project options from State).