|
| 1 | +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. |
| 2 | + |
| 3 | +namespace EmittedIL |
| 4 | + |
| 5 | +open Xunit |
| 6 | +open FSharp.Test.Compiler |
| 7 | + |
| 8 | +module PrintFunction = |
| 9 | + |
| 10 | + [<Fact>] |
| 11 | + let ``print with int specializes to Int32 ToString with InvariantCulture``() = |
| 12 | + FSharp """ |
| 13 | +module PrintInt |
| 14 | +
|
| 15 | +let printInt () = print 42 |
| 16 | + """ |
| 17 | + |> withOptimize |
| 18 | + |> compile |
| 19 | + |> shouldSucceed |
| 20 | + |> verifyIL [ |
| 21 | + """call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out()""" |
| 22 | + """call class [netstandard]System.Globalization.CultureInfo [netstandard]System.Globalization.CultureInfo::get_InvariantCulture()""" |
| 23 | + """call instance string [netstandard]System.Int32::ToString(string,""" |
| 24 | + """callvirt instance void [netstandard]System.IO.TextWriter::Write(string)"""] |
| 25 | + |
| 26 | + [<Fact>] |
| 27 | + let ``printn with int specializes to Int32 ToString with InvariantCulture``() = |
| 28 | + FSharp """ |
| 29 | +module PrintnInt |
| 30 | +
|
| 31 | +let printnInt () = printn 42 |
| 32 | + """ |
| 33 | + |> withOptimize |
| 34 | + |> compile |
| 35 | + |> shouldSucceed |
| 36 | + |> verifyIL [ |
| 37 | + """call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out()""" |
| 38 | + """call class [netstandard]System.Globalization.CultureInfo [netstandard]System.Globalization.CultureInfo::get_InvariantCulture()""" |
| 39 | + """call instance string [netstandard]System.Int32::ToString(string,""" |
| 40 | + """callvirt instance void [netstandard]System.IO.TextWriter::WriteLine(string)"""] |
| 41 | + |
| 42 | + [<Fact>] |
| 43 | + let ``print with string writes to Console Out``() = |
| 44 | + FSharp """ |
| 45 | +module PrintString |
| 46 | +
|
| 47 | +let printStr () = print "hello" |
| 48 | + """ |
| 49 | + |> withOptimize |
| 50 | + |> compile |
| 51 | + |> shouldSucceed |
| 52 | + |> verifyIL [ |
| 53 | + """call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out()""" |
| 54 | + """callvirt instance void [netstandard]System.IO.TextWriter::Write(string)"""] |
| 55 | + |
| 56 | + [<Fact>] |
| 57 | + let ``printn with float specializes to Double ToString with InvariantCulture``() = |
| 58 | + FSharp """ |
| 59 | +module PrintnFloat |
| 60 | +
|
| 61 | +let printnFloat () = printn 3.14 |
| 62 | + """ |
| 63 | + |> withOptimize |
| 64 | + |> compile |
| 65 | + |> shouldSucceed |
| 66 | + |> verifyIL [ |
| 67 | + """call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out()""" |
| 68 | + """call class [netstandard]System.Globalization.CultureInfo [netstandard]System.Globalization.CultureInfo::get_InvariantCulture()""" |
| 69 | + """call instance string [netstandard]System.Double::ToString(string,""" |
| 70 | + """callvirt instance void [netstandard]System.IO.TextWriter::WriteLine(string)"""] |
0 commit comments