Skip to content

Commit

Permalink
Merge pull request #1066 from nojaf/fix-1026
Browse files Browse the repository at this point in the history
Add regression test for indentation after multiple hash directives
  • Loading branch information
nojaf authored Sep 2, 2020
2 parents b455085 + bf01a83 commit 16b2761
Showing 1 changed file with 74 additions and 0 deletions.
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 ())
"""

0 comments on commit 16b2761

Please sign in to comment.