@@ -141,10 +141,7 @@ let initTests createServer =
141141 })
142142
143143let validateSymbolExists msgType symbolInfos predicate =
144- Expect.exists
145- symbolInfos
146- predicate
147- $" {msgType}s do not contain the expected symbol"
144+ Expect.exists symbolInfos predicate $" {msgType}s do not contain the expected symbol"
148145
149146let allSymbolInfosExist ( infos : SymbolInformation seq ) predicates =
150147 predicates |> List.iter ( validateSymbolExists ( nameof SymbolInformation) infos)
@@ -187,16 +184,12 @@ let documentSymbolTest state =
187184 | Ok( Some( U2.C1 symbolInformations)) ->
188185 Expect.equal symbolInformations.Length 15 " Document Symbol has all symbols"
189186
190- allSymbolInfosExist
191- symbolInformations
192- [ fun n -> n.Name = " MyDateTime" && n.Kind = SymbolKind.Class]
187+ allSymbolInfosExist symbolInformations [ fun n -> n.Name = " MyDateTime" && n.Kind = SymbolKind.Class ]
193188
194189 | Ok( Some( U2.C2 documentSymbols)) ->
195190 Expect.equal documentSymbols.Length 15 " Document Symbol has all symbols"
196191
197- allDocumentSymbolsExist
198- documentSymbols
199- [ fun n -> n.Name = " MyDateTime" && n.Kind = SymbolKind.Class]
192+ allDocumentSymbolsExist documentSymbols [ fun n -> n.Name = " MyDateTime" && n.Kind = SymbolKind.Class ]
200193 } ]
201194
202195let workspaceSymbolTest state =
@@ -213,8 +206,7 @@ let workspaceSymbolTest state =
213206
214207 testList
215208 " Workspace Symbols Tests"
216- [
217- testCaseAsync " Get Workspace Symbols Using Filename of Script File as Query"
209+ [ testCaseAsync " Get Workspace Symbols Using Filename of Script File as Query"
218210 <| async {
219211 let! server , _path = server
220212
@@ -231,16 +223,12 @@ let workspaceSymbolTest state =
231223 | Ok( Some( U2.C1 symbolInfos)) ->
232224 Expect.equal symbolInfos.Length 1 " Workspace did not find all the expected symbols"
233225
234- allSymbolInfosExist
235- symbolInfos
236- [ fun n -> n.Name = " Script" && n.Kind = SymbolKind.Module]
226+ allSymbolInfosExist symbolInfos [ fun n -> n.Name = " Script" && n.Kind = SymbolKind.Module ]
237227
238228 | Ok( Some( U2.C2 workspaceSymbols)) ->
239229 Expect.equal workspaceSymbols.Length 1 " Workspace did not find all the expected symbols"
240230
241- allWorkspaceSymbolsExist
242- workspaceSymbols
243- [ fun n -> n.Name = " Script" && n.Kind = SymbolKind.Module]
231+ allWorkspaceSymbolsExist workspaceSymbols [ fun n -> n.Name = " Script" && n.Kind = SymbolKind.Module ]
244232 }
245233
246234 testCaseAsync " Get Workspace Symbols Using Query w/ Text"
@@ -262,26 +250,22 @@ let workspaceSymbolTest state =
262250
263251 allSymbolInfosExist
264252 symbolInfos
265- [
266- fun n -> n.Name = " X" && n.Kind = SymbolKind.Class
253+ [ fun n -> n.Name = " X" && n.Kind = SymbolKind.Class
267254 fun n -> n.Name = " X" && n.Kind = SymbolKind.Class
268255 fun n -> n.Name = " X.X" && n.Kind = SymbolKind.Module
269256 fun n -> n.Name = " X.Y" && n.Kind = SymbolKind.Module
270- fun n -> n.Name = " X.Z" && n.Kind = SymbolKind.Class
271- ]
257+ fun n -> n.Name = " X.Z" && n.Kind = SymbolKind.Class ]
272258
273259 | Ok( Some( U2.C2 workspaceSymbols)) ->
274260 Expect.equal workspaceSymbols.Length 5 " Workspace did not find all the expected symbols"
275261
276262 allWorkspaceSymbolsExist
277263 workspaceSymbols
278- [
279- fun n -> n.Name = " X" && n.Kind = SymbolKind.Class
264+ [ fun n -> n.Name = " X" && n.Kind = SymbolKind.Class
280265 fun n -> n.Name = " X" && n.Kind = SymbolKind.Class
281266 fun n -> n.Name = " X.X" && n.Kind = SymbolKind.Module
282267 fun n -> n.Name = " X.Y" && n.Kind = SymbolKind.Module
283- fun n -> n.Name = " X.Z" && n.Kind = SymbolKind.Class
284- ]
268+ fun n -> n.Name = " X.Z" && n.Kind = SymbolKind.Class ]
285269 }
286270
287271 testCaseAsync " Get Workspace Symbols Using Query w/o Text"
@@ -298,12 +282,9 @@ let workspaceSymbolTest state =
298282 match res with
299283 | Result.Error e -> failtestf " Request failed: %A " e
300284 | Ok None -> failtest " Request none"
301- | Ok( Some( U2.C1 res)) ->
302- Expect.equal res.Length 0 " Workspace found symbols when we didn't expect to find any"
303- | Ok( Some( U2.C2 res)) ->
304- Expect.equal res.Length 0 " Workspace found symbols when we didn't expect to find any"
305- }
306- ]
285+ | Ok( Some( U2.C1 res)) -> Expect.equal res.Length 0 " Workspace found symbols when we didn't expect to find any"
286+ | Ok( Some( U2.C2 res)) -> Expect.equal res.Length 0 " Workspace found symbols when we didn't expect to find any"
287+ } ]
307288
308289
309290let foldingTests state =
@@ -438,7 +419,8 @@ let tooltipTests state =
438419 " tooltip evaluation"
439420 [ testList
440421 " tests"
441- [ verifyDescription " language keywords"
422+ [ verifyDescription
423+ " language keywords"
442424 0 u
443425 2 u
444426 [ " **Description**"
@@ -450,8 +432,13 @@ let tooltipTests state =
450432 verifySignature " trigger.innerCharacter" 0 u 5 u " val arrayOfTuples: (int * int) array" // inner positions trigger
451433 verifySignature " uses prefix generics" 1 u 5 u " val listOfTuples: list<int * int>" // verify we default to prefix-generics style
452434 verifySignature " struct tuple handling" 2 u 5 u " val listOfStructTuples: list<struct (int * int)>" // verify we render struct tuples in a round-tripabble format
453- verifySignature " strip meaningless units of measure" 3 u 5 u " val floatThatShouldHaveGenericReportedInTooltip: float" // verify we strip <MeasureOne> measure annotations
454- verifyDescription " tooltip formatting for external library functions"
435+ verifySignature
436+ " strip meaningless units of measure"
437+ 3 u
438+ 5 u
439+ " val floatThatShouldHaveGenericReportedInTooltip: float" // verify we strip <MeasureOne> measure annotations
440+ verifyDescription
441+ " tooltip formatting for external library functions"
455442 4 u
456443 4 u
457444 [ " **Description**"
@@ -469,7 +456,8 @@ let tooltipTests state =
469456 " **Generic Parameters**"
470457 " "
471458 " * `'T` is `System.String`" ] // verify fancy descriptions for external library functions and correct backticks for multiple segments
472- verifyDescription " multiple generic parameters are explained"
459+ verifyDescription
460+ " multiple generic parameters are explained"
473461 13 u
474462 11 u
475463 [ " **Description**"
@@ -491,34 +479,51 @@ let tooltipTests state =
491479 verifySignature " mixed struct and reference tuples" 15 u 5 u " val nestedStructTuples: int * struct (int * int)" // verify we can differentiate between struct and non-struct tuples
492480 verifySignature " units of measure are rendered nicely" 21 u 9 u " val speed: float<m/s>" // verify we nicely-render measure annotations
493481 // verify formatting of function-parameters to values. NOTE: we want to wrap them in parens for user clarity eventually.
494- verifySignature " parameters that are functions are wrapped in parens for clarity"
482+ verifySignature
483+ " parameters that are functions are wrapped in parens for clarity"
495484 26 u
496485 5 u
497486 ( concatLines [ " val funcWithFunParam:" ; " f: (int -> unit) ->" ; " i: int" ; " -> unit" ])
498487 // verify formatting of tuple args. NOTE: we want to wrap tuples in parens for user clarify eventually.
499- verifySignature " tuple args are split on each line"
488+ verifySignature
489+ " tuple args are split on each line"
500490 30 u
501491 12 u
502492 ( concatLines [ " val funcWithTupleParam:" ; " int *" ; " int" ; " -> int * int" ])
503493 // verify formatting of struct tuple args in parameter tooltips.
504- verifySignature " struct tuple parameters are rendered correctly"
494+ verifySignature
495+ " struct tuple parameters are rendered correctly"
505496 32 u
506497 12 u
507498 ( concatLines
508499 [ " val funcWithStructTupleParam:"
509500 " f: struct (int * int)"
510501 " -> struct (int * int)" ])
511- verifySignature " tuple member parameters are gathered on single line" 36 u 15 u ( concatLines [ " member Foo:" ; " stuff: int * int * int" ; " -> int" ])
512- verifySignature " multiple named member parameters are split on each line"
502+ verifySignature
503+ " tuple member parameters are gathered on single line"
504+ 36 u
505+ 15 u
506+ ( concatLines [ " member Foo:" ; " stuff: int * int * int" ; " -> int" ])
507+ verifySignature
508+ " multiple named member parameters are split on each line"
513509 37 u
514510 15 u
515511 ( concatLines [ " member Bar:" ; " a: int *" ; " b: int *" ; " c: int" ; " -> int" ])
516512 // verify formatting for multi-char operators
517- verifySignature " multi-char operator rendering" 39 u 7 u ( concatLines [ " val ( .>> ):" ; " x: int ->" ; " y: int" ; " -> int" ])
513+ verifySignature
514+ " multi-char operator rendering"
515+ 39 u
516+ 7 u
517+ ( concatLines [ " val ( .>> ):" ; " x: int ->" ; " y: int" ; " -> int" ])
518518 // verify formatting for single-char operators
519- verifySignature " single-char operator rendering" 41 u 6 u ( concatLines [ " val ( ^ ):" ; " x: int ->" ; " y: int" ; " -> int" ])
519+ verifySignature
520+ " single-char operator rendering"
521+ 41 u
522+ 6 u
523+ ( concatLines [ " val ( ^ ):" ; " x: int ->" ; " y: int" ; " -> int" ])
520524 // verify rendering of generic constraints
521- verifySignature " generic constraints on parameters"
525+ verifySignature
526+ " generic constraints on parameters"
522527 43 u
523528 13 u
524529 ( concatLines
@@ -527,93 +532,117 @@ let tooltipTests state =
527532 " y: 'b (requires static member ( + ))"
528533 " -> 'c" ])
529534 //verify rendering of solved generic constraints in tooltips for members where they are solved
530- verifyDescription " solved generic parameters are called out in tooltip"
535+ verifyDescription
536+ " solved generic parameters are called out in tooltip"
531537 45 u
532538 15 u
533539 [ " **Generic Parameters**"
534540 " "
535541 " * `'a` is `int`"
536542 " * `'b` is `int`"
537543 " * `'c` is `int`" ]
538- verifySignature " optional member parameters are rendered with leading question mark"
544+ verifySignature
545+ " optional member parameters are rendered with leading question mark"
539546 48 u
540547 28 u
541548 ( concatLines
542549 [ " static member Start:"
543550 " body : (MailboxProcessor<string> -> Async<unit>) *"
544551 " ?cancellationToken: System.Threading.CancellationToken"
545552 " -> MailboxProcessor<string>" ])
546- verifySignature " union case named parameters are rendered" 54 u 9 u " Case2 of string * newlineBefore: bool * newlineAfter: bool"
547- verifySignature " active pattern signatures with potentially-nullable results"
553+ verifySignature
554+ " union case named parameters are rendered"
555+ 54 u
556+ 9 u
557+ " Case2 of string * newlineBefore: bool * newlineAfter: bool"
558+ verifySignature
559+ " active pattern signatures with potentially-nullable results"
548560 60 u
549561 7 u
550562 ( concatLines
563+ #if NET8_ 0
564+ [ " active pattern Value: "
565+ " input: Expr"
566+ " -> option<obj * System.Type>" ])
567+ #else
551568 [ " active pattern Value: "
552569 " input: Expr"
553570 " -> option<objnull * System.Type>" ])
554- verifySignature " generic constraint rendering for IWSAM"
571+ #endif
572+ verifySignature
573+ " generic constraint rendering for IWSAM"
555574 77 u
556575 5 u
557- ( concatLines [
558- " val testIWSAMTest:"
576+ ( concatLines
577+ [ " val testIWSAMTest:"
559578 " unit"
560- " -> Result<string,'e> (requires :> IWSAMTest<'e>)"
561- ])
562- verifySignature " multiple generic constraints for IWASMs"
579+ " -> Result<string | null ,'e> (requires :> IWSAMTest<'e>)" ])
580+ verifySignature
581+ " multiple generic constraints for IWASMs"
563582 90 u
564583 25 u
565- ( concatLines [
566- " static member GetAwaiter:"
584+ ( concatLines
585+ [ " static member GetAwaiter:"
567586 " awaitable: 'Awaitable (requires member GetAwaiter)"
568- " -> Awaiter<^Awaiter,'TResult> (requires :> ICriticalNotifyCompletion and member IsCompleted and member GetResult)"
569- ])
570- verifySignature " basic active pattern"
587+ " -> Awaiter<^Awaiter,'TResult> (requires :> ICriticalNotifyCompletion and member IsCompleted and member GetResult)" ])
588+ verifySignature
589+ " basic active pattern"
571590 65 u
572591 7 u
573592 ( concatLines
574593 [ " active pattern DefaultValue: "
575594 " input: Expr"
576595 " -> option<System.Type>" ])
577- verifySignature " basic active pattern with nullability awareness"
596+ verifySignature
597+ " basic active pattern with nullability awareness"
578598 70 u
579599 7 u
580600 ( concatLines
601+ #if NET8_ 0
602+ [ " active pattern ValueWithName: "
603+ " input: Expr"
604+ " -> option<obj * System.Type * string>" ])
605+ #else
581606 [ " active pattern ValueWithName: "
582607 " input: Expr"
583608 " -> option<objnull * System.Type * string>" ])
584- verifySignature " interface with members with and without parameter names"
609+ #endif
610+ verifySignature
611+ " interface with members with and without parameter names"
585612 96 u
586613 7 u
587614 ( concatLines
588615 [ " interface IWithAndWithoutParamNames"
589616 " abstract member WithParamNames: arg1: int * arg2: float -> string"
590617 " abstract member WithoutParamNames: int * string -> int" ])
591- verifySignature " function with unsolved nullable parameter" 102 u 7 u ( concatLines [
592- " val usesNullable:"
593- " x: 't | null"
594- " -> 't (requires reference)"
595- ])
596-
597- verifySignature " function with concrete nullable parameter" 103 u 7 u ( concatLines [
598- " val usesConcreteNullable:"
599- " x: string | null"
600- " -> String"
601- ])
602- verifySignature " function with generic nullable return" 104 u 7 u ( concatLines [
603- " val makesNullable:"
604- " x: 'x"
605- " -> 'x | null (requires reference)"
606- ])
607- verifySignature " function with concrete nullable return" 105 u 7 u ( concatLines [
608- " val makesConcreteNullable:"
609- " x: string"
610- " -> string | null"
611- ])
612- verifySignature " function with nullable return from BCL call" 106 u 7 u ( concatLines [
613- " val usesBCLNullable:"
614- " key: string"
615- " -> string | null"
616- ])] ]
618+ #if NET8_ 0_ OR_ GREATER
619+ verifySignature
620+ " function with unsolved nullable parameter"
621+ 102 u
622+ 7 u
623+ ( concatLines [ " val usesNullable:" ; " x: 't | null" ; " -> 't (requires reference)" ])
624+ verifySignature
625+ " function with concrete nullable parameter"
626+ 103 u
627+ 7 u
628+ ( concatLines [ " val usesConcreteNullable:" ; " x: string | null" ; " -> String" ])
629+ verifySignature
630+ " function with generic nullable return"
631+ 104 u
632+ 7 u
633+ ( concatLines [ " val makesNullable:" ; " x: 'x" ; " -> 'x | null (requires reference)" ])
634+ verifySignature
635+ " function with concrete nullable return"
636+ 105 u
637+ 7 u
638+ ( concatLines [ " val makesConcreteNullable:" ; " x: string" ; " -> string | null" ])
639+ verifySignature
640+ " function with nullable return from BCL call"
641+ 106 u
642+ 7 u
643+ ( concatLines [ " val usesBCLNullable:" ; " key: string" ; " -> string | null" ])
644+ #endif
645+ ] ]
617646
618647let closeTests state =
619648 // Note: clear diagnostics also implies clear caches (-> remove file & project options from State).
0 commit comments