-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Respect byte-order mark. Fixes 795 * Removed helper functions and expose runFantomasTool * Add remark about UTF-8
- Loading branch information
Showing
4 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module Fantomas.CoreGlobalTool.Tests.ByteOrderMarkTests | ||
|
||
open System.IO | ||
open NUnit.Framework | ||
open FsUnit | ||
open Fantomas.CoreGlobalTool.Tests.TestHelpers | ||
open System.Text | ||
|
||
[<Literal>] | ||
let Source = "namespace Company.Product.Feature" | ||
|
||
let private getInitialBytes file = | ||
use file = new FileStream(file, FileMode.Open, FileAccess.Read) | ||
let mutable bom = Array.zeroCreate 3 | ||
file.Read(bom, 0, 3) |> ignore | ||
bom | ||
|
||
[<Test>] | ||
let ``byte-order mark should be preserved, 795``() = | ||
use fileFixture = new TemporaryFileCodeSample(Source, true) | ||
let exitCode = runFantomasTool fileFixture.Filename | ||
exitCode |> should equal 0 | ||
|
||
let expectedPreamble = Encoding.UTF8.GetPreamble() | ||
let actualPreamble = getInitialBytes fileFixture.Filename | ||
expectedPreamble |> should equal actualPreamble | ||
|
||
[<Test>] | ||
let ``preserve byte-order from original file`` () = | ||
use inputFixture = new TemporaryFileCodeSample(Source, true) | ||
use outputFixture = new OutputFile() | ||
let exitCode = | ||
sprintf "--out %s %s" outputFixture.Filename inputFixture.Filename | ||
|> runFantomasTool | ||
|
||
exitCode |> should equal 0 | ||
|
||
let expectedPreamble = Encoding.UTF8.GetPreamble() | ||
let actualPreamble = getInitialBytes outputFixture.Filename | ||
expectedPreamble |> should equal actualPreamble |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters