@@ -40,7 +40,7 @@ type SemanticClassificationServiceTests() =
4040|> Option.toList
4141|> List.collect Array.toList
4242
43- let verifyColorizerAtEndOfMarker ( fileContents : string , marker : string , classificationType : string ) =
43+ let verifyClassificationAtEndOfMarker ( fileContents : string , marker : string , classificationType : string ) =
4444let text = SourceText.From fileContents
4545let ranges = getRanges fileContents
4646let line = text.Lines.GetLinePosition( fileContents.IndexOf( marker) + marker.Length- 1 )
@@ -49,6 +49,14 @@ type SemanticClassificationServiceTests() =
4949| None-> Assert.Fail( " Cannot find colorization data for end of marker" )
5050| Some(_, ty) -> Assert.AreEqual( classificationType, FSharpClassificationTypes.getClassificationTypeName ty, " Classification data doesn't match for end of marker" )
5151
52+ let verifyNoClassificationDataAtEndOfMarker ( fileContents : string , marker : string , classificationType : string ) =
53+ let text = SourceText.From fileContents
54+ let ranges = getRanges fileContents
55+ let line = text.Lines.GetLinePosition( fileContents.IndexOf( marker) + marker.Length- 1 )
56+ let markerPos = Range.mkPos( Range.Line.fromZ line.Line) ( line.Character+ marker.Length- 1 )
57+ let anyData = ranges|> List.exists( fun ( range , sct ) -> Range.rangeContainsPos range markerPos&& (( FSharpClassificationTypes.getClassificationTypeName sct) = classificationType))
58+ Assert.False( anyData, " Classification data was found when it wasn't expected." )
59+
5260[<TestCase( " (*1*)" , FSharpClassificationTypes.ValueType) >]
5361[<TestCase( " (*2*)" , FSharpClassificationTypes.ReferenceType) >]
5462[<TestCase( " (*3*)" , FSharpClassificationTypes.ValueType) >]
@@ -57,7 +65,7 @@ type SemanticClassificationServiceTests() =
5765[<TestCase( " (*6*)" , FSharpClassificationTypes.ValueType) >]
5866[<TestCase( " (*7*)" , FSharpClassificationTypes.ReferenceType) >]
5967member __.Measured_Types ( marker : string , classificationType : string ) =
60- verifyColorizerAtEndOfMarker (
68+ verifyClassificationAtEndOfMarker (
6169""" #light (*Light*)
6270 open System
6371
@@ -76,4 +84,60 @@ type SemanticClassificationServiceTests() =
7684 let g: (*6*)Guid<Ms> = Uom.tag Guid.Empty
7785 let s: (*7*)string<Ms> = Uom.tag "foo"""" ,
7886 marker,
79- classificationType)
87+ classificationType)
88+
89+ [<TestCase( " (*1*)" , FSharpClassificationTypes.MutableVar) >]
90+ [<TestCase( " (*2*)" , FSharpClassificationTypes.MutableVar) >]
91+ [<TestCase( " (*3*)" , FSharpClassificationTypes.MutableVar) >]
92+ [<TestCase( " (*4*)" , FSharpClassificationTypes.MutableVar) >]
93+ [<TestCase( " (*5*)" , FSharpClassificationTypes.MutableVar) >]
94+ [<TestCase( " (*6*)" , FSharpClassificationTypes.MutableVar) >]
95+ [<TestCase( " (*7*)" , FSharpClassificationTypes.MutableVar) >]
96+ [<TestCase( " (*8*)" , FSharpClassificationTypes.MutableVar) >]
97+ [<TestCase( " (*9*)" , FSharpClassificationTypes.MutableVar) >]
98+ [<TestCase( " (*10*)" , FSharpClassificationTypes.MutableVar) >]
99+ [<TestCase( " (*11*)" , FSharpClassificationTypes.MutableVar) >]
100+ [<TestCase( " (*12*)" , FSharpClassificationTypes.MutableVar) >]
101+ member __.MutableValues ( marker : string , classificationType : string ) =
102+ let sourceText = """
103+ type R1 = { mutable (*1*)Doop: int}
104+ let r1 = { (*2*)Doop = 12 }
105+ r1.Doop
106+
107+ let mutable (*3*)first = 12
108+
109+ printfn "%d " (*4*)first
110+
111+ let g ((*5*)xRef: outref<int>) = (*6*)xRef <- 12
112+
113+ let f() =
114+ let (*7*)second = &first
115+ let (*8*)third: outref<int> = &first
116+ printfn "%d%d " (*9*)second (*10*)third
117+
118+ type R = { (*11*)MutableField: int ref }
119+ let r = { (*12*)MutableField = ref 12 }
120+ r.MutableField
121+ r.MutableField := 3
122+ """
123+ verifyClassificationAtEndOfMarker( sourceText, marker, classificationType)
124+
125+
126+ [<TestCase( " (*1*)" , FSharpClassificationTypes.MutableVar) >]
127+ [<TestCase( " (*2*)" , FSharpClassificationTypes.MutableVar) >]
128+ [<TestCase( " (*3*)" , FSharpClassificationTypes.MutableVar) >]
129+ [<TestCase( " (*4*)" , FSharpClassificationTypes.MutableVar) >]
130+ [<TestCase( " (*5*)" , FSharpClassificationTypes.MutableVar) >]
131+ [<TestCase( " (*6*)" , FSharpClassificationTypes.MutableVar) >]
132+ member __.NoInrefsExpected ( marker : string , classificationType : string ) =
133+ let sourceText = """
134+ let f (item: (*1*)inref<int>) = printfn "%d " (*2*)item
135+ let g() =
136+ let x = 1
137+ let y = 2
138+ let (*3*)xRef = &x
139+ let (*4*)yRef: inref<int> = &y
140+ f (*5*)&xRef
141+ f (*6*)&yRef
142+ """
143+ verifyNoClassificationDataAtEndOfMarker( sourceText, marker, classificationType)