Skip to content

Commit

Permalink
stringinterp test: add PrintFormat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yatli committed May 2, 2020
1 parent 086c0d9 commit 49ba592
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/fsharp/Compiler/Language/StringInterpolation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,28 @@ check "fwejwflpej17" (fmt_de $"abc {30000,-10:N} def {40000:N} hij") "abc 30.000
"""

[<Test>]
let ``String interpolation to PrintFormat`` () =
CompilerAssert.CompileExeAndRunWithOptions [| "--langversion:preview" |]
"""
open System.Text
open Printf
let check msg a b =
if a = b then printfn "%s succeeded" msg else failwithf "%s failed, expected %A, got %A" msg b a
check "fwejwflpej1" (sprintf $"") ""
check "fwejwflpej2" (sprintf $"abc") "abc"
check "fwejwflpej3" (sprintf $"abc{1}") "abc1"
let sb = StringBuilder()
bprintf sb $"{0}"
bprintf sb $"abc"
bprintf sb $"abc{1}"
check "fwejwflpej4" (sb.ToString()) "0abcabc1"
"""


[<Test>]
let ``String interpolation using .NET Formats`` () =
CompilerAssert.CompileExeAndRunWithOptions [| "--langversion:preview" |]
Expand Down

0 comments on commit 49ba592

Please sign in to comment.