From b77b1a427599be63933691664fdeec5a4b5b08dc Mon Sep 17 00:00:00 2001 From: Kurt Schelfthout Date: Tue, 26 Sep 2017 22:16:34 +0100 Subject: [PATCH] Don't escape newline and tab chars. --- FsCheck Release Notes.md | 3 ++- src/FsCheck/Runner.fs | 2 +- tests/FsCheck.Test/Runner.fs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/FsCheck Release Notes.md b/FsCheck Release Notes.md index 2f0f379d..8b3555bb 100644 --- a/FsCheck Release Notes.md +++ b/FsCheck Release Notes.md @@ -1,4 +1,5 @@ -### 2.10.3 - To be released +### 2.10.3 - 26 September 2017 +* Don't escape newline and tab characters. ### 2.10.2 - 25 September 2017 * Fix stack overflow in Gen.piles, listOf and arrayOf when generating long collections. diff --git a/src/FsCheck/Runner.fs b/src/FsCheck/Runner.fs index 13029d16..21d7d25c 100644 --- a/src/FsCheck/Runner.fs +++ b/src/FsCheck/Runner.fs @@ -179,7 +179,7 @@ module Runner = let result = System.Text.StringBuilder() let mutable escaped = false s |> String.iter (fun ch -> - if not (Char.IsControl(ch)) then + if not (Char.IsControl(ch)) || ch = '\n' || ch = '\r' || ch = '\t' then result.Append(ch) |> ignore else escaped <- true diff --git a/tests/FsCheck.Test/Runner.fs b/tests/FsCheck.Test/Runner.fs index d92bd235..cb840847 100644 --- a/tests/FsCheck.Test/Runner.fs +++ b/tests/FsCheck.Test/Runner.fs @@ -58,9 +58,9 @@ module Runner = [] let ``should show control characters as character codes``() = - let stringWithControlChar = "1234\001 fadf" + let stringWithControlChar = "\r\n\t1234\001 fadf" let result = Runner.argumentsToString [stringWithControlChar] - test <@ result.StartsWith("\"1234\\001 fadf") @> + test <@ result.StartsWith("\"\r\n\t1234\\001 fadf") @> [] let ``should show control characters as character codes for strings nested in other types``() =