Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test for indentation after multiple hash directives #1066

Merged
merged 2 commits into from
Sep 2, 2020
Merged
Changes from all commits
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
74 changes: 74 additions & 0 deletions src/Fantomas.Tests/CompilerDirectivesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1701,3 +1701,77 @@ let ``empty module with trivia, 1031`` () =
#load "intellisense_lazy.fsx"
#endif
"""

[<Test>]
let ``don't indent too far after multiple hash directives, 1026`` () =
formatSourceString false """
let getDefaultProxyFor =
memoize
(fun (url:string) ->
let uri = Uri url
let getDefault () =
#if CUSTOM_WEBPROXY
let result =
{ new IWebProxy with
member __.Credentials
with get () = null
and set _value = ()
member __.GetProxy _ = null
member __.IsBypassed (_host : Uri) = true
}
#else
let result = WebRequest.GetSystemWebProxy()
#endif
#if CUSTOM_WEBPROXY
let proxy = result
#else
let address = result.GetProxy uri
if address = uri then null else
let proxy = WebProxy address
proxy.BypassProxyOnLocal <- true
#endif
proxy.Credentials <- CredentialCache.DefaultCredentials
proxy

match calcEnvProxies.Force().TryFind uri.Scheme with
| Some p -> if p.GetProxy uri <> uri then p else getDefault()
| None -> getDefault())
""" config
|> prepend newline
|> should equal """
let getDefaultProxyFor =
memoize (fun (url: string) ->
let uri = Uri url

let getDefault () =
#if CUSTOM_WEBPROXY
let result =
{ new IWebProxy with
member __.Credentials = null

member __.Credentials
with set _value = ()

member __.GetProxy _ = null
member __.IsBypassed(_host: Uri) = true }
#else
let result = WebRequest.GetSystemWebProxy()
#endif
#if CUSTOM_WEBPROXY
let proxy = result
#else
let address = result.GetProxy uri

if address = uri then
null
else
let proxy = WebProxy address
proxy.BypassProxyOnLocal <- true
#endif
proxy.Credentials <- CredentialCache.DefaultCredentials
proxy

match calcEnvProxies.Force().TryFind uri.Scheme with
| Some p -> if p.GetProxy uri <> uri then p else getDefault ()
| None -> getDefault ())
"""