Skip to content

Commit 0408959

Browse files
author
7sharp9
committed
Added Test to confirm tuple and curried nested functions have CuriedParameterGroups available
1 parent 6d06e59 commit 0408959

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

tests/service/ProjectAnalysisTests.fs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4325,3 +4325,63 @@ let ``Test project34 should report correct accessibility for System.Data.Listene
43254325
|> Option.get
43264326

43274327
listenerFuncEntity.Accessibility.IsPrivate |> shouldEqual true
4328+
4329+
module Project35 =
4330+
open System.IO
4331+
4332+
let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs")
4333+
let base2 = Path.GetTempFileName()
4334+
let dllName = Path.ChangeExtension(base2, ".dll")
4335+
let projFileName = Path.ChangeExtension(base2, ".fsproj")
4336+
let fileSource1 = """
4337+
type Test =
4338+
let curriedFunction (one:int) (two:float) (three:string) =
4339+
one + int two + int three
4340+
let tupleFunction (one:int, two:float, three:string) =
4341+
one + int two + int three
4342+
"""
4343+
File.WriteAllText(fileName1, fileSource1)
4344+
let cleanFileName a = if a = fileName1 then "file1" else "??"
4345+
4346+
let fileNames = [fileName1]
4347+
let args = mkProjectCommandLineArgs (dllName, fileNames)
4348+
let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args)
4349+
4350+
4351+
[<Test>]
4352+
let ``Test project35 CurriedParameterGroups should be available for nested functions`` () =
4353+
let wholeProjectResults = checker.ParseAndCheckProject(Project35.options) |> Async.RunSynchronously
4354+
let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously
4355+
let findByDisplayName name =
4356+
Array.find (fun (su:FSharpSymbolUse) -> su.Symbol.DisplayName = name)
4357+
4358+
let curriedFunction = allSymbolUses |> findByDisplayName "curriedFunction"
4359+
match curriedFunction.Symbol with
4360+
| :? FSharpMemberOrFunctionOrValue as mfv ->
4361+
let curriedParamGroups =
4362+
mfv.CurriedParameterGroups
4363+
|> Seq.map Seq.toList
4364+
|> Seq.toList
4365+
match curriedParamGroups with
4366+
| [[param1];[param2];[param3]] ->
4367+
param1.Type.TypeDefinition.DisplayName |> should equal "int"
4368+
param2.Type.TypeDefinition.DisplayName |> should equal "float"
4369+
param3.Type.TypeDefinition.DisplayName |> should equal "string"
4370+
| _ -> failwith "Unexpected parameters"
4371+
| _ -> failwith "Unexpected symbol type"
4372+
4373+
let tupledFunction = allSymbolUses |> findByDisplayName "tupleFunction"
4374+
match tupledFunction.Symbol with
4375+
| :? FSharpMemberOrFunctionOrValue as mfv ->
4376+
let curriedParamGroups =
4377+
mfv.CurriedParameterGroups
4378+
|> Seq.map Seq.toList
4379+
|> Seq.toList
4380+
match curriedParamGroups with
4381+
| [[param1;param2;param3]] ->
4382+
param1.Type.TypeDefinition.DisplayName |> should equal "int"
4383+
param2.Type.TypeDefinition.DisplayName |> should equal "float"
4384+
param3.Type.TypeDefinition.DisplayName |> should equal "string"
4385+
| _ -> failwith "Unexpected parameters"
4386+
| _ -> failwith "Unexpected symbol type"
4387+

0 commit comments

Comments
 (0)