diff --git a/src/Fantomas.Tests/FSharpScriptTests.fs b/src/Fantomas.Tests/FSharpScriptTests.fs index 590967599b..1783acf55f 100644 --- a/src/Fantomas.Tests/FSharpScriptTests.fs +++ b/src/Fantomas.Tests/FSharpScriptTests.fs @@ -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" +""" + +[] +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 """ \ No newline at end of file