-
Notifications
You must be signed in to change notification settings - Fork 854
Expand file tree
/
Copy pathTypeCheckerRecoveryTests.fs
More file actions
121 lines (95 loc) · 2.32 KB
/
TypeCheckerRecoveryTests.fs
File metadata and controls
121 lines (95 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
module FSharp.Compiler.Service.Tests.TypeChecker.TypeCheckerRecoveryTests
open FSharp.Compiler.Service.Tests
open FSharp.Compiler.Text
open FSharp.Test.Assert
open Xunit
let assertHasSymbolUsageAtCaret name source =
let context, checkResults = Checker.getCheckedResolveContext source
getSymbolUses checkResults
|> Seq.exists (fun symbolUse ->
Range.rangeContainsPos symbolUse.Range context.Pos &&
symbolUse.Symbol.DisplayNameCore = name
)
|> shouldEqual true
[<Fact>]
let ``Let 01`` () =
let _, checkResults = getParseAndCheckResults """
do
let a = b.ToString()
"""
dumpDiagnosticNumbers checkResults |> shouldEqual [
"(3,4--3,7)", 588
"(3,12--3,13)", 39
]
[<Fact>]
let ``Tuple 01`` () =
let _, checkResults = getParseAndCheckResults """
open System
Math.Max(a,)
"""
dumpDiagnosticNumbers checkResults |> shouldEqual [
"(4,10--4,11)", 3100
"(4,9--4,10)", 39
"(4,5--4,8)", 41
]
assertHasSymbolUsages ["Max"] checkResults
[<Fact>]
let ``Tuple 02`` () =
let _, checkResults = getParseAndCheckResults """
open System
Math.Max(a,b,)
"""
dumpDiagnosticNumbers checkResults |> shouldEqual [
"(4,12--4,13)", 3100
"(4,9--4,10)", 39
"(4,11--4,12)", 39
"(4,0--4,14)", 503
]
assertHasSymbolUsages ["Max"] checkResults
module Constraints =
[<Fact>]
let ``Type 01`` () =
assertHasSymbolUsageAtCaret "f" """
let f (x: string) =
x + 1
{caret}f ""
"""
[<Fact>]
let ``Type 02`` () =
assertHasSymbolUsageAtCaret "M" """
type T =
static member M(x: string) =
x + 1
T.M{caret} ""
"""
module Expressions =
[<Fact>]
let ``Method type 01`` () =
assertHasSymbolUsageAtCaret "ToString" """
if true then
"".ToString{caret}
"""
[<Fact>]
let ``Method type 02`` () =
assertHasSymbolUsageAtCaret "M" """
type T =
static member M() = ""
if true then
T.M{caret}
"""
[<Fact>]
let ``Method type 03`` () =
assertHasSymbolUsageAtCaret "M" """
type T =
static member M(i: int) = ""
static member M(s: string) = ""
if true then
T.M{caret}
"""
[<Fact>]
let ``Method type 04`` () =
assertHasSymbolUsageAtCaret "GetHashCode" """
let o: obj = null
if true then
o.GetHashCode{caret}
"""