Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify test
  • Loading branch information
auduchinok committed Nov 6, 2020
commit f1d507190927ba7e09220f6176772a54b9cbfe25
11 changes: 8 additions & 3 deletions tests/service/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,15 @@ let matchBraces (name: string, code: string) =
let braces = checker.MatchBraces(filePath, FSharp.Compiler.Text.SourceText.ofString code, options) |> Async.RunSynchronously
braces

let parseSourceCodeAndGetModule (source: string) =
match parseSourceCode ("test", source) with
| Some (ParsedInput.ImplFile (ParsedImplFileInput (_, _, _, _, _, [ moduleOrNamespace ], _))) -> moduleOrNamespace

let getSingleModuleLikeDecl (input: ParsedInput option) =
match input with
| Some (ParsedInput.ImplFile (ParsedImplFileInput (modules = [ decl ]))) -> decl
| _ -> failwith "Could not get module decls"

let parseSourceCodeAndGetModule (source: string) =
parseSourceCode ("test", source) |> getSingleModuleLikeDecl


/// Extract range info
let tups (m:Range.range) = (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn)
Expand Down
11 changes: 4 additions & 7 deletions tests/service/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,10 @@ module ExternDeclarations =
let ``Access modifier`` () =
let parseResults, checkResults = getParseAndCheckResults "extern int private f()"

match parseResults.ParseTree with
| Some (ParsedInput.ImplFile (ParsedImplFileInput (modules = [SynModuleOrNamespace (decls = [decl])]))) ->
match decl with
| SynModuleDecl.Let (_, [Binding (accessibility = accessibility)], _) ->
accessibility |> should equal (Some SynAccess.Private)
| _ -> failwith "Couldn't get f"
| _ -> failwith "Couldn't get bindings"
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
Expand Down