Skip to content

Commit

Permalink
Fix SignatureHelpProviderTests
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Dec 6, 2016
1 parent 7d73178 commit 5964daf
Showing 1 changed file with 43 additions and 38 deletions.
81 changes: 43 additions & 38 deletions vsintegration/tests/unittests/SignatureHelpProviderTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ open System
Console.WriteLine([(1,2)])
""",
[
("WriteLine(", Some ("[17..42)", 0, 0, None));
("WriteLine(", Some ("[20..45)", 0, 0, None));
(",", None);
("[(", Some ("[17..42)", 0, 1, None))
("[(", Some ("[20..45)", 0, 1, None))
]);
( """
//3
Expand All @@ -97,21 +97,21 @@ type foo3 = N1.T<ParamIgnored=
type foo4 = N1.T<Param1=1,
type foo5 = N1.T<Param1=1,ParamIgnored=
""",
[("type foo = N1.T<", Some ("[16..23)", 0, 0, None));
("type foo2 = N1.T<", Some ("[35..48)", 0, 0, Some "Param1"));
("type foo2 = N1.T<Param1", Some ("[35..48)", 0, 1, Some "Param1"));
("type foo2 = N1.T<Param1=", Some ("[35..48)", 0, 1, Some "Param1"));
("type foo3 = N1.T<", Some ("[60..79)", 0, 0, Some "ParamIgnored"));
("type foo3 = N1.T<ParamIgnored=", Some ("[60..79)", 0, 1, Some "ParamIgnored"));
("type foo4 = N1.T<Param1", Some ("[91..106)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=", Some ("[91..106)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=1", Some ("[91..106)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1", Some ("[118..146)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=", Some ("[118..146)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1", Some ("[118..146)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1,", Some ("[118..146)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored",Some ("[118..146)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored=",Some ("[118..146)", 1, 2, Some "ParamIgnored"))
[("type foo = N1.T<", Some ("[18..26)", 0, 0, None));
("type foo2 = N1.T<", Some ("[38..52)", 0, 0, Some "Param1"));
("type foo2 = N1.T<Param1", Some ("[38..52)", 0, 1, Some "Param1"));
("type foo2 = N1.T<Param1=", Some ("[38..52)", 0, 1, Some "Param1"));
("type foo3 = N1.T<", Some ("[64..84)", 0, 0, Some "ParamIgnored"));
("type foo3 = N1.T<ParamIgnored=", Some ("[64..84)", 0, 1, Some "ParamIgnored"));
("type foo4 = N1.T<Param1", Some ("[96..112)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=", Some ("[96..112)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=1", Some ("[96..112)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1", Some ("[124..153)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=", Some ("[124..153)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1", Some ("[124..153)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1,", Some ("[124..153)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored",Some ("[124..153)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored=",Some ("[124..153)", 1, 2, Some "ParamIgnored"))
]);
( """
//4
Expand All @@ -121,28 +121,30 @@ type foo3 = N1.T<ParamIgnored= >
type foo4 = N1.T<Param1=1, >
type foo5 = N1.T<Param1=1,ParamIgnored= >
""",
[("type foo = N1.T<", Some ("[16..22)", 0, 0, None));
("type foo2 = N1.T<", Some ("[37..50)", 0, 0, Some "Param1"));
("type foo2 = N1.T<Param1", Some ("[37..50)", 0, 1, Some "Param1"));
("type foo2 = N1.T<Param1=", Some ("[37..50)", 0, 1, Some "Param1"));
("type foo3 = N1.T<", Some ("[64..83)", 0, 0, Some "ParamIgnored"));
("type foo3 = N1.T<ParamIgnored=", Some ("[64..83)", 0, 1, Some "ParamIgnored"));
("type foo4 = N1.T<Param1", Some ("[97..112)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=", Some ("[97..112)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=1", Some ("[97..112)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1", Some ("[126..154)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=", Some ("[126..154)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1", Some ("[126..154)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1,", Some ("[126..154)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored",Some ("[126..154)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored=",Some ("[126..154)", 1, 2, Some "ParamIgnored"))])
[("type foo = N1.T<", Some ("[18..24)", 0, 0, None));
("type foo2 = N1.T<", Some ("[40..53)", 0, 0, Some "Param1"));
("type foo2 = N1.T<Param1", Some ("[40..53)", 0, 1, Some "Param1"));
("type foo2 = N1.T<Param1=", Some ("[40..53)", 0, 1, Some "Param1"));
("type foo3 = N1.T<", Some ("[68..87)", 0, 0, Some "ParamIgnored"));
("type foo3 = N1.T<ParamIgnored=", Some ("[68..87)", 0, 1, Some "ParamIgnored"));
("type foo4 = N1.T<Param1", Some ("[102..117)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=", Some ("[102..117)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=1", Some ("[102..117)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1", Some ("[132..160)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=", Some ("[132..160)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1", Some ("[132..160)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1,", Some ("[132..160)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored",Some ("[132..160)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored=",Some ("[132..160)", 1, 2, Some "ParamIgnored"))])
//Test case 5
( """let _ = System.DateTime(""",
[("let _ = System.DateTime(", Some ("[8..24)", 0, 0, None)) ])
]

let sb = System.Text.StringBuilder()
for (fileContents, testCases) in manyTestCases do
printfn "Test case: fileContents = %s..." fileContents.[2..4]

let actual =
[ for (marker, expected) in testCases do
printfn "Test case: marker = %s" marker
Expand All @@ -163,13 +165,16 @@ type foo5 = N1.T<Param1=1,ParamIgnored= >
| None -> None
| Some (results,applicableSpan,argumentIndex,argumentCount,argumentName) -> Some (applicableSpan.ToString(),argumentIndex,argumentCount,argumentName)

if expected <> actual then Assert.Fail(sprintf "FSharpCompletionProvider.ProvideMethodsAsyncAux() gave unexpected results, expected %A, got %A" expected actual)

yield (marker, actual) ]
()
// Use this to print out data to update the test cases, after uncommenting the assert
//printfn "(\"\"\"%s\n\"\"\",\n%s)" fileContents ((sprintf "%A" actual).Replace("null","None"))
if expected <> actual then
sb.AppendLine(sprintf "FSharpCompletionProvider.ProvideMethodsAsyncAux() gave unexpected results, expected %A, got %A" expected actual) |> ignore
yield (marker, actual) ]

printfn "(\"\"\"%s\n\"\"\",\n%s)" fileContents ((sprintf "%A" actual).Replace("null","None"))


match sb.ToString() with
| "" -> ()
| errorText -> Assert.Fail errorText



Expand Down

0 comments on commit 5964daf

Please sign in to comment.