Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SignatureHelpProviderTests #1949

Merged
merged 2 commits into from
Dec 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 49 additions & 44 deletions vsintegration/tests/unittests/SignatureHelpProviderTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ System.Console.WriteLine(format="Hello, {0}",arg0="World")
[(".", None);
("System", None);
("WriteLine", None);
("(", Some ("[5..62)", 0, 2, Some "format"));
("format", Some ("[5..62)", 0, 2, Some "format"));
("(", Some ("[7..64)", 0, 2, Some "format"));
("format", Some ("[7..64)", 0, 2, Some "format"));
(",", None);
("""",""", Some ("[5..62)", 1, 2, Some "arg0"));
("arg0", Some ("[5..62)", 1, 2, Some "arg0"));
("arg0=", Some ("[5..62)", 1, 2, Some "arg0"));
("World", Some ("[5..62)", 1, 2, Some "arg0"));
("""",""", Some ("[7..64)", 1, 2, Some "arg0"));
("arg0", Some ("[7..64)", 1, 2, Some "arg0"));
("arg0=", Some ("[7..64)", 1, 2, Some "arg0"));
("World", Some ("[7..64)", 1, 2, Some "arg0"));
(")", None)]);
( """
//2
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