forked from dotnet/fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCapturedTypes.fs
More file actions
36 lines (27 loc) · 1.09 KB
/
Copy pathCapturedTypes.fs
File metadata and controls
36 lines (27 loc) · 1.09 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
module FSharp.Compiler.Service.Tests.CapturedTypes
open FSharp.Compiler.Symbols
open FSharp.Test.Assert
open Xunit
let private displayContext =
FSharpDisplayContext.Empty.WithShortTypeNames(true)
let tryGetCapturedType markedSource =
let context, checkResults = Checker.getCheckedResolveContext markedSource
checkResults.TryGetCapturedType context.SelectedRange.Value
let assertCapturedType expectedTypeString markedSource =
let capturedType = tryGetCapturedType markedSource
capturedType.Value.Format displayContext |> shouldEqual expectedTypeString
[<Fact>]
let ``Expr - If 01`` () =
assertCapturedType "int * int" "{selstart}if true then 1, 2 else 1, true{selend}"
[<Fact>]
let ``Expr - Literal 01`` () =
assertCapturedType "int" "{selstart}1{selend}"
[<Fact>]
let ``Expr - Literal 02`` () =
assertCapturedType "string" "{selstart}\"\"{selend}"
[<Fact>]
let ``Expr - Tuple 01`` () =
assertCapturedType "int * int" "{selstart}1, 2{selend}"
[<Fact>]
let ``Expr - Tuple 02`` () =
assertCapturedType "int * int" "if true then {selstart}1, 2{selend} else 1, true"