@@ -49,6 +49,9 @@ let internal projectOptions = {
4949 Stamp= None
5050}
5151
52+ let formatCompletions ( completions : string seq ) =
53+ " \n\t " + String.Join( " \n\t " , completions)
54+
5255let VerifyCompletionList ( fileContents : string , marker : string , expected : string list , unexpected : string list ) =
5356let caretPosition = fileContents.IndexOf( marker) + marker.Length
5457let results =
@@ -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+ let expectedFound =
64+ expected
65+ |> Seq.filter results.Contains
66+
67+ let expectedNotFound =
68+ expected
69+ |> Seq.filter( expectedFound.Contains>> not )
70+
71+ let unexpectedNotFound =
72+ unexpected
73+ |> Seq.filter( results.Contains>> not )
74+
75+ let unexpectedFound =
76+ unexpected
77+ |> Seq.filter( unexpectedNotFound.Contains>> not )
78+
79+ // If either of these are true, then the test fails.
80+ let hasExpectedNotFound = not ( Seq.isEmpty expectedNotFound)
81+ let hasUnexpectedFound = not ( Seq.isEmpty unexpectedFound)
82+
83+ if hasExpectedNotFound|| hasUnexpectedFoundthen
84+ let expectedNotFoundMsg =
85+ if hasExpectedNotFoundthen
86+ sprintf" \n Expected 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+ let unexpectedFoundMsg =
91+ if hasUnexpectedFoundthen
92+ sprintf" \n Unexpected completions found:%s \n " ( formatCompletions unexpectedFound)
93+ else
94+ String.Empty
95+
96+ let completionsMsg = sprintf" \n in Completions:%s " ( formatCompletions results)
97+
98+ let msg = sprintf" %s%s%s " expectedNotFoundMsg unexpectedFoundMsg completionsMsg
99+
100+ Assert.Fail( msg)
65101
66102let VerifyCompletionListExactly ( fileContents : string , marker : string , expected : string list ) =
67103let caretPosition = fileContents.IndexOf( marker) + marker.Length
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+ let fileContents = """
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+ let expected = [ " SettableProperty" ; " AnotherSettableProperty" ]
310+ let notExpected = [ " 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+ let fileContents = """
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+ let expected = []
325+ let notExpected = [ " 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+ let fileContents = """
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+ let expected = [ " SettableProperty" ; " AnotherSettableProperty" ]
341+ let notExpected = [ " NonSettableProperty" ]
342+ VerifyCompletionList( fileContents, " (Setta" , expected, notExpected)
343+
262344[<Test>]
263345let ``Extension methods go after everything else , extension properties are treated as normal ones`` () =
264346let fileContents = """