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 cda7c51
Showing 1 changed file with 42 additions and 37 deletions.
79 changes: 42 additions & 37 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 ("[37..51)", 0, 0, Some "Param1"));
("type foo2 = N1.T<Param1", Some ("[37..51)", 0, 1, Some "Param1"));
("type foo2 = N1.T<Param1=", Some ("[37..51)", 0, 1, Some "Param1"));
("type foo3 = N1.T<", Some ("[62..82)", 0, 0, Some "ParamIgnored"));
("type foo3 = N1.T<ParamIgnored=", Some ("[62..82)", 0, 1, Some "ParamIgnored"));
("type foo4 = N1.T<Param1", Some ("[93..109)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=", Some ("[93..109)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=1", Some ("[93..109)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1", Some ("[120..149)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=", Some ("[120..149)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1", Some ("[120..149)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1,", Some ("[120..149)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored",Some ("[120..149)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored=",Some ("[120..149)", 1, 2, Some "ParamIgnored"))
]);
( """
//4
Expand All @@ -121,28 +121,29 @@ 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..25)", 0, 0, None));
("type foo2 = N1.T<", Some ("[39..53)", 0, 0, Some "Param1"));
("type foo2 = N1.T<Param1", Some ("[39..53)", 0, 1, Some "Param1"));
("type foo2 = N1.T<Param1=", Some ("[39..53)", 0, 1, Some "Param1"));
("type foo3 = N1.T<", Some ("[67..86)", 0, 0, Some "ParamIgnored"));
("type foo3 = N1.T<ParamIgnored=", Some ("[67..86)", 0, 1, Some "ParamIgnored"));
("type foo4 = N1.T<Param1", Some ("[99..115)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=", Some ("[99..115)", 0, 2, Some "Param1"));
("type foo4 = N1.T<Param1=1", Some ("[99..115)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1", Some ("[128..157)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=", Some ("[128..157)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1", Some ("[128..157)", 0, 2, Some "Param1"));
("type foo5 = N1.T<Param1=1,", Some ("[128..157)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored",Some ("[128..157)", 1, 2, Some "ParamIgnored"));
("type foo5 = N1.T<Param1=1,ParamIgnored=",Some ("[128..157)", 1, 2, Some "ParamIgnored"))])
//Test case 5
( """let _ = System.DateTime(""",
[("let _ = System.DateTime(", Some ("[8..24)", 0, 0, None)) ])
[("let _ = System.DateTime(", Some ("[10..27)", 0, 0, None)) ])
]

for (fileContents, testCases) in manyTestCases do
printfn "Test case: fileContents = %s..." fileContents.[2..4]
let sb = System.Text.StringBuilder()
let actual =
[ for (marker, expected) in testCases do
printfn "Test case: marker = %s" marker
Expand All @@ -163,10 +164,14 @@ 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) ]
()
if expected <> actual then
sb.AppendLine(sprintf "FSharpCompletionProvider.ProvideMethodsAsyncAux() gave unexpected results, expected %A, got %A" expected actual) |> ignore
yield (marker, actual) ]

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

// 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"))

Expand Down

0 comments on commit cda7c51

Please sign in to comment.