Skip to content

Commit

Permalink
fix vsintegration tests affected by overload error message changes
Browse files Browse the repository at this point in the history
  • Loading branch information
smoothdeveloper committed Apr 30, 2019
1 parent 19e2c3c commit a2babef
Showing 1 changed file with 54 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Error>) =
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) =
Expand Down Expand Up @@ -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)


[<Test>]
member public this.``Query.InvalidJoinRelation.GroupJoin``() =
Expand Down Expand Up @@ -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, [<System.ParamArray>] 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, [<System.ParamArray>] arg: obj []) : unit
- System.Console.WriteLine(value: obj) : unit
- System.Console.WriteLine(value: string) : unit
"""
]
CheckErrorList content (assertExpectedErrorMessages expectedMessages)

[<Test>]
member public this.``InvalidMethodOverload2``() =
Expand All @@ -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)

[<Test; Category("Expensive")>]
member public this.``NoErrorInErrList``() =
Expand Down

0 comments on commit a2babef

Please sign in to comment.