Skip to content

Commit

Permalink
Additional tests for #480
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Sep 18, 2019
1 parent a13018f commit a57b8b5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Fantomas.Tests/CompilerDirectivesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -778,3 +778,15 @@ let x = 1
let x = 1
#endif
"""

[<Test>]
let ``no code for inactive define`` () =
formatSourceString false """#if SOMETHING
let foo = 42
#endif""" config
|> prepend newline
|> should equal """
#if SOMETHING
let foo = 42
#endif
"""
16 changes: 16 additions & 0 deletions src/Fantomas.Tests/TriviaTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,19 @@ let ``trailing newlines should not be picked up in trivia`` () =
match trivia with
| [] -> pass()
| _ -> fail()


[<Test>]
let ``code in non-active defines should be returned in trivia`` () =
let source = """#if SOMETHING
let foo = 42
#endif"""

let trivia =
toTriviaWithDefines source
|> Map.find []

match trivia with
| [{ Type = MainNode("SynModuleOrNamespace.AnonModule")
ContentBefore = [ Directive("#if SOMETHING"); Newline; Directive("#endif") ] }] -> pass()
| _ -> fail()

0 comments on commit a57b8b5

Please sign in to comment.