Skip to content

Commit

Permalink
Moved fsharpqa/Libraries/Core/LanguagePrimitives FSI test cases to NU…
Browse files Browse the repository at this point in the history
…nit (#9435)

* Migrated comparison FSI test case

* Migrated string format FSI test case
  • Loading branch information
ThorstenReichert committed Jun 13, 2020
1 parent 19c8cbc commit 4dd0741
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 153 deletions.
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.

0 comments on commit 4dd0741

Please sign in to comment.