Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6368914

Browse files
authored
Merge pull request #3955 from TIHan/ide-test-fix1
Added tests to CompletionProvider tests. Cleaned up formatting for CompletionProvider tests.
2 parentsb9cf6a4 +c55d1e1 commit6368914

File tree

2 files changed

+86
-5
lines changed

2 files changed

+86
-5
lines changed

‎vsintegration/tests/unittests/CompletionProviderTests.fs‎

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ let internal projectOptions = {
4949
Stamp= None
5050
}
5151

52+
letformatCompletions(completions:string seq)=
53+
"\n\t"+ String.Join("\n\t", completions)
54+
5255
letVerifyCompletionList(fileContents:string,marker:string,expected:string list,unexpected:string list)=
5356
letcaretPosition= fileContents.IndexOf(marker)+ marker.Length
5457
letresults=
@@ -57,11 +60,44 @@ let VerifyCompletionList(fileContents: string, marker: string, expected: string
5760
|> Option.defaultValue(ResizeArray())
5861
|> Seq.map(fun result-> result.DisplayText)
5962

60-
for itemin expecteddo
61-
Assert.IsTrue(results.Contains(item), sprintf"Completions should contain '%s'. Got '%s'." item(String.Join(",", results)))
63+
letexpectedFound=
64+
expected
65+
|> Seq.filter results.Contains
66+
67+
letexpectedNotFound=
68+
expected
69+
|> Seq.filter(expectedFound.Contains>>not)
70+
71+
letunexpectedNotFound=
72+
unexpected
73+
|> Seq.filter(results.Contains>>not)
74+
75+
letunexpectedFound=
76+
unexpected
77+
|> Seq.filter(unexpectedNotFound.Contains>>not)
78+
79+
// If either of these are true, then the test fails.
80+
lethasExpectedNotFound=not(Seq.isEmpty expectedNotFound)
81+
lethasUnexpectedFound=not(Seq.isEmpty unexpectedFound)
82+
83+
if hasExpectedNotFound|| hasUnexpectedFoundthen
84+
letexpectedNotFoundMsg=
85+
if hasExpectedNotFoundthen
86+
sprintf"\nExpected completions not found:%s\n"(formatCompletions expectedNotFound)
87+
else
88+
String.Empty
6289

63-
for itemin unexpecteddo
64-
Assert.IsFalse(results.Contains(item), sprintf"Completions should not contain '%s'. Got '{%s}'" item(String.Join(",", results)))
90+
letunexpectedFoundMsg=
91+
if hasUnexpectedFoundthen
92+
sprintf"\nUnexpected completions found:%s\n"(formatCompletions unexpectedFound)
93+
else
94+
String.Empty
95+
96+
letcompletionsMsg= sprintf"\nin Completions:%s"(formatCompletions results)
97+
98+
letmsg= sprintf"%s%s%s" expectedNotFoundMsg unexpectedFoundMsg completionsMsg
99+
100+
Assert.Fail(msg)
65101

66102
letVerifyCompletionListExactly(fileContents:string,marker:string,expected:string list)=
67103
letcaretPosition= fileContents.IndexOf(marker)+ marker.Length
@@ -259,6 +295,52 @@ x.
259295
"ToArray";"ToString";"TrimExcess";"TrueForAll"]
260296
VerifyCompletionListExactly(fileContents,"x.", expected)
261297

298+
[<Test;Ignore("Before this test can pass, the test below needs to pass. Related to: https://github.com/Microsoft/visualfsharp/issues/2973")>]
299+
let``Constructing a new class with object initializer syntax``()=
300+
letfileContents="""
301+
type A() =
302+
member val SettableProperty = 1 with get, set
303+
member val AnotherSettableProperty = 1 with get, set
304+
member val NonSettableProperty = 1
305+
306+
let _ = new A(Setta
307+
"""
308+
309+
letexpected=["SettableProperty";"AnotherSettableProperty"]
310+
letnotExpected=["NonSettableProperty"]
311+
VerifyCompletionList(fileContents,"(Setta", expected, notExpected)
312+
313+
[<Test;Ignore("https://github.com/Microsoft/visualfsharp/issues/2973")>]
314+
let``Constructing a new class with object initializer syntax and verifying'at' character doesn't exist.``()=
315+
letfileContents="""
316+
type A() =
317+
member val SettableProperty = 1 with get, set
318+
member val AnotherSettableProperty = 1 with get, set
319+
member val NonSettableProperty = 1
320+
321+
let _ = new A(Setta
322+
"""
323+
324+
letexpected=[]
325+
letnotExpected=["SettableProperty@";"AnotherSettableProperty@";"NonSettableProperty@"]
326+
VerifyCompletionList(fileContents,"(Setta", expected, notExpected)
327+
328+
[<Test;Ignore("https://github.com/Microsoft/visualfsharp/issues/3954")>]
329+
let``Constructing a new fully qualified class with object initializer syntax``()=
330+
letfileContents="""
331+
module M =
332+
type A() =
333+
member val SettableProperty = 1 with get, set
334+
member val AnotherSettableProperty = 1 with get, set
335+
member val NonSettableProperty = 1
336+
337+
let _ = new M.A(Setta
338+
"""
339+
340+
letexpected=["SettableProperty";"AnotherSettableProperty"]
341+
letnotExpected=["NonSettableProperty"]
342+
VerifyCompletionList(fileContents,"(Setta", expected, notExpected)
343+
262344
[<Test>]
263345
let``Extension methods go after everything else,extension properties are treated as normal ones``()=
264346
letfileContents="""

‎vsintegration/tests/unittests/Tests.LanguageService.Completion.fs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ a.
596596
AssertCtrlSpaceCompleteContains(typeDef3@["new M.A((**))"])"A((**)"["SettableProperty";"AnotherSettableProperty"]["NonSettableProperty"]
597597
AssertCtrlSpaceCompleteContains(typeDef3@["new M.A(S = 1)"])"A(S"["SettableProperty"]["NonSettableProperty"]
598598
AssertCtrlSpaceCompleteContains(typeDef3@["new M.A(S = 1)"])"A(S = 1"[]["NonSettableProperty";"SettableProperty"]// neg test
599-
AssertCtrlSpaceCompleteContains(typeDef3@["new M.A(S = 1,)"])"A(S = 1,"["AnotherSettableProperty"]["NonSettableProperty"]
600599

601600
lettypeDef4=
602601
[

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp