[Pkg-cli-apps-commits] [fsharp] 28/60: Support/fixes for building and running unit tests against all portable versions of FSharp.Core (changeset 1306102)
Christopher Halse Rogers
raof-guest at moszumanska.debian.org
Sun Sep 14 08:13:39 UTC 2014
This is an automated email from the git hooks/post-receive script.
raof-guest pushed a commit to branch master
in repository fsharp.
commit 05efc2165840408fd343e5c3e84970e732e2bc1d
Author: latkin <latkin at microsoft.com>
Date: Fri Jul 25 16:50:10 2014 -0700
Support/fixes for building and running unit tests against all portable versions of FSharp.Core (changeset 1306102)
---
src/FSharpSource.targets | 4 +-
.../FSharp.Core.Unittests.fsproj | 18 ++-
.../FSharp.Core/DiscrimantedUnionType.fs | 2 +-
.../Microsoft.FSharp.Control/AsyncModule.fs | 14 +-
.../Microsoft.FSharp.Control/AsyncType.fs | 56 ++++++--
.../Microsoft.FSharp.Control/LazyType.fs | 36 ++---
.../Microsoft.FSharp.Core/BigIntType.fs | 155 ++++++++++++++++++---
.../FSharpReflection.fs | 32 ++++-
.../FSharp.Core.Unittests/FSharp.Core/PrimTypes.fs | 2 +-
src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs | 1 +
tests/RunTests.cmd | 33 ++++-
tests/TESTGUIDE.html | 10 ++
12 files changed, 300 insertions(+), 63 deletions(-)
diff --git a/src/FSharpSource.targets b/src/FSharpSource.targets
index 767d9c0..f16e8d5 100644
--- a/src/FSharpSource.targets
+++ b/src/FSharpSource.targets
@@ -702,8 +702,8 @@
'$(TargetFramework)' == 'portable78' or
'$(TargetFramework)' == 'portable259')"/>
<Error
- Text="TargetFramework '$(TargetFramework)' is only supported when building FSharp.Core.dll. All other components must be built with TargetFramework=net40"
- Condition="'$(AssemblyName)' != 'FSharp.Core' and '$(TargetFramework)' != 'net40'"/>
+ Text="TargetFramework '$(TargetFramework)' is only supported when building FSharp.Core.dll and FSharp.Core.Unittests.dll. All other components must be built with TargetFramework=net40"
+ Condition="'$(AssemblyName)' != 'FSharp.Core' and '$(AssemblyName)' != 'FSharp.Core.Unittests' and '$(TargetFramework)' != 'net40'"/>
</Target>
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj b/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
index c136a0f..f6af3b2 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
@@ -19,7 +19,14 @@
<!-- Prevent compiler from inlining calls to FSharp.Core to improve code coverage accuracy -->
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
- </PropertyGroup>
+ <TargetProfile Condition=" '$(TargetFramework)' == 'portable7' or '$(TargetFramework)' == 'portable78' or '$(TargetFramework)' == 'portable259' ">netcore</TargetProfile>
+ <!-- workaround for msbuild narrowing the assembly search paths when building portable libs -->
+ <AssemblySearchPaths Condition="$(TargetFramework.Contains('portable'))">
+ {CandidateAssemblyFiles};
+ {TargetFrameworkDirectory};
+ {Registry:Software\Microsoft\.NETFramework,v4.5,AssemblyFoldersEx};
+ </AssemblySearchPaths>
+ </PropertyGroup>
<PropertyGroup>
<DefineConstants Condition=" '$(TargetFramework)' == 'sl5' ">$(DefineConstants);SILVERLIGHT</DefineConstants>
<DefineConstants>$(DefineConstants);EXTENSIONTYPING</DefineConstants>
@@ -42,12 +49,17 @@
<WarningLevel>3</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.framework" Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'" />
+ <!-- need full name and SpecificVersion = true in order to convince msbuild to allow this reference when targeting portable47 -->
+ <Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'" >
+ <SpecificVersion>true</SpecificVersion>
+ </Reference>
<Reference Include="NUnitFramework" Condition="'$(TargetFramework)' == 'sl5' OR '$(TargetFramework)' == 'sl3-wp'" />
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj">
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
<Name>FSharp.Core</Name>
</ProjectReference>
+ </ItemGroup>
+ <ItemGroup Condition="!$(TargetFramework.Contains('portable'))">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Numerics" Condition="'$(TargetFramework)' == 'net40'" />
@@ -92,7 +104,7 @@
<Compile Include="FSharp.Core\Microsoft.FSharp.Quotations\FSharpQuotations.fs" />
<Compile Include="TypeForwarding.fs" />
<Compile Include="NUnitFrameworkShims.fs" Condition="'$(TargetFramework)' == 'sl3-wp'" />
- <Compile Include="SurfaceArea.4.0.fs"/>
+ <Compile Include="SurfaceArea.4.0.fs" Condition="'$(TargetFramework)' == 'net40'"/>
</ItemGroup>
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets" />
</Project>
\ No newline at end of file
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/DiscrimantedUnionType.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/DiscrimantedUnionType.fs
index 100f3c9..ef2c7c9 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/DiscrimantedUnionType.fs
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/DiscrimantedUnionType.fs
@@ -45,7 +45,7 @@ type UseUnionsAsFlags() =
[<Test>]
member this.CanParseViaBCL() =
let values = System.Enum.GetValues(typeof<FlagsUnion>)
- let fourFromString = System.Enum.Parse(typeof<FlagsUnion>, "Four") :?> FlagsUnion // downcast needed
+ let fourFromString = System.Enum.Parse(typeof<FlagsUnion>, "Four", false) :?> FlagsUnion // downcast needed
Assert.AreEqual(fourFromString, FlagsUnion.Four)
[<Test>]
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs
index 647edf6..3c6853e 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs
@@ -264,7 +264,10 @@ type AsyncModule() =
:? InvalidOperationException as e when e.Message = "EXPECTED" -> return ()
}
Async.RunSynchronously(test)
-
+
+#if FSHARP_CORE_NETCORE_PORTABLE
+// nothing
+#else
[<Test>]
member this.``FromContinuationsCanTailCallCurrentThread``() =
let cnt = ref 0
@@ -285,6 +288,7 @@ type AsyncModule() =
f 5000 |> Async.StartImmediate
Assert.AreEqual(origTid, !finalTid)
Assert.AreEqual(5000, !cnt)
+#endif
[<Test>]
member this.``AwaitWaitHandle With Cancellation``() =
@@ -344,6 +348,9 @@ type AsyncModule() =
#if FSHARP_CORE_PORTABLE
// nothing
#else
+#if FSHARP_CORE_NETCORE_PORTABLE
+// nothing
+#else
[<Test>]
member this.``SleepContinuations``() =
let okCount = ref 0
@@ -371,6 +378,7 @@ type AsyncModule() =
Assert.AreEqual(0, !okCount)
Assert.AreEqual(0, !errCount)
#endif
+#endif
#if FSHARP_CORE_PORTABLE
// nothing
@@ -378,6 +386,9 @@ type AsyncModule() =
#if FSHARP_CORE_2_0
// nothing
#else
+#if FSHARP_CORE_NETCORE_PORTABLE
+//nothing
+#else
// we are on the desktop
member this.RunExeAndExpectOutput(exeName, expected:string) =
let curDir = (new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).LocalPath |> System.IO.Path.GetDirectoryName
@@ -458,4 +469,5 @@ AwaitWaitHandleAlreadySignaled1 [|("ok", false); ("unhandled", false)|]
#endif
#endif
+#endif
#endif
\ No newline at end of file
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs
index b36dee2..93167dd 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs
@@ -91,6 +91,7 @@ type AsyncType() =
(fun _ -> result := "Cancel"),
cts.Token)
cts.Cancel()
+ Async.Sleep(1000) |> Async.RunSynchronously
Assert.AreEqual("Cancel", !result)
)
@@ -125,7 +126,12 @@ type AsyncType() =
member this.CreateTask () =
let s = "Hello tasks!"
let a = async { return s }
- use t : Task<string> = Async.StartAsTask a
+#if FSHARP_CORE_NETCORE_PORTABLE
+ let t : Task<string> =
+#else
+ use t : Task<string> =
+#endif
+ Async.StartAsTask a
this.WaitASec t
Assert.IsTrue (t.IsCompleted)
Assert.AreEqual(s, t.Result)
@@ -134,7 +140,12 @@ type AsyncType() =
member this.StartTask () =
let s = "Hello tasks!"
let a = async { return s }
- use t = Async.StartAsTask a
+#if FSHARP_CORE_NETCORE_PORTABLE
+ let t =
+#else
+ use t =
+#endif
+ Async.StartAsTask a
this.WaitASec t
Assert.IsTrue (t.IsCompleted)
Assert.AreEqual(s, t.Result)
@@ -144,7 +155,12 @@ type AsyncType() =
let a = async {
do raise (Exception ())
}
- use t = Async.StartAsTask a
+#if FSHARP_CORE_NETCORE_PORTABLE
+ let t =
+#else
+ use t =
+#endif
+ Async.StartAsTask a
let mutable exceptionThrown = false
try
this.WaitASec t
@@ -158,7 +174,12 @@ type AsyncType() =
let a = async {
while true do ()
}
- use t = Async.StartAsTask a
+#if FSHARP_CORE_NETCORE_PORTABLE
+ let t =
+#else
+ use t =
+#endif
+ Async.StartAsTask a
Async.CancelDefaultToken ()
let mutable exceptionThrown = false
try
@@ -178,7 +199,12 @@ type AsyncType() =
}
let cts = new CancellationTokenSource()
let token = cts.Token
- use t = Async.StartAsTask(a, cancellationToken=token)
+#if FSHARP_CORE_NETCORE_PORTABLE
+ let t =
+#else
+ use t =
+#endif
+ Async.StartAsTask(a, cancellationToken=token)
// printfn "%A" t.Status
ewh.WaitOne() |> Assert.IsTrue
cts.Cancel()
@@ -195,7 +221,12 @@ type AsyncType() =
[<Test>]
member this.TaskAsyncValue () =
let s = "Test"
- use t = Task.Factory.StartNew(Func<_>(fun () -> s))
+#if FSHARP_CORE_NETCORE_PORTABLE
+ let t =
+#else
+ use t =
+#endif
+ Task.Factory.StartNew(Func<_>(fun () -> s))
let a = async {
let! s1 = Async.AwaitTask(t)
return s = s1
@@ -204,7 +235,12 @@ type AsyncType() =
[<Test>]
member this.TaskAsyncValueException () =
- use t = Task.Factory.StartNew(Func<unit>(fun () -> raise <| Exception()))
+#if FSHARP_CORE_NETCORE_PORTABLE
+ let t =
+#else
+ use t =
+#endif
+ Task.Factory.StartNew(Func<unit>(fun () -> raise <| Exception()))
let a = async {
try
let! v = Async.AwaitTask(t)
@@ -218,7 +254,11 @@ type AsyncType() =
use ewh = new ManualResetEvent(false)
let cts = new CancellationTokenSource()
let token = cts.Token
- use t : Task<unit>=
+#if FSHARP_CORE_NETCORE_PORTABLE
+ let t : Task<unit>=
+#else
+ use t : Task<unit>=
+#endif
Task.Factory.StartNew(Func<unit>(fun () -> while not token.IsCancellationRequested do ()), token)
let cancelled = ref true
let a = async {
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/LazyType.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/LazyType.fs
index 829f3f0..ae0361e 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/LazyType.fs
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Control/LazyType.fs
@@ -15,30 +15,30 @@ type LazyType() =
member this.Create() =
// int
- let intLazy = Lazy.Create(fun () -> 2)
+ let intLazy = Lazy<_>.Create(fun () -> 2)
Assert.AreEqual(intLazy.Value, 2)
// string
- let stringLazy = Lazy.Create(fun () -> "string")
+ let stringLazy = Lazy<_>.Create(fun () -> "string")
Assert.AreEqual(stringLazy.Value, "string")
// null
- let nullLazy = Lazy.Create(fun () -> ())
+ let nullLazy = Lazy<_>.Create(fun () -> ())
Assert.AreEqual(nullLazy.Value, null)
[<Test>]
member this.CreateFromValue() =
// int
- let intLazy = Lazy.CreateFromValue( 2)
+ let intLazy = Lazy<_>.CreateFromValue( 2)
Assert.AreEqual(intLazy.Value,2)
// string
- let stringLazy = Lazy.CreateFromValue( "string")
+ let stringLazy = Lazy<_>.CreateFromValue( "string")
Assert.AreEqual(stringLazy.Value,"string")
//null
- let nullLazy = Lazy.CreateFromValue(null)
+ let nullLazy = Lazy<_>.CreateFromValue(null)
Assert.AreEqual(nullLazy.Value,null)
@@ -46,17 +46,17 @@ type LazyType() =
member this.Force() =
// int
- let intLazy = Lazy.CreateFromValue( 2)
+ let intLazy = Lazy<_>.CreateFromValue( 2)
let intForce = intLazy.Force()
Assert.AreEqual(intForce,2)
// string
- let stringLazy = Lazy.CreateFromValue( "string")
+ let stringLazy = Lazy<_>.CreateFromValue( "string")
let stringForce = stringLazy.Force()
Assert.AreEqual(stringForce,"string")
//null
- let nullLazy = Lazy.CreateFromValue(null)
+ let nullLazy = Lazy<_>.CreateFromValue(null)
let nullForce = nullLazy.Force()
Assert.AreEqual(nullForce,null)
@@ -64,35 +64,35 @@ type LazyType() =
member this.Value() =
// int
- let intLazy = Lazy.CreateFromValue( 2)
+ let intLazy = Lazy<_>.CreateFromValue( 2)
Assert.AreEqual(intLazy.Value,2)
// string
- let stringLazy = Lazy.CreateFromValue( "string")
+ let stringLazy = Lazy<_>.CreateFromValue( "string")
Assert.AreEqual(stringLazy.Value,"string")
//null
- let nullLazy = Lazy.CreateFromValue(null)
+ let nullLazy = Lazy<_>.CreateFromValue(null)
Assert.AreEqual(nullLazy.Value,null)
[<Test>]
member this.IsDelayed() =
// int
- let intLazy = Lazy.Create( fun () -> 1)
+ let intLazy = Lazy<_>.Create( fun () -> 1)
Assert.AreEqual(not intLazy.IsValueCreated,true)
let resultIsDelayed = intLazy.Force()
Assert.AreEqual(not intLazy.IsValueCreated,false)
// string
- let stringLazy = Lazy.Create( fun () -> "string")
+ let stringLazy = Lazy<_>.Create( fun () -> "string")
Assert.AreEqual(not stringLazy.IsValueCreated,true)
let resultIsDelayed = stringLazy.Force()
Assert.AreEqual(not stringLazy.IsValueCreated,false)
//null
- let nullLazy = Lazy.Create(fun () -> null)
+ let nullLazy = Lazy<_>.Create(fun () -> null)
Assert.AreEqual(not nullLazy.IsValueCreated,true)
let resultIsDelayed = nullLazy.Force()
Assert.AreEqual(not nullLazy.IsValueCreated,false)
@@ -101,20 +101,20 @@ type LazyType() =
member this.IsForced() =
// int
- let intLazy = Lazy.Create( fun () -> 1)
+ let intLazy = Lazy<_>.Create( fun () -> 1)
Assert.AreEqual( intLazy.IsValueCreated,false)
let resultIsForced = intLazy.Force()
Assert.AreEqual( intLazy.IsValueCreated,true)
// string
- let stringLazy = Lazy.Create( fun () -> "string")
+ let stringLazy = Lazy<_>.Create( fun () -> "string")
Assert.AreEqual( stringLazy.IsValueCreated,false)
let resultIsForced = stringLazy.Force()
Assert.AreEqual( stringLazy.IsValueCreated,true)
//null
- let nullLazy = Lazy.Create(fun () -> null)
+ let nullLazy = Lazy<_>.Create(fun () -> null)
Assert.AreEqual( nullLazy.IsValueCreated,false)
let resultIsForced = nullLazy.Force()
Assert.AreEqual( nullLazy.IsValueCreated,true)
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Core/BigIntType.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Core/BigIntType.fs
index fe2ff79..282a0a4 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Core/BigIntType.fs
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Core/BigIntType.fs
@@ -48,6 +48,7 @@ type BigIntType() =
Assert.AreEqual((new BigInteger(168)).ToString(), "168")
Assert.AreEqual(-168I.ToString(), "-168")
Assert.AreEqual(-0I.ToString(), "0")
+ Assert.AreEqual((BigInteger()).ToString(), "0")
[<Test>]
@@ -57,20 +58,45 @@ type BigIntType() =
let a = new BigInteger(168)
let b = 168I
let c = new BigInteger(168L)
+ let z1 = 0I
+ let z2 = BigInteger(0)
+ let z3 = BigInteger.Zero
+ let z4 = BigInteger()
+
Assert.IsTrue( (a = b) )
Assert.IsTrue( (b = c) )
Assert.IsTrue( (c = a) )
+ Assert.IsTrue( (z1 = z2) )
+ Assert.IsTrue( (z2 = z3) )
+ Assert.IsTrue( (z3 = z4) )
+ Assert.IsTrue( (z4 = z1) )
+ Assert.IsTrue( (z1 = -z2) )
+ Assert.IsTrue( (z2 = -z3) )
+ Assert.IsTrue( (z3 = -z4) )
+ Assert.IsTrue( (z4 = -z1) )
Assert.IsTrue( a.Equals(b) ); Assert.IsTrue( b.Equals(a) )
Assert.IsTrue( b.Equals(c) ); Assert.IsTrue( c.Equals(b) )
Assert.IsTrue( c.Equals(a) ); Assert.IsTrue( a.Equals(c) )
+ Assert.IsTrue( z1.Equals(z2) ); Assert.IsTrue( z2.Equals(z3) )
+ Assert.IsTrue( z3.Equals(z4) ); Assert.IsTrue( z4.Equals(z1) )
// Self equality
let a = new BigInteger(168)
- Assert.IsTrue( (a = a) )
+ Assert.IsTrue( (a = a) )
+ Assert.IsTrue( (z1 = z1) )
+ Assert.IsTrue( (z2 = z2) )
+ Assert.IsTrue( (z3 = z3) )
+ Assert.IsTrue( (z4 = z4) )
Assert.IsTrue(a.Equals(a))
+ Assert.IsTrue(z1.Equals(z1))
+ Assert.IsTrue(z2.Equals(z2))
+ Assert.IsTrue(z3.Equals(z3))
+ Assert.IsTrue(z4.Equals(z4))
// Null
- Assert.IsFalse(a.Equals(null))
+ Assert.IsFalse(a.Equals(null))
+
+ Assert.IsTrue(0I.GetHashCode() = (BigInteger()).GetHashCode())
// static methods
[<Test>]
@@ -84,6 +110,7 @@ type BigIntType() =
Assert.AreEqual(BigInteger.Abs(bigNegativeB),
bigPositiveB)
Assert.AreEqual(BigInteger.Abs(0I), 0I)
+ Assert.AreEqual(BigInteger.Abs(BigInteger()), 0I)
()
@@ -91,6 +118,7 @@ type BigIntType() =
member this.DivRem() =
let mutable r = BigInteger(0)
let mutable q = BigInteger(0)
+ let mutable qr = (BigInteger.Zero, BigInteger.Zero)
q <- BigInteger.DivRem(100I, 123I, &r)
Assert.AreEqual((q,r), (0I, 100I))
@@ -112,13 +140,13 @@ type BigIntType() =
q <- BigInteger.DivRem(0I, 100I, &r)
Assert.AreEqual((q,r), (0I, 0I))
-
- // Check ThrowsDivideByZeroException
- try
- BigInteger.DivRem(100I,0I,&r) |> ignore
- with
- | :? DivideByZeroException -> ()
- | _ -> Assert.Fail()
+
+ qr <- BigInteger.DivRem(BigInteger(), 1I)
+ Assert.AreEqual(qr, (0I, 0I))
+
+ CheckThrowsDivideByZeroException(fun () -> BigInteger.DivRem(100I,0I) |> ignore)
+ CheckThrowsDivideByZeroException(fun () -> BigInteger.DivRem(100I, BigInteger()) |> ignore)
+ CheckThrowsDivideByZeroException(fun () -> BigInteger.DivRem(BigInteger(), BigInteger()) |> ignore)
()
@@ -128,6 +156,10 @@ type BigIntType() =
Assert.AreEqual(BigInteger.GreatestCommonDivisor(bigPositiveA, bigPositiveB), 900000000090I)
Assert.AreEqual(BigInteger.GreatestCommonDivisor(bigNegativeA, bigNegativeB), 900000000090I)
Assert.AreEqual(BigInteger.GreatestCommonDivisor(0I, bigPositiveA), bigPositiveA)
+ Assert.AreEqual(BigInteger.GreatestCommonDivisor(BigInteger(), bigPositiveA), bigPositiveA)
+ Assert.AreEqual(BigInteger.GreatestCommonDivisor(bigPositiveA, BigInteger()), bigPositiveA)
+ Assert.AreEqual(BigInteger.GreatestCommonDivisor(BigInteger(), bigNegativeA), bigPositiveA)
+ Assert.AreEqual(BigInteger.GreatestCommonDivisor(BigInteger(), BigInteger()), 0I)
()
@@ -144,9 +176,19 @@ type BigIntType() =
bigPositiveA)
Assert.AreEqual(BigInteger.Parse("168"), 168I)
Assert.AreEqual(BigInteger.Parse("000"), 0I)
+ Assert.AreEqual(BigInteger.Parse("-100"), BigInteger(-100))
+ Assert.AreEqual(BigInteger.Parse("+4242"), BigInteger(4242))
+ Assert.AreEqual(BigInteger.Parse(" +4242 "), BigInteger(4242))
+ Assert.AreEqual(BigInteger.Parse("+0003"), BigInteger(3))
+
CheckThrowsFormatException(fun() -> BigInteger.Parse("abc168L") |> ignore)
CheckThrowsFormatException(fun() -> BigInteger.Parse("") |> ignore)
+ CheckThrowsFormatException(fun() -> BigInteger.Parse(" ") |> ignore)
+ CheckThrowsFormatException(fun() -> BigInteger.Parse("-") |> ignore)
+ CheckThrowsFormatException(fun() -> BigInteger.Parse("+") |> ignore)
+ CheckThrowsFormatException(fun() -> BigInteger.Parse("+-") |> ignore)
+ CheckThrowsArgumentNullException(fun() -> BigInteger.Parse(null) |> ignore)
()
#endif
@@ -157,19 +199,56 @@ type BigIntType() =
Assert.AreEqual(BigInteger.Pow(0I, 100), 0I)
Assert.AreEqual(BigInteger.Pow(2I, 0), 1I)
Assert.AreEqual(BigInteger.Pow(-10I, 2), 100I)
- CheckThrowsArgumentException(fun() -> BigInteger.Pow(100I, -2) |> ignore)
+ Assert.AreEqual(BigInteger.Pow(0I, 0), 1I)
+ Assert.AreEqual(BigInteger.Pow(BigInteger(), 0), 1I)
+ Assert.AreEqual(BigInteger.Pow(0I, 1), 0I)
+ Assert.AreEqual(BigInteger.Pow(BigInteger(), 1), 0I)
+ CheckThrowsArgumentOutOfRangeException(fun() -> BigInteger.Pow(100I, -2) |> ignore)
()
[<Test>]
member this.Sign() =
Assert.AreEqual(0I.Sign, 0)
+ Assert.AreEqual(BigInteger().Sign, 0)
Assert.AreEqual(bigPositiveA.Sign, 1)
Assert.AreEqual(bigNegativeA.Sign, -1)
()
+
+ [<Test>]
+ member this.IsZero() =
+ Assert.IsTrue(0I.IsZero)
+ Assert.IsTrue(-0I.IsZero)
+ Assert.IsTrue(BigInteger.Zero.IsZero)
+ Assert.IsTrue((-BigInteger.Zero).IsZero)
+ Assert.IsTrue(BigInteger().IsZero)
+ Assert.IsTrue((-BigInteger()).IsZero)
+ Assert.IsTrue(BigInteger(0).IsZero)
+ Assert.IsTrue((-BigInteger(0)).IsZero)
+ Assert.IsFalse(1I.IsZero)
+ Assert.IsFalse(BigInteger.One.IsZero)
+ Assert.IsFalse(-1I.IsZero)
+ ()
+
+ [<Test>]
+ member this.IsOne() =
+ Assert.IsFalse(0I.IsOne)
+ Assert.IsFalse(-0I.IsOne)
+ Assert.IsFalse(BigInteger.Zero.IsOne)
+ Assert.IsFalse((-BigInteger.Zero).IsOne)
+ Assert.IsFalse(BigInteger().IsOne)
+ Assert.IsFalse((-BigInteger()).IsOne)
+ Assert.IsFalse(BigInteger(0).IsOne)
+ Assert.IsFalse((-BigInteger(0)).IsOne)
+ Assert.IsTrue(1I.IsOne)
+ Assert.IsTrue(BigInteger.One.IsOne)
+ Assert.IsTrue(BigInteger(1).IsOne)
+ Assert.IsFalse(-1I.IsOne)
+ ()
[<Test>]
member this.ToDouble() =
Assert.AreEqual(double 0I, 0.0)
+ Assert.AreEqual(double (BigInteger()), 0.0)
Assert.AreEqual(double 123I, 123.0)
Assert.AreEqual(double -123I, -123.0)
()
@@ -177,6 +256,7 @@ type BigIntType() =
[<Test>]
member this.ToInt32() =
Assert.AreEqual(int32 0I, 0)
+ Assert.AreEqual(int32 (BigInteger()), 0)
Assert.AreEqual(int32 123I, 123)
Assert.AreEqual(int32 -123I, -123)
()
@@ -184,6 +264,7 @@ type BigIntType() =
[<Test>]
member this.ToInt64() =
Assert.AreEqual(int64 0I, 0L)
+ Assert.AreEqual(int64 (BigInteger()), 0L)
Assert.AreEqual(int64 123I, 123L)
Assert.AreEqual(int64 -123I, -123L)
@@ -192,6 +273,7 @@ type BigIntType() =
[<Test>]
member this.Zero() =
Assert.AreEqual(BigInteger.Zero,0I)
+ Assert.AreEqual(BigInteger.Zero, BigInteger())
()
// operators
@@ -200,6 +282,8 @@ type BigIntType() =
Assert.AreEqual((123I + 456I),579I)
Assert.AreEqual((-123I + (-456I)),-579I)
Assert.AreEqual((0I + 123I),123I)
+ Assert.AreEqual((BigInteger() + 123I),123I)
+ Assert.AreEqual((123I + BigInteger()),123I)
Assert.AreEqual((bigPositiveA + 0I),bigPositiveA)
Assert.AreEqual((bigPositiveA + bigNegativeA),0I)
@@ -210,7 +294,8 @@ type BigIntType() =
Assert.AreEqual((123I / 124I),0I)
Assert.AreEqual((123I / (-124I)),0I)
Assert.AreEqual((0I / 123I),0I)
-
+ Assert.AreEqual((BigInteger() / 123I),0I)
+
()
[<Test>]
@@ -220,6 +305,7 @@ type BigIntType() =
Assert.AreEqual((bigNegativeA = bigPositiveA),false)
Assert.AreEqual((bigNegativeA = (-123I)),false)
Assert.AreEqual((0I = new BigInteger(0)),true)
+ Assert.AreEqual((0I = new BigInteger()),true)
()
@@ -229,6 +315,10 @@ type BigIntType() =
Assert.AreEqual((bigNegativeA > bigPositiveB),false)
Assert.AreEqual((bigNegativeA > (-123I)),false)
Assert.AreEqual((0I > new BigInteger(0)),false)
+ Assert.AreEqual((0I > new BigInteger()),false)
+ Assert.AreEqual((BigInteger() > BigInteger()),false)
+ Assert.AreEqual((BigInteger() > 1I),false)
+ Assert.AreEqual((BigInteger() > -1I),true)
()
@@ -239,6 +329,10 @@ type BigIntType() =
Assert.AreEqual((bigPositiveB >= bigPositiveA),true)
Assert.AreEqual((bigNegativeA >= bigNegativeA),true)
Assert.AreEqual((0I >= new BigInteger(0)),true)
+ Assert.AreEqual((0I >= new BigInteger()),true)
+ Assert.AreEqual((BigInteger() >= BigInteger()),true)
+ Assert.AreEqual((BigInteger() >= 1I),false)
+ Assert.AreEqual((BigInteger() >= -1I),true)
()
@@ -249,7 +343,11 @@ type BigIntType() =
Assert.AreEqual((bigPositiveA < bigNegativeB),false)
Assert.AreEqual((bigNegativeA < bigPositiveB),true)
Assert.AreEqual((0I < new BigInteger(0)),false)
-
+ Assert.AreEqual((0I < new BigInteger()),false)
+ Assert.AreEqual((BigInteger() < BigInteger()),false)
+ Assert.AreEqual((BigInteger() < 1I),true)
+ Assert.AreEqual((BigInteger() < -1I),false)
+
()
[<Test>]
@@ -259,7 +357,11 @@ type BigIntType() =
Assert.AreEqual((bigNegativeB <= bigPositiveA),true)
Assert.AreEqual((bigNegativeA <= bigNegativeA),true)
Assert.AreEqual((0I <= new BigInteger(-0)),true)
-
+ Assert.AreEqual((0I <= new BigInteger()),true)
+ Assert.AreEqual((BigInteger() <= BigInteger()),true)
+ Assert.AreEqual((BigInteger() <= 1I),true)
+ Assert.AreEqual((BigInteger() <= -1I),false)
+
()
[<Test>]
@@ -267,7 +369,10 @@ type BigIntType() =
Assert.AreEqual((bigPositiveA % bigPositiveB),bigPositiveA)
Assert.AreEqual((bigNegativeA % bigNegativeB),bigNegativeA)
Assert.AreEqual((0I % bigPositiveA),0I)
-
+ Assert.AreEqual((BigInteger() % bigPositiveA),0I)
+ CheckThrowsDivideByZeroException(fun () -> 2I % 0I |> ignore)
+ CheckThrowsDivideByZeroException(fun () -> 2I % (BigInteger()) |> ignore)
+
()
[<Test>]
@@ -276,6 +381,7 @@ type BigIntType() =
Assert.AreEqual((123I * (-100I)),-12300I)
Assert.AreEqual((-123I * (-100I)),12300I)
Assert.AreEqual((0I * bigPositiveA),0I)
+ Assert.AreEqual((BigInteger() * bigPositiveA),0I)
Assert.AreEqual((1I * 0I),0I)
()
@@ -306,9 +412,11 @@ type BigIntType() =
]
VerifySeqsEqual resultNeg seqNeg
- let resultSmall = [0I..5I]
+ let resultSmall1 = [0I..5I]
+ let resultSmall2 = [BigInteger()..5I]
let seqSmall = [0I;1I;2I;3I;4I;5I]
- VerifySeqsEqual resultSmall seqSmall
+ VerifySeqsEqual resultSmall1 seqSmall
+ VerifySeqsEqual resultSmall2 seqSmall
()
@@ -335,9 +443,14 @@ type BigIntType() =
]
VerifySeqsEqual resultNeg seqNeg
- let resultSmall = [0I..3I..9I]
+ let resultSmall1 = [0I..3I..9I]
+ let resultSmall1 = [BigInteger()..3I..9I]
let seqSmall = [0I;3I;6I;9I]
- VerifySeqsEqual resultSmall seqSmall
+ VerifySeqsEqual resultSmall1 seqSmall
+
+ CheckThrowsArgumentException(fun () -> [0I .. BigInteger() .. 3I] |> ignore)
+
+ VerifySeqsEqual [0I .. -2I .. 10I] []
()
@@ -345,6 +458,8 @@ type BigIntType() =
member this.Subtraction() =
Assert.AreEqual((100I - 123I),-23I)
Assert.AreEqual((0I - bigPositiveB),bigNegativeB)
+ Assert.AreEqual((BigInteger() - bigPositiveB),bigNegativeB)
+ Assert.AreEqual((bigPositiveB - BigInteger()),bigPositiveB)
Assert.AreEqual((bigPositiveB - 0I),bigPositiveB)
Assert.AreEqual((-100I - (-123I)),23I)
Assert.AreEqual((100I - (-123I)),223I)
@@ -357,6 +472,7 @@ type BigIntType() =
Assert.AreEqual(-bigPositiveA,bigNegativeA)
Assert.AreEqual(-bigNegativeA,bigPositiveA)
Assert.AreEqual(-0I,0I)
+ Assert.AreEqual(-BigInteger(),0I)
()
@@ -364,7 +480,8 @@ type BigIntType() =
member this.UnaryPlus() =
Assert.AreEqual(+bigPositiveA,bigPositiveA)
Assert.AreEqual(+bigNegativeA,bigNegativeA)
- Assert.AreEqual(+0I,0I)
+ Assert.AreEqual(+0I,0I)
+ Assert.AreEqual(+BigInteger(),0I)
()
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Reflection/FSharpReflection.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Reflection/FSharpReflection.fs
index d03979e..22ceba8 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Reflection/FSharpReflection.fs
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Reflection/FSharpReflection.fs
@@ -25,6 +25,30 @@ Make sure each method works on:
* Fuction
*)
+#if FX_RESHAPED_REFLECTION
+module PrimReflectionAdapters =
+ open System.Linq
+
+ type System.Type with
+ member this.Assembly = this.GetTypeInfo().Assembly
+ member this.IsGenericType = this.GetTypeInfo().IsGenericType
+ member this.IsValueType = this.GetTypeInfo().IsValueType
+ member this.IsAssignableFrom(otherTy : Type) = this.GetTypeInfo().IsAssignableFrom(otherTy.GetTypeInfo())
+ member this.GetProperty(name) = this.GetRuntimeProperty(name)
+ member this.GetProperties() = this.GetRuntimeProperties() |> Array.ofSeq
+ member this.GetMethod(name, parameterTypes) = this.GetRuntimeMethod(name, parameterTypes)
+ member this.GetCustomAttributes(attrTy : Type, inherits : bool) : obj[] =
+ unbox (box (CustomAttributeExtensions.GetCustomAttributes(this.GetTypeInfo(), attrTy, false).ToArray()))
+
+ type System.Reflection.MemberInfo with
+ member this.ReflectedType = this.DeclaringType
+
+ type System.Reflection.Assembly with
+ member this.GetTypes() = this.DefinedTypes |> Seq.map (fun ti -> ti.AsType()) |> Array.ofSeq
+
+open PrimReflectionAdapters
+#endif
+
module IsModule =
type IsModuleType () =
member this.M = 1
@@ -769,7 +793,7 @@ type FSharpTypeTests() =
CheckThrowsArgumentNullException(fun () -> FSharpType.IsModule(null) |> ignore )
()
-
+
[<Test>]
member this.IsRecord() =
@@ -792,9 +816,11 @@ type FSharpTypeTests() =
// negative
Assert.IsFalse(FSharpType.IsRecord(typeof<unit>))
-
+#if FX_RESHAPED_REFLECTION
+ Assert.IsFalse( FSharpType.IsRecord(typeof<unit>, true) )
+#else
Assert.IsFalse( FSharpType.IsRecord(typeof<unit>, System.Reflection.BindingFlags.NonPublic) )
-
+#endif
()
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/PrimTypes.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/PrimTypes.fs
index b33a68a..e5fed7e 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/PrimTypes.fs
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/PrimTypes.fs
@@ -93,7 +93,7 @@ type LanguagePrimitivesModule() =
#if FX_NO_TO_LOWER_INVARIANT
Assert.AreEqual(s.ToLower(), (string guid).ToLower())
#else
- Assert.AreEqual(s.ToLower(Globalization.CultureInfo.InvariantCulture), (string guid).ToLower(Globalization.CultureInfo.InvariantCulture))
+ Assert.AreEqual(s.ToLowerInvariant(), (string guid).ToLowerInvariant())
#endif
[<Test>]
member this.GenericComparison() =
diff --git a/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs b/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs
index fc2fda6..3fde252 100644
--- a/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs
+++ b/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs
@@ -48,6 +48,7 @@ let CheckThrowsNotSupportedException f = CheckThrowsExn<NotSupportedException>
let CheckThrowsArgumentException f = CheckThrowsExn<ArgumentException> f
let CheckThrowsArgumentNullException f = CheckThrowsExn<ArgumentNullException> f
let CheckThrowsArgumentNullException2 s f = CheckThrowsExn2<ArgumentNullException> s f
+let CheckThrowsArgumentOutOfRangeException f = CheckThrowsExn<ArgumentOutOfRangeException> f
let CheckThrowsKeyNotFoundException f = CheckThrowsExn<KeyNotFoundException> f
let CheckThrowsDivideByZeroException f = CheckThrowsExn<DivideByZeroException> f
let CheckThrowsOverflowException f = CheckThrowsExn<OverflowException> f
diff --git a/tests/RunTests.cmd b/tests/RunTests.cmd
index 51ea15a..bd76b11 100644
--- a/tests/RunTests.cmd
+++ b/tests/RunTests.cmd
@@ -35,14 +35,33 @@ set FSCBINPATH=%~dp0..\%FLAVOR%\net40\bin
if /I "%2" == "fsharp" (goto :FSHARP)
if /I "%2" == "fsharpqa" (goto :FSHARPQA)
-if /I "%2" == "coreunit" (goto :COREUNIT)
+if /I "%2" == "coreunit" (
+ set coreunitsuffix=net40
+ goto :COREUNIT
+)
+if /I "%2" == "coreunitportable47" (
+ set coreunitsuffix=portable47
+ goto :COREUNIT
+)
+if /I "%2" == "coreunitportable7" (
+ set coreunitsuffix=portable7
+ goto :COREUNIT
+)
+if /I "%2" == "coreunitportable78" (
+ set coreunitsuffix=portable78
+ goto :COREUNIT
+)
+if /I "%2" == "coreunitportable259" (
+ set coreunitsuffix=portable259
+ goto :COREUNIT
+)
if /I "%2" == "ideunit" (goto :IDEUNIT)
:USAGE
echo Usage:
echo.
-echo RunTests.cmd ^<debug^|release^> ^<fsharp^|fsharpqa^|coreunit^|ideunit^> [TagToRun^|"Tags,To,Run"] [TagNotToRun^|"Tags,Not,To,Run"]
+echo RunTests.cmd ^<debug^|release^> ^<fsharp^|fsharpqa^|coreunit^|coreunitportable47^|coreunitportable7^|coreunitportable78^|coreunit259^|ideunit^> [TagToRun^|"Tags,To,Run"] [TagNotToRun^|"Tags,Not,To,Run"]
echo.
exit /b 1
@@ -141,9 +160,9 @@ goto :EOF
:COREUNIT
-set XMLFILE=CoreUnit_Xml.xml
-set OUTPUTFILE=CoreUnit_Output.log
-set ERRORFILE=CoreUnit_Error.log
+set XMLFILE=CoreUnit_%coreunitsuffix%_Xml.xml
+set OUTPUTFILE=CoreUnit_%coreunitsuffix%_Output.log
+set ERRORFILE=CoreUnit_%coreunitsuffix%_Error.log
set FILEDIR=%~dp0
where.exe nunit-console.exe > NUL 2> NUL
@@ -151,8 +170,8 @@ if errorlevel 1 (
echo Error: nunit-console.exe is not in the PATH
exit /b 1
)
-echo nunit-console.exe /nologo /result=%XMLFILE% /output=%OUTPUTFILE% /err=%ERRORFILE% /work=%FILEDIR% %FSCBINPATH%\FSharp.Core.Unittests.dll
- nunit-console.exe /nologo /result=%XMLFILE% /output=%OUTPUTFILE% /err=%ERRORFILE% /work=%FILEDIR% %FSCBINPATH%\FSharp.Core.Unittests.dll
+echo nunit-console.exe /nologo /result=%XMLFILE% /output=%OUTPUTFILE% /err=%ERRORFILE% /work=%FILEDIR% %FSCBINPATH%\..\..\%coreunitsuffix%\bin\FSharp.Core.Unittests.dll
+ nunit-console.exe /nologo /result=%XMLFILE% /output=%OUTPUTFILE% /err=%ERRORFILE% /work=%FILEDIR% %FSCBINPATH%\..\..\%coreunitsuffix%\bin\FSharp.Core.Unittests.dll
goto :EOF
diff --git a/tests/TESTGUIDE.html b/tests/TESTGUIDE.html
index d54bf7d..637ce53 100644
--- a/tests/TESTGUIDE.html
+++ b/tests/TESTGUIDE.html
@@ -337,8 +337,14 @@
<li><code>msbuild src\fsharp-library-build.proj /p:TargetFramework=net20 /p:Configuration=<debug|release></code> to generate the libraries for .NET 2</li>
<li><code>msbuild src\fsharp-library-build.proj /p:TargetFramework=portable47 /p:Configuration=<debug|release></code> to generate the libraries for .NET portable profile 47</li>
<li><code>msbuild src\fsharp-library-build.proj /p:TargetFramework=portable7 /p:Configuration=<debug|release></code> to generate the libraries for .NET portable profile 7</li>
+ <li><code>msbuild src\fsharp-library-build.proj /p:TargetFramework=portable78 /p:Configuration=<debug|release></code> to generate the libraries for .NET portable profile 78</li>
+ <li><code>msbuild src\fsharp-library-build.proj /p:TargetFramework=portable259 /p:Configuration=<debug|release></code> to generate the libraries for .NET portable profile 259</li>
<li><code>msbuild src\fsharp-typeproviders-build.proj /p:Configuration=<debug|release></code> to generate FSharp.Data.TypeProviders.dll for .NET 4</li>
<li><code>msbuild src\fsharp-library-unittests-build.proj /p:Configuration=<debug|release></code> to generate FSharp.Core unit tests</li>
+ <li><code>msbuild src\fsharp-library-unittests-build.proj /p:TargetFramework=portable47 /p:Configuration=<debug|release></code> to generate FSharp.Core unit tests for .NET portable profile 47</li>
+ <li><code>msbuild src\fsharp-library-unittests-build.proj /p:TargetFramework=portable7 /p:Configuration=<debug|release></code> to generate FSharp.Core unit tests for .NET portable profile 7</li>
+ <li><code>msbuild src\fsharp-library-unittests-build.proj /p:TargetFramework=portable78 /p:Configuration=<debug|release></code> to generate FSharp.Core unit tests for .NET portable profile 78</li>
+ <li><code>msbuild src\fsharp-library-unittests-build.proj /p:TargetFramework=portable259 /p:Configuration=<debug|release></code> to generate FSharp.Core unit tests for .NET portable profile 259</li>
<li><code>msbuild vsintegration\fsharp-vsintegration-build.proj /p:Configuration=<debug|release></code> to generate all Visual Studio integration components</li>
<li><code>msbuild vsintegration\fsharp-vsintegration-unittests-build.proj /p:Configuration=<debug|release></code> to generate IDE unit tests</li>
<li><code>src\update.cmd <debug|release> -ngen</code> to update the GAC, add strong name validation skips, and ngen latest-built binaries</li>
@@ -352,6 +358,10 @@
RunTests.cmd <debug|release> fsharp [tags to run] [tags not to run]
RunTests.cmd <debug|release> fsharpqa [tags to run] [tags not to run]
RunTests.cmd <debug|release> coreunit
+ RunTests.cmd <debug|release> coreunitportable47
+ RunTests.cmd <debug|release> coreunitportable7
+ RunTests.cmd <debug|release> coreunitportable78
+ RunTests.cmd <debug|release> coreunitportable259
RunTests.cmd <debug|release> ideunit
</pre>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-cli-apps/packages/fsharp.git
More information about the Pkg-cli-apps-commits
mailing list