Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master to release/dev16.7 #9436

Merged
merged 1 commit into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open NUnit.Framework
open FSharp.TestHelpers

[<TestFixture>]
module ``Comparison Tests`` =
Expand All @@ -16,4 +17,27 @@ module ``Comparison Tests`` =

Assert.IsFalse (W System.Double.NaN = W System.Double.NaN)
Assert.IsTrue ((W System.Double.NaN).Equals(W System.Double.NaN))
Assert.areEqual (compare (W System.Double.NaN) (W System.Double.NaN)) 0
Assert.areEqual (compare (W System.Double.NaN) (W System.Double.NaN)) 0

[<Test>]
let ``Comparisons with wrapped NaN in FSI``() =
// Regression test for FSHARP1.0:5640
// This is a sanity test: more coverage in FSHARP suite...

CompilerAssert.RunScriptWithOptions [| "--langversion:preview" |]
"""
type 'a www = W of 'a

let assertTrue a =
if (not a) then failwithf "Expected true, but found false."
()

let p = W System.Double.NaN = W System.Double.NaN
let q = (W System.Double.NaN).Equals(W System.Double.NaN)
let z = compare (W System.Double.NaN) (W System.Double.NaN)

assertTrue (not p)
assertTrue q
assertTrue (z = 0)
"""
[]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open NUnit.Framework
open FSharp.TestHelpers

[<TestFixture>]
module ``String Format Tests`` =
Expand Down Expand Up @@ -137,3 +138,70 @@ module ``String Format Tests`` =
Assert.areEqual (string infinityf) "Infinity"
Assert.areEqual (string nanf) "NaN"
Assert.areEqual (string (new System.Guid("210f4d6b-cb42-4b09-baa1-f1aa8e59d4b0"))) "210f4d6b-cb42-4b09-baa1-f1aa8e59d4b0"

[<Test>]
let ``string constructor in FSI``() =
// Regression test for FSHARP1.0:5894

CompilerAssert.RunScriptWithOptions [| "--langversion:preview" |]
"""
let assertEqual a b =
if a <> b then failwithf "Expected '%s', but got '%s'" a b
()

assertEqual (string 1.0f) "1"
assertEqual (string 1.00001f) "1.00001"
assertEqual (string -1.00001f) "-1.00001"
assertEqual (string 1.0) "1"
assertEqual (string 1.00001) "1.00001"
assertEqual (string -1.00001) "-1.00001"
assertEqual (string System.SByte.MaxValue) "127"
assertEqual (string System.SByte.MinValue) "-128"
assertEqual (string 0y) "0"
assertEqual (string -1y) "-1"
assertEqual (string 1y) "1"
assertEqual (string System.Byte.MaxValue) "255"
assertEqual (string System.Byte.MinValue) "0"
assertEqual (string 0uy) "0"
assertEqual (string 1uy) "1"
assertEqual (string System.Int16.MaxValue) "32767"
assertEqual (string System.Int16.MinValue) "-32768"
assertEqual (string 0s) "0"
assertEqual (string -10s) "-10"
assertEqual (string 10s) "10"
assertEqual (string System.UInt16.MaxValue) "65535"
assertEqual (string System.UInt16.MinValue) "0"
assertEqual (string 0us) "0"
assertEqual (string 110us) "110"
assertEqual (string System.Int32.MaxValue) "2147483647"
assertEqual (string System.Int32.MinValue) "-2147483648"
assertEqual (string 0) "0"
assertEqual (string -10) "-10"
assertEqual (string 10) "10"
assertEqual (string System.UInt32.MaxValue) "4294967295"
assertEqual (string System.UInt32.MinValue) "0"
assertEqual (string 0u) "0"
assertEqual (string 10u) "10"
assertEqual (string System.Int64.MaxValue) "9223372036854775807"
assertEqual (string System.Int64.MinValue) "-9223372036854775808"
assertEqual (string 0L) "0"
assertEqual (string -10L) "-10"
assertEqual (string 10L) "10"
assertEqual (string System.UInt64.MaxValue) "18446744073709551615"
assertEqual (string System.UInt64.MinValue) "0"
assertEqual (string 0UL) "0"
assertEqual (string 10UL) "10"
assertEqual (string System.Decimal.MaxValue) "79228162514264337593543950335"
assertEqual (string System.Decimal.MinValue) "-79228162514264337593543950335"
assertEqual (string System.Decimal.Zero) "0"
assertEqual (string 12345678M) "12345678"
assertEqual (string -12345678M) "-12345678"
assertEqual (string -infinity) "-Infinity"
assertEqual (string infinity) "Infinity"
assertEqual (string nan) "NaN"
assertEqual (string -infinityf) "-Infinity"
assertEqual (string infinityf) "Infinity"
assertEqual (string nanf) "NaN"
assertEqual (string (new System.Guid("210f4d6b-cb42-4b09-baa1-f1aa8e59d4b0"))) "210f4d6b-cb42-4b09-baa1-f1aa8e59d4b0"
"""
[]

This file was deleted.

This file was deleted.

This file was deleted.