From 443ed8a775240dbdf07a6ffe8d2cc81b8da3e52a Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 11 Jul 2019 16:06:18 +0200 Subject: [PATCH] E2E test that verifies #380 --- src/Fantomas.Tests/FSharpScriptTests.fs | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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