Skip to content

Commit

Permalink
E2E test that verifies #380
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Jul 11, 2019
1 parent 7541abf commit 443ed8a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Fantomas.Tests/FSharpScriptTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,32 @@ let ``e2e script test with keyword __source__directory__`` () =
|> String.normalizeNewLine
|> should equal """#I __SOURCE_DIRECTORY__
#load ".paket/load/net471/main.group.fsx"
"""

[<Test>]
let ``fantomas removes module and namespace if it is only 1 word`` () =
let source = """namespace Shared
type Counter = int
"""

let file = Path.Combine(Path.GetTempPath(), System.Guid.NewGuid().ToString("N") + ".fsx")
File.WriteAllText(file, source)

let fantomasConfig =
{ FormatConfig.FormatConfig.Default with
StrictMode = true
IndentSpaceNum = 2
SpaceBeforeColon = false }
let formattedFiles = FakeHelpers.formatCode fantomasConfig [file]

let formattedSource = File.ReadAllText(file)
List.length formattedFiles == 1
File.Delete(file)

formattedSource
|> String.normalizeNewLine
|> should equal """namespace Shared
type Counter = int
"""

0 comments on commit 443ed8a

Please sign in to comment.