Skip to content

Commit

Permalink
Check no modifier, explicit public modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
auduchinok committed Nov 6, 2020
1 parent f1d5071 commit fcfd224
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions tests/service/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,32 @@ match "foo" with
module ExternDeclarations =
[<Test>]
let ``Access modifier`` () =
let parseResults, checkResults = getParseAndCheckResults "extern int private f()"

match getSingleModuleLikeDecl parseResults.ParseTree with
| SynModuleOrNamespace (decls = [SynModuleDecl.Let (_, [Binding (accessibility = accessibility)], _)]) ->
accessibility |> should equal (Some SynAccess.Private)
| _ -> failwith "Couldn't get f"

match findSymbolByName "f" checkResults with
| :? FSharpMemberOrFunctionOrValue as mfv -> mfv.Accessibility.IsPrivate |> should equal true
| _ -> failwith "Couldn't get f"
let parseResults, checkResults = getParseAndCheckResults """
extern int a()
extern int public b()
extern int private c()
"""
let (SynModuleOrNamespace (decls = decls)) = getSingleModuleLikeDecl parseResults.ParseTree

[ None
Some SynAccess.Public
Some SynAccess.Private ]
|> List.zip decls
|> List.iter (fun (actual, (expected)) ->
match actual with
| SynModuleDecl.Let (_, [Binding (accessibility = access)], _) -> access |> should equal expected
| decl -> failwithf "unexpected decl: %O" decl)

[ "a", (true, false, false, false)
"b", (true, false, false, false)
"c", (false, false, false, true) ]
|> List.iter (fun (name, expectedAccess) ->
match findSymbolByName name checkResults with
| :? FSharpMemberOrFunctionOrValue as mfv ->
let access = mfv.Accessibility
(access.IsPublic, access.IsProtected, access.IsInternal, access.IsPrivate)
|> should equal expectedAccess
| _ -> failwith "Couldn't get f")


module XmlDocSig =
Expand Down

0 comments on commit fcfd224

Please sign in to comment.