diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs index 8c22810bb062..e794169de72e 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs @@ -57,6 +57,23 @@ type UsingMSBuild() as this = let ok = errors |> List.exists (fun err -> err.Message = text) Assert.IsTrue(ok, sprintf "Error list should contain '%s' message" text) + let assertExpectedErrorMessages expected (actual: list) = + let normalizeCR input = System.Text.RegularExpressions.Regex.Replace(input, @"\r\n|\n\r|\n|\r", "\r\n") + let actual = + actual + |> Seq.map (fun e -> e.Message) + |> String.concat Environment.NewLine + |> normalizeCR + let expected = expected |> String.concat Environment.NewLine |> normalizeCR + + let message = + sprintf """ +=[ expected ]============ +%s +=[ actual ]============== +%s +=========================""" expected actual + Assert.AreEqual(expected, actual, message) //verify the error list Count member private this.VerifyErrorListCountAtOpenProject(fileContents : string, num : int) = @@ -185,17 +202,18 @@ let g (t : T) = t.Count() """ let expectedMessages = - [ "Possible overload: 'new : bool -> X'." - "Possible overload: 'new : int -> X'." ] + [ """No overloads match for method 'X'. - CheckErrorList content <| - fun errors -> - Assert.AreEqual(3, List.length errors) - assertContains errors "No overloads match for method 'X'. The available overloads are shown below." - for expected in expectedMessages do - errors - |> List.exists (fun e -> e.Message.StartsWith expected) - |> Assert.IsTrue +Argument given: float + +Available overloads: + - new : bool -> X + - new : int -> X +""" + ] + + CheckErrorList content (assertExpectedErrorMessages expectedMessages) + [] member public this.``Query.InvalidJoinRelation.GroupJoin``() = @@ -271,10 +289,19 @@ let x = let content = """ System.Console.WriteLine(null) """ - CheckErrorList content <| - fun errors -> - Assert.AreEqual(1, List.length errors) - assertContains errors "A unique overload for method 'WriteLine' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: System.Console.WriteLine(buffer: char []) : unit, System.Console.WriteLine(format: string, [] arg: obj []) : unit, System.Console.WriteLine(value: obj) : unit, System.Console.WriteLine(value: string) : unit" + let expectedMessages = [ +"""A unique overload for method 'WriteLine' could not be determined based on type information prior to this program point. A type annotation may be needed. + +Argument given: 'a when 'a : null + +Candidates: + - System.Console.WriteLine(buffer: char []) : unit + - System.Console.WriteLine(format: string, [] arg: obj []) : unit + - System.Console.WriteLine(value: obj) : unit + - System.Console.WriteLine(value: string) : unit +""" + ] + CheckErrorList content (assertExpectedErrorMessages expectedMessages) [] member public this.``InvalidMethodOverload2``() = @@ -288,10 +315,19 @@ type B() = let b = B() b.Do(1, 1) """ - CheckErrorList content <| - fun errors -> - Assert.AreEqual(1, List.length errors) - assertContains errors "A unique overload for method 'Do' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: member A.Do : a:int * b:'T -> unit, member A.Do : a:int * b:int -> unit" + let expectedMessages = [ +"""A unique overload for method 'Do' could not be determined based on type information prior to this program point. A type annotation may be needed. + +Arguments given: + - int + - int + +Candidates: + - member A.Do : a:int * b:'T -> unit + - member A.Do : a:int * b:int -> unit +""" + ] + CheckErrorList content (assertExpectedErrorMessages expectedMessages) [] member public this.``NoErrorInErrList``() =