diff --git a/.gitignore b/.gitignore index 8437862b50..8a7f2a5afe 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,5 @@ build.ok *.vserr *.userprefs +extras +ossreadme*.txt diff --git a/src/FSharpSource.targets b/src/FSharpSource.targets index 869dcc6e50..08fef4f5db 100755 --- a/src/FSharpSource.targets +++ b/src/FSharpSource.targets @@ -277,8 +277,8 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do $(MSBuildExtensionsPath32)\..\xbuild-frameworks\.NETPortable\v4.5 $(OtherFlags) --targetprofile:netcore - - + + $(TargetFramework) $(DefineConstants);FSHARP_CORE_NETCORE_PORTABLE @@ -318,6 +318,7 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do $(OtherFlags) --targetprofile:netcore + $(TargetFramework) $(DefineConstants);FSHARP_CORE_NETCORE_PORTABLE @@ -863,7 +864,7 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do + Condition="'$(Configuration)'!='Release' and '$(Configuration)'!='Debug' and '$(Configuration)'!='VSRelease' and '$(Configuration)'!='VSDebug' and '$(Configuration)'!='Proto'"/> diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index a928ad7fe3..a383b803e1 100755 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -1142,7 +1142,7 @@ lexIndentOffForML,"Consider using a file with extension '.ml' or '.mli' instead" fscTooManyErrors,"Exiting - too many errors" 2001,docfileNoXmlSuffix,"The documentation file has no .xml suffix" 2002,fscNoImplementationFiles,"No implementation files specified" -2003,fscBadAssemblyVersion,"An AssemblyVersionAttribute specified version '%s', but this value is invalid and has been ignored" +2003,fscBadAssemblyVersion,"An %s specified version '%s', but this value is invalid and has been ignored" 2004,fscTwoResourceManifests,"Conflicting options specified: 'win32manifest' and 'win32res'. Only one of these can be used." 2005,fscQuotationLiteralsStaticLinking,"The code in assembly '%s' makes uses of quotation literals. Static linking may not include components that make use of quotation literals." 2006,fscQuotationLiteralsStaticLinking0,"Code in this assembly makes uses of quotation literals. Static linking may not include components that make use of quotation literals." diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj b/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj index 481949ef64..688d36a2e5 100644 --- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj +++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj @@ -18,6 +18,13 @@ false false + netcore + + + {CandidateAssemblyFiles}; + {TargetFrameworkDirectory}; + {Registry:Software\Microsoft\.NETFramework,v4.5,AssemblyFoldersEx}; + $(DefineConstants);SILVERLIGHT @@ -42,7 +49,10 @@ False - + + + true + {DED3BBD7-53F4-428A-8C9F-27968E768605} @@ -50,6 +60,8 @@ + + @@ -101,7 +113,7 @@ - + diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/DiscrimantedUnionType.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/DiscrimantedUnionType.fs index 100f3c9b60..ef2c7c9fcf 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() = [] member this.CanParseViaBCL() = let values = System.Enum.GetValues(typeof) - let fourFromString = System.Enum.Parse(typeof, "Four") :?> FlagsUnion // downcast needed + let fourFromString = System.Enum.Parse(typeof, "Four", false) :?> FlagsUnion // downcast needed Assert.AreEqual(fourFromString, FlagsUnion.Four) [] 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 e7cc79ce86..18b43ec842 100755 --- 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 [] 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 [] member this.``AwaitWaitHandle With Cancellation``() = @@ -343,6 +347,9 @@ type AsyncModule() = #if FSHARP_CORE_PORTABLE // nothing +#else +#if FSHARP_CORE_NETCORE_PORTABLE +// nothing #else [] member this.``SleepContinuations``() = @@ -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 @@ -455,5 +466,6 @@ AwaitWaitHandleAlreadySignaled0 [|("ok", true); ("caught:boom", true)|] AwaitWaitHandleAlreadySignaled1 [|("ok", false); ("unhandled", false)|] """ ) +#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 b36dee28ea..93167dd467 100755 --- 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 = Async.StartAsTask a +#if FSHARP_CORE_NETCORE_PORTABLE + let t : Task = +#else + use t : Task = +#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() = [] 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() = [] member this.TaskAsyncValueException () = - use t = Task.Factory.StartNew(Func(fun () -> raise <| Exception())) +#if FSHARP_CORE_NETCORE_PORTABLE + let t = +#else + use t = +#endif + Task.Factory.StartNew(Func(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= +#if FSHARP_CORE_NETCORE_PORTABLE + let t : Task= +#else + use t : Task= +#endif Task.Factory.StartNew(Func(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 829f3f0339..ae0361efdd 100755 --- 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) [] 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) [] 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 fe2ff79f18..51cef66303 100755 --- 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,10 @@ type BigIntType() = Assert.AreEqual((new BigInteger(168)).ToString(), "168") Assert.AreEqual(-168I.ToString(), "-168") Assert.AreEqual(-0I.ToString(), "0") +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((BigInteger()).ToString(), "0") +#endif [] @@ -57,20 +61,63 @@ 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) ) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.IsTrue( (z3 = z4) ) + Assert.IsTrue( (z4 = z1) ) +#endif + Assert.IsTrue( (z1 = -z2) ) + Assert.IsTrue( (z2 = -z3) ) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.IsTrue( (z3 = -z4) ) + Assert.IsTrue( (z4 = -z1) ) +#endif 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) ) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.IsTrue( z3.Equals(z4) ); Assert.IsTrue( z4.Equals(z1) ) +#endif // 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) ) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.IsTrue( (z4 = z4) ) +#endif Assert.IsTrue(a.Equals(a)) + Assert.IsTrue(z1.Equals(z1)) + Assert.IsTrue(z2.Equals(z2)) + Assert.IsTrue(z3.Equals(z3)) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.IsTrue(z4.Equals(z4)) +#endif // Null - Assert.IsFalse(a.Equals(null)) + Assert.IsFalse(a.Equals(null)) + +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.IsTrue(0I.GetHashCode() = (BigInteger()).GetHashCode()) +#endif // static methods [] @@ -84,6 +131,10 @@ type BigIntType() = Assert.AreEqual(BigInteger.Abs(bigNegativeB), bigPositiveB) Assert.AreEqual(BigInteger.Abs(0I), 0I) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual(BigInteger.Abs(BigInteger()), 0I) +#endif () @@ -91,6 +142,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 +164,16 @@ 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() + +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + qr <- BigInteger.DivRem(BigInteger(), 1I) + Assert.AreEqual(qr, (0I, 0I)) + CheckThrowsDivideByZeroException(fun () -> BigInteger.DivRem(100I, BigInteger()) |> ignore) + CheckThrowsDivideByZeroException(fun () -> BigInteger.DivRem(BigInteger(), BigInteger()) |> ignore) +#endif + + CheckThrowsDivideByZeroException(fun () -> BigInteger.DivRem(100I,0I) |> ignore) () @@ -128,6 +183,13 @@ type BigIntType() = Assert.AreEqual(BigInteger.GreatestCommonDivisor(bigPositiveA, bigPositiveB), 900000000090I) Assert.AreEqual(BigInteger.GreatestCommonDivisor(bigNegativeA, bigNegativeB), 900000000090I) Assert.AreEqual(BigInteger.GreatestCommonDivisor(0I, bigPositiveA), bigPositiveA) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + 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) +#endif () @@ -144,9 +206,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 +229,68 @@ 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) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual(BigInteger.Pow(BigInteger(), 0), 1I) + Assert.AreEqual(BigInteger.Pow(BigInteger(), 1), 0I) +#endif + Assert.AreEqual(BigInteger.Pow(0I, 1), 0I) + CheckThrowsArgumentOutOfRangeException(fun() -> BigInteger.Pow(100I, -2) |> ignore) () [] member this.Sign() = Assert.AreEqual(0I.Sign, 0) + Assert.AreEqual(BigInteger().Sign, 0) Assert.AreEqual(bigPositiveA.Sign, 1) Assert.AreEqual(bigNegativeA.Sign, -1) () + + [] + member this.IsZero() = + Assert.IsTrue(0I.IsZero) + Assert.IsTrue(-0I.IsZero) + Assert.IsTrue(BigInteger.Zero.IsZero) + Assert.IsTrue((-BigInteger.Zero).IsZero) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.IsTrue(BigInteger().IsZero) + Assert.IsTrue((-BigInteger()).IsZero) +#endif + Assert.IsTrue(BigInteger(0).IsZero) + Assert.IsTrue((-BigInteger(0)).IsZero) + Assert.IsFalse(1I.IsZero) + Assert.IsFalse(BigInteger.One.IsZero) + Assert.IsFalse(-1I.IsZero) + () + + [] + member this.IsOne() = + Assert.IsFalse(0I.IsOne) + Assert.IsFalse(-0I.IsOne) + Assert.IsFalse(BigInteger.Zero.IsOne) + Assert.IsFalse((-BigInteger.Zero).IsOne) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.IsFalse(BigInteger().IsOne) + Assert.IsFalse((-BigInteger()).IsOne) +#endif + 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) + () [] member this.ToDouble() = Assert.AreEqual(double 0I, 0.0) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual(double (BigInteger()), 0.0) +#endif Assert.AreEqual(double 123I, 123.0) Assert.AreEqual(double -123I, -123.0) () @@ -177,6 +298,10 @@ type BigIntType() = [] member this.ToInt32() = Assert.AreEqual(int32 0I, 0) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual(int32 (BigInteger()), 0) +#endif Assert.AreEqual(int32 123I, 123) Assert.AreEqual(int32 -123I, -123) () @@ -184,6 +309,10 @@ type BigIntType() = [] member this.ToInt64() = Assert.AreEqual(int64 0I, 0L) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual(int64 (BigInteger()), 0L) +#endif Assert.AreEqual(int64 123I, 123L) Assert.AreEqual(int64 -123I, -123L) @@ -192,6 +321,10 @@ type BigIntType() = [] member this.Zero() = Assert.AreEqual(BigInteger.Zero,0I) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual(BigInteger.Zero, BigInteger()) +#endif () // operators @@ -200,6 +333,11 @@ type BigIntType() = Assert.AreEqual((123I + 456I),579I) Assert.AreEqual((-123I + (-456I)),-579I) Assert.AreEqual((0I + 123I),123I) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((BigInteger() + 123I),123I) + Assert.AreEqual((123I + BigInteger()),123I) +#endif Assert.AreEqual((bigPositiveA + 0I),bigPositiveA) Assert.AreEqual((bigPositiveA + bigNegativeA),0I) @@ -210,7 +348,11 @@ type BigIntType() = Assert.AreEqual((123I / 124I),0I) Assert.AreEqual((123I / (-124I)),0I) Assert.AreEqual((0I / 123I),0I) - +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((BigInteger() / 123I),0I) +#endif + () [] @@ -220,6 +362,10 @@ type BigIntType() = Assert.AreEqual((bigNegativeA = bigPositiveA),false) Assert.AreEqual((bigNegativeA = (-123I)),false) Assert.AreEqual((0I = new BigInteger(0)),true) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((0I = new BigInteger()),true) +#endif () @@ -229,6 +375,13 @@ type BigIntType() = Assert.AreEqual((bigNegativeA > bigPositiveB),false) Assert.AreEqual((bigNegativeA > (-123I)),false) Assert.AreEqual((0I > new BigInteger(0)),false) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((0I > new BigInteger()),false) + Assert.AreEqual((BigInteger() > BigInteger()),false) + Assert.AreEqual((BigInteger() > 1I),false) + Assert.AreEqual((BigInteger() > -1I),true) +#endif () @@ -239,6 +392,13 @@ type BigIntType() = Assert.AreEqual((bigPositiveB >= bigPositiveA),true) Assert.AreEqual((bigNegativeA >= bigNegativeA),true) Assert.AreEqual((0I >= new BigInteger(0)),true) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((0I >= new BigInteger()),true) + Assert.AreEqual((BigInteger() >= BigInteger()),true) + Assert.AreEqual((BigInteger() >= 1I),false) + Assert.AreEqual((BigInteger() >= -1I),true) +#endif () @@ -249,7 +409,14 @@ type BigIntType() = Assert.AreEqual((bigPositiveA < bigNegativeB),false) Assert.AreEqual((bigNegativeA < bigPositiveB),true) Assert.AreEqual((0I < new BigInteger(0)),false) - +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((0I < new BigInteger()),false) + Assert.AreEqual((BigInteger() < BigInteger()),false) + Assert.AreEqual((BigInteger() < 1I),true) + Assert.AreEqual((BigInteger() < -1I),false) +#endif + () [] @@ -259,7 +426,14 @@ type BigIntType() = Assert.AreEqual((bigNegativeB <= bigPositiveA),true) Assert.AreEqual((bigNegativeA <= bigNegativeA),true) Assert.AreEqual((0I <= new BigInteger(-0)),true) - +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((0I <= new BigInteger()),true) + Assert.AreEqual((BigInteger() <= BigInteger()),true) + Assert.AreEqual((BigInteger() <= 1I),true) + Assert.AreEqual((BigInteger() <= -1I),false) +#endif + () [] @@ -267,7 +441,13 @@ type BigIntType() = Assert.AreEqual((bigPositiveA % bigPositiveB),bigPositiveA) Assert.AreEqual((bigNegativeA % bigNegativeB),bigNegativeA) Assert.AreEqual((0I % bigPositiveA),0I) - +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((BigInteger() % bigPositiveA),0I) + CheckThrowsDivideByZeroException(fun () -> 2I % 0I |> ignore) + CheckThrowsDivideByZeroException(fun () -> 2I % (BigInteger()) |> ignore) +#endif + () [] @@ -276,6 +456,10 @@ type BigIntType() = Assert.AreEqual((123I * (-100I)),-12300I) Assert.AreEqual((-123I * (-100I)),12300I) Assert.AreEqual((0I * bigPositiveA),0I) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((BigInteger() * bigPositiveA),0I) +#endif Assert.AreEqual((1I * 0I),0I) () @@ -306,9 +490,15 @@ type BigIntType() = ] VerifySeqsEqual resultNeg seqNeg - let resultSmall = [0I..5I] + let resultSmall1 = [0I..5I] let seqSmall = [0I;1I;2I;3I;4I;5I] - VerifySeqsEqual resultSmall seqSmall + VerifySeqsEqual resultSmall1 seqSmall + +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + let resultSmall2 = [BigInteger()..5I] + VerifySeqsEqual resultSmall2 seqSmall +#endif () @@ -335,9 +525,17 @@ type BigIntType() = ] VerifySeqsEqual resultNeg seqNeg - let resultSmall = [0I..3I..9I] + let resultSmall1 = [0I..3I..9I] +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + let resultSmall1 = [BigInteger()..3I..9I] let seqSmall = [0I;3I;6I;9I] - VerifySeqsEqual resultSmall seqSmall + VerifySeqsEqual resultSmall1 seqSmall + + CheckThrowsArgumentException(fun () -> [0I .. BigInteger() .. 3I] |> ignore) + +#endif + VerifySeqsEqual [0I .. -2I .. 10I] [] () @@ -345,6 +543,11 @@ type BigIntType() = member this.Subtraction() = Assert.AreEqual((100I - 123I),-23I) Assert.AreEqual((0I - bigPositiveB),bigNegativeB) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual((BigInteger() - bigPositiveB),bigNegativeB) + Assert.AreEqual((bigPositiveB - BigInteger()),bigPositiveB) +#endif Assert.AreEqual((bigPositiveB - 0I),bigPositiveB) Assert.AreEqual((-100I - (-123I)),23I) Assert.AreEqual((100I - (-123I)),223I) @@ -357,6 +560,10 @@ type BigIntType() = Assert.AreEqual(-bigPositiveA,bigNegativeA) Assert.AreEqual(-bigNegativeA,bigPositiveA) Assert.AreEqual(-0I,0I) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual(-BigInteger(),0I) +#endif () @@ -364,7 +571,11 @@ type BigIntType() = member this.UnaryPlus() = Assert.AreEqual(+bigPositiveA,bigPositiveA) Assert.AreEqual(+bigNegativeA,bigNegativeA) - Assert.AreEqual(+0I,0I) + Assert.AreEqual(+0I,0I) +#if MONO // see https://bugzilla.xamarin.com/show_bug.cgi?id=22591 +#else + Assert.AreEqual(+BigInteger(),0I) +#endif () 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 d03979e87b..22ceba8e93 100755 --- 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 ) () - + [] member this.IsRecord() = @@ -792,9 +816,11 @@ type FSharpTypeTests() = // negative Assert.IsFalse(FSharpType.IsRecord(typeof)) - +#if FX_RESHAPED_REFLECTION + Assert.IsFalse( FSharpType.IsRecord(typeof, true) ) +#else Assert.IsFalse( FSharpType.IsRecord(typeof, 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 eee611ab1b..7d7ce19941 100755 --- 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 [] member this.GenericComparison() = diff --git a/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs b/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs index fc2fda663f..02ebe39fa9 100755 --- a/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs +++ b/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs @@ -48,6 +48,7 @@ let CheckThrowsNotSupportedException f = CheckThrowsExn let CheckThrowsArgumentException f = CheckThrowsExn f let CheckThrowsArgumentNullException f = CheckThrowsExn f let CheckThrowsArgumentNullException2 s f = CheckThrowsExn2 s f +let CheckThrowsArgumentOutOfRangeException f = CheckThrowsExn f let CheckThrowsKeyNotFoundException f = CheckThrowsExn f let CheckThrowsDivideByZeroException f = CheckThrowsExn f let CheckThrowsOverflowException f = CheckThrowsExn f @@ -56,13 +57,11 @@ let CheckThrowsFormatException f = CheckThrowsExn // Verifies two sequences are equal (same length, equiv elements) let VerifySeqsEqual seq1 seq2 = - if Seq.length seq1 <> Seq.length seq2 then Assert.Fail() - - let zippedElements = Seq.zip seq1 seq2 - if zippedElements |> Seq.forall (fun (a, b) -> a = b) - then () - else Assert.Fail() - + Assert.AreEqual(Seq.length seq1, Seq.length seq2, "Sequences are different lengths.") + + Seq.zip seq1 seq2 + |> Seq.iteri (fun i (a, b) -> if a <> b then Assert.Fail("Sequences are different in position {0}\n Expected: {1}\n But was: {2}", i, a, b)) + let sleep(n : int32) = #if FX_NO_THREAD async { do! Async.Sleep(n) } |> Async.RunSynchronously diff --git a/src/fsharp/FSharp.Core/control.fs b/src/fsharp/FSharp.Core/control.fs index 58e1b1f2ff..a1b8e903a3 100755 --- a/src/fsharp/FSharp.Core/control.fs +++ b/src/fsharp/FSharp.Core/control.fs @@ -1476,8 +1476,13 @@ namespace Microsoft.FSharp.Control static member Sleep(dueTime : int) : Async = // use combo protectedPrimitiveWithResync + continueWith instead of AwaitTask so we can pass cancellation token to the Delay task unprotectedPrimitiveWithResync ( fun ({ aux = aux} as args) -> - TaskHelpers.continueWithUnit(Task.Delay(dueTime, aux.token), args) - ) + let mutable the_exn = null + let task = try Task.Delay(dueTime, aux.token) + with e -> the_exn <- e; null + match the_exn with + | null -> TaskHelpers.continueWithUnit(task, args) + | e -> aux.econt e + ) #else static member Sleep(dueTime) : Async = unprotectedPrimitiveWithResync (fun ({ aux = aux } as args) -> diff --git a/src/fsharp/FSharp.Core/math/n.fs b/src/fsharp/FSharp.Core/math/n.fs index 2f1945af12..09b779b9de 100755 --- a/src/fsharp/FSharp.Core/math/n.fs +++ b/src/fsharp/FSharp.Core/math/n.fs @@ -1562,7 +1562,7 @@ module internal BigNatModule = if 0 <= d && d <= 9 then build (add (mul ten acc) (embed d)) (i+1) else - raise (new System.FormatException("The value could not be parsed")) + raise (new System.FormatException(SR.GetString(SR.badFormatString))) build (embed 0) 0 diff --git a/src/fsharp/FSharp.Core/math/z.fs b/src/fsharp/FSharp.Core/math/z.fs index c3578a1bc7..e389f2a3f9 100755 --- a/src/fsharp/FSharp.Core/math/z.fs +++ b/src/fsharp/FSharp.Core/math/z.fs @@ -19,7 +19,10 @@ namespace System.Numerics // NOTE: 0 has two repns (+1,0) or (-1,0). [] [] +#if FX_ATLEAST_PORTABLE +#else [] +#endif type BigInteger(signInt:int, v : BigNat) = static let smallLim = 4096 @@ -31,13 +34,17 @@ namespace System.Numerics if BigNatModule.isSmall n && BigNatModule.getSmall n < smallLim then smallPosTab.[BigNatModule.getSmall n] else n + static member internal create (s,n) = BigInteger(s,BigInteger.nat n) + static member internal posn n = BigInteger(1,BigInteger.nat n) - static member internal negn n = BigInteger(-1,BigInteger.nat n) + static member internal negn n = BigInteger(-1,BigInteger.nat n) member x.Sign = if x.IsZero then 0 else signInt + member x.SignInt = signInt + member internal x.V = v static member op_Equality (x:BigInteger, y:BigInteger) = @@ -48,7 +55,12 @@ namespace System.Numerics | -1, -1 -> BigNatModule.equal x.V y.V // -1.xv = -1.yv iff xv = yv | 1,-1 -> BigNatModule.isZero x.V && BigNatModule.isZero y.V // 1.xv = -1.yv iff xv=0 and yv=0 | -1, 1 -> BigNatModule.isZero x.V && BigNatModule.isZero y.V // -1.xv = 1.yv iff xv=0 and yv=0 - | _ -> invalidArg "x" "signs should be +/- 1" + | 0, 0 -> true + | 0, 1 -> BigNatModule.isZero y.V + | 0, -1 -> BigNatModule.isZero y.V + | 1, 0 -> BigNatModule.isZero x.V + | -1, 0 -> BigNatModule.isZero x.V + | _ -> invalidArg "x" "signs should be +/- 1 or 0" static member op_Inequality (x:BigInteger, y:BigInteger) = not (BigInteger.op_Equality(x,y)) // CA2226: OperatorsShouldHaveSymmetricalOverloads @@ -62,7 +74,12 @@ namespace System.Numerics // (a) xv=0 and yv=0, then false // (b) xv<>0, -1.xv < 0 <= 1.yv, so true // (c) yv<>0, -1.xv <= 0 < 1.yv, so true - | _ -> invalidArg "x" "signs should be +/- 1" + | 0, 0 -> false + | 0, 1 -> not (BigNatModule.isZero y.V) + | 0,-1 -> false + | 1, 0 -> false + | -1, 0 -> not (BigNatModule.isZero x.V) + | _ -> invalidArg "x" "signs should be +/- 1 or 0" static member op_GreaterThan (x:BigInteger, y:BigInteger) = // Follow lt by +/- symmetry match x.SignInt,y.SignInt with @@ -70,10 +87,18 @@ namespace System.Numerics | -1,-1 -> BigNatModule.gt y.V x.V | 1,-1 -> not (BigNatModule.isZero x.V) || not (BigNatModule.isZero y.V) | -1, 1 -> false - | _ -> invalidArg "x" "signs should be +/- 1" + | 0, 0 -> false + | 0, 1 -> false + | 0,-1 -> not (BigNatModule.isZero y.V) + | 1, 0 -> not (BigNatModule.isZero x.V) + | -1, 0 -> false + | _ -> invalidArg "x" "signs should be +/- 1 or 0" static member internal compare(n,nn) = if BigInteger.op_LessThan(n,nn) then -1 elif BigInteger.op_Equality(n,nn) then 0 else 1 - static member internal hash (z:BigInteger) = z.SignInt + BigNatModule.hash(z.V) + + static member internal hash (z:BigInteger) = + if z.SignInt = 0 then 1 // 1 is hashcode for initialized BigInteger.Zero + else z.SignInt + BigNatModule.hash(z.V) override x.ToString() = match x.SignInt with @@ -81,8 +106,9 @@ namespace System.Numerics | -1 -> if BigNatModule.isZero x.V then "0" // not negative infact, but zero. - else "-" + BigNatModule.toString x.V // negative - | _ -> invalidOp "signs should be +/- 1" + else "-" + BigNatModule.toString x.V // negative + | 0 -> "0" + | _ -> invalidOp "signs should be +/- 1 or 0" member x.StructuredDisplayString = x.ToString() @@ -99,7 +125,6 @@ namespace System.Numerics override x.GetHashCode() = BigInteger.hash(x) - new (n:int) = if n>=0 then BigInteger (1,BigInteger.nat(BigNatModule.ofInt32 n)) @@ -107,7 +132,6 @@ namespace System.Numerics then BigInteger(-1,BigInteger.nat(BigNatModule.ofInt64 (-(int64 n)))) else BigInteger(-1,BigInteger.nat(BigNatModule.ofInt32 (-n))) - new (n:int64) = if n>=0L then BigInteger(1,BigInteger.nat (BigNatModule.ofInt64 n)) @@ -116,9 +140,16 @@ namespace System.Numerics else BigInteger(-1,BigInteger.nat (BigNatModule.ofInt64 (-n))) static member One = one + static member Zero = zero - static member (~-) (z:BigInteger) = BigInteger.create(-1 * z.SignInt,z.V) - static member Scale(k,z:BigInteger) = + + static member (~-) (z:BigInteger) = + match z.SignInt with + | 0 -> BigInteger.Zero + | i -> BigInteger.create(-i, z.V) + + static member Scale(k, z:BigInteger) = + if z.SignInt = 0 then BigInteger.Zero else if k<0 then BigInteger.create(-z.SignInt, (BigNatModule.scale (-k) z.V)) // k.zsign.zv = -zsign.(-k.zv) else BigInteger.create(z.SignInt, (BigNatModule.scale k z.V)) // k.zsign.zv = zsign.k.zv @@ -132,8 +163,10 @@ namespace System.Numerics static member internal addnn (nx,ny) = BigInteger.posn (BigNatModule.add nx ny) // Compute "nx + ny" to be integer - member x.IsZero = BigNatModule.isZero x.V // signx.xv = 0 iff xv=0, since signx is +1,-1 + member x.IsZero = x.SignInt = 0 || BigNatModule.isZero x.V + member x.IsOne = (x.SignInt = 1) && BigNatModule.isOne x.V // signx.xv = 1 iff signx = +1 and xv = 1 + static member (+) (x:BigInteger,y:BigInteger) = if y.IsZero then x else if x.IsZero then y else @@ -146,6 +179,7 @@ namespace System.Numerics static member (-) (x:BigInteger,y:BigInteger) = if y.IsZero then x else + if x.IsZero then -y else match x.SignInt,y.SignInt with | 1, 1 -> BigInteger.subnn(x.V,y.V) // 1.xv - 1.yv = (xv - yv) | -1,-1 -> BigInteger.subnn(y.V,x.V) // -1.xv - -1.yv = (yv - xv) @@ -162,7 +196,12 @@ namespace System.Numerics let m = (BigNatModule.mul x.V y.V) BigInteger.create (x.SignInt * y.SignInt,m) // xsign.xv * ysign.yv = (xsign.ysign).(xv.yv) - static member DivRem (x:BigInteger,y:BigInteger,rem:BigInteger byref) = + static member DivRem (x:BigInteger, y:BigInteger, []rem:BigInteger byref) = + if y.IsZero then raise (new System.DivideByZeroException()) + if x.IsZero then + rem <- BigInteger.Zero + BigInteger.Zero + else let d,r = BigNatModule.divmod x.V y.V // HAVE: |x| = d.|y| + r and 0 <= r < |y| // HAVE: xv = d.yv + r and 0 <= r < yv @@ -176,13 +215,22 @@ namespace System.Numerics static member (/) (x:BigInteger,y:BigInteger) = let mutable rem = new BigInteger(0) BigInteger.DivRem(x,y,&rem) + static member (%) (x:BigInteger,y:BigInteger) = let mutable rem = new BigInteger(0) BigInteger.DivRem(x,y,&rem) |> ignore ; rem - static member GreatestCommonDivisor (x:BigInteger,y:BigInteger) = BigInteger.posn (BigNatModule.hcf x.V y.V) // hcf (xsign.xv,ysign.yv) = hcf (xv,yv) + + static member GreatestCommonDivisor (x:BigInteger,y:BigInteger) = + match x.SignInt,y.SignInt with + | 0, 0 -> BigInteger.Zero + | 0, _ -> BigInteger.posn y.V + | _, 0 -> BigInteger.posn x.V + | _ -> BigInteger.posn (BigNatModule.hcf x.V y.V) // hcf (xsign.xv,ysign.yv) = hcf (xv,yv) member x.IsNegative = x.SignInt = -1 && not (x.IsZero) // signx.xv < 0 iff signx = -1 and xv<>0 + member x.IsPositive = x.SignInt = 1 && not (x.IsZero) // signx.xv > 0 iff signx = +1 and xv<>0 + static member Abs (x:BigInteger) = if x.SignInt = -1 then -x else x static member op_LessThanOrEqual (x:BigInteger,y:BigInteger) = @@ -192,9 +240,14 @@ namespace System.Numerics | 1,-1 -> BigNatModule.isZero x.V && BigNatModule.isZero y.V // 1.xv <= -1.yv, // (a) if xv=0 and yv=0 then true // (b) otherwise false, only meet at zero. - + | -1, 1 -> true // -1.xv <= 1.yv, true - | _ -> invalidArg "x" "signs should be +/- 1" + | 0, 0 -> true + | 1, 0 -> BigNatModule.isZero x.V + | -1, 0 -> true + | 0, 1 -> true + | 0,-1 -> BigNatModule.isZero y.V + | _ -> invalidArg "x" "signs should be +/- 1 or 0" static member op_GreaterThanOrEqual (x:BigInteger,y:BigInteger) = // Follow lte by +/- symmetry match x.SignInt,y.SignInt with @@ -202,15 +255,24 @@ namespace System.Numerics | -1,-1 -> BigNatModule.gte y.V x.V | 1,-1 -> true | -1, 1 -> BigNatModule.isZero x.V && BigNatModule.isZero y.V - | _ -> invalidArg "x" "signs should be +/- 1" - + | 0, 0 -> true + | 1, 0 -> true + | -1, 0 -> BigNatModule.isZero x.V + | 0, 1 -> BigNatModule.isZero y.V + | 0,-1 -> true + | _ -> invalidArg "x" "signs should be +/- 1 or 0" static member Pow (x:BigInteger,y:int32) = - if y < 0 then invalidArg "y" (SR.GetString(SR.inputMustBeNonNegative)) - let yval = BigInteger(y) - BigInteger.create ((if BigNatModule.isZero (BigNatModule.rem yval.V BigNatModule.two) then 1 else x.SignInt), BigNatModule.pow x.V yval.V) + if y < 0 then raise (new System.ArgumentOutOfRangeException("y", (SR.GetString(SR.inputMustBeNonNegative)))) + match x.IsZero, y with + | true, 0 -> BigInteger.One + | true, _ -> BigInteger.Zero + | _ -> + let yval = BigInteger(y) + BigInteger.create ((if BigNatModule.isZero (BigNatModule.rem yval.V BigNatModule.two) then 1 else x.SignInt), BigNatModule.pow x.V yval.V) static member op_Explicit (x:BigInteger) = + if x.IsZero then 0 else let u = BigNatModule.toUInt32 x.V if u <= uint32 System.Int32.MaxValue then // Handle range [-MaxValue,MaxValue] @@ -222,7 +284,8 @@ namespace System.Numerics else raise (System.OverflowException()) - static member op_Explicit (x:BigInteger) = + static member op_Explicit (x:BigInteger) = + if x.IsZero then 0L else let u = BigNatModule.toUInt64 x.V if u <= uint64 System.Int64.MaxValue then (* Handle range [-MaxValue,MaxValue] *) @@ -238,17 +301,23 @@ namespace System.Numerics match x.SignInt with | 1 -> BigNatModule.toFloat x.V // float (1.xv) = float (xv) | -1 -> - (BigNatModule.toFloat x.V) // float (-1.xv) = - float (xv) - | _ -> invalidArg "x" "signs should be +/- 1" + | 0 -> 0. + | _ -> invalidArg "x" "signs should be +/- 1 or 0" static member Parse(text:string) = + if text = null then raise (new ArgumentNullException("text")) + let text = text.Trim() let len = text.Length - if len = 0 then raise (new System.FormatException("The value could not be parsed")) - if text.[0..0] = "-" then - BigInteger.negn (BigNatModule.ofString text.[1..len-1]) - else - BigInteger.posn (BigNatModule.ofString text) - - member internal x.IsSmall = BigNatModule.isSmall (x.V) + if len = 0 then raise (new System.FormatException(SR.GetString(SR.badFormatString))) + match text.[0], len with + | '-', 1 -> raise (new System.FormatException(SR.GetString(SR.badFormatString))) + | '-', _ -> BigInteger.negn (BigNatModule.ofString text.[1..len-1]) + | '+', 1 -> raise (new System.FormatException(SR.GetString(SR.badFormatString))) + | '+', _ -> BigInteger.posn (BigNatModule.ofString text.[1..len-1]) + | _ -> BigInteger.posn (BigNatModule.ofString text) + + member internal x.IsSmall = x.IsZero || BigNatModule.isSmall (x.V) + static member Factorial (x:BigInteger) = if x.IsNegative then invalidArg "x" (SR.GetString(SR.inputMustBeNonNegative)) if x.IsPositive then BigInteger.posn (BigNatModule.factorial x.V) @@ -257,6 +326,7 @@ namespace System.Numerics static member ( ~+ )(n1:BigInteger) = n1 static member FromInt64(x:int64) = new BigInteger(x) + static member FromInt32(x:int32) = new BigInteger(x) #endif diff --git a/src/fsharp/FSharp.Core/math/z.fsi b/src/fsharp/FSharp.Core/math/z.fsi index 0d2b4d7e20..a87c2b50f0 100755 --- a/src/fsharp/FSharp.Core/math/z.fsi +++ b/src/fsharp/FSharp.Core/math/z.fsi @@ -36,7 +36,7 @@ namespace System.Numerics /// Return the sign of a big integer: 0, +1 or -1 member Sign : int /// Compute the ratio and remainder of two big integers - static member DivRem : x:BigInteger * y:BigInteger * rem:BigInteger byref -> BigInteger + static member DivRem : x:BigInteger * y:BigInteger * []rem:BigInteger byref -> BigInteger /// This operator is for consistency when this type be used from other CLI languages static member op_LessThan : x:BigInteger * y:BigInteger -> bool diff --git a/src/fsharp/FSharp.Core/set.fs b/src/fsharp/FSharp.Core/set.fs index 814e307313..147f72c3eb 100755 --- a/src/fsharp/FSharp.Core/set.fs +++ b/src/fsharp/FSharp.Core/set.fs @@ -194,7 +194,7 @@ namespace Microsoft.FSharp.Collections let rec spliceOutSuccessor t = match t with - | SetEmpty -> failwith "internal error: Map.spliceOutSuccessor" + | SetEmpty -> failwith "internal error: Set.spliceOutSuccessor" | SetOne (k2) -> k2,SetEmpty | SetNode (k2,l,r,_) -> match l with diff --git a/src/fsharp/ast.fs b/src/fsharp/ast.fs index b83910f42c..739683525c 100644 --- a/src/fsharp/ast.fs +++ b/src/fsharp/ast.fs @@ -1728,31 +1728,17 @@ let mkSynApp5 f x1 x2 x3 x4 x5 m = mkSynApp1 (mkSynApp4 f x1 x2 x3 x4 m) x5 m let mkSynDotParenSet m a b c = mkSynTrifix m parenSet a b c let mkSynDotBrackGet m mDot a b = SynExpr.DotIndexedGet(a,[SynIndexerArg.One b],mDot,m) let mkSynQMarkSet m a b c = mkSynTrifix m qmarkSet a b c - let mkSynDotBrackSliceGet m mDot arr sliceArg = SynExpr.DotIndexedGet(arr,[sliceArg],mDot,m) -let mkSlice m mDot arr sliceArgs = - //let args = [ for arg in sliceArgs do - // match arg with - // | SynIndexerArg.Range (x1,x2) -> yield x1; yield x2 - // | SynIndexerArg.One x -> yield x ] - SynExpr.DotIndexedGet(arr,sliceArgs,mDot,m) - -let mkSynDotBrackSlice2Get m mDot arr sliceArg1 sliceArg2 = - match sliceArg1, sliceArg2 with - | SynIndexerArg.One x1, SynIndexerArg.One x2 -> mkSynDotBrackGet m mDot arr (SynExpr.Tuple([x1;x2],[],unionRanges x1.Range x2.Range)) - | _ -> mkSlice m mDot arr [ sliceArg1; sliceArg2 ] - -let mkSynDotBrackSlice3Get m mDot arr sliceArg1 sliceArg2 sliceArg3 = - match sliceArg1, sliceArg2, sliceArg3 with - | SynIndexerArg.One x1, SynIndexerArg.One x2, SynIndexerArg.One x3 -> mkSynDotBrackGet m mDot arr (SynExpr.Tuple([x1;x2;x3],[],unionRanges x1.Range x3.Range)) - | _ -> mkSlice m mDot arr [ sliceArg1; sliceArg2; sliceArg3 ] - -let mkSynDotBrackSlice4Get m mDot arr sliceArg1 sliceArg2 sliceArg3 sliceArg4 = - match sliceArg1, sliceArg2, sliceArg3, sliceArg4 with - | SynIndexerArg.One x1, SynIndexerArg.One x2, SynIndexerArg.One x3, SynIndexerArg.One x4 -> mkSynDotBrackGet m mDot arr (SynExpr.Tuple([x1;x2;x3;x4],[],unionRanges x1.Range x4.Range)) - | _ -> mkSlice m mDot arr [ sliceArg1; sliceArg2; sliceArg3; sliceArg4 ] - +let mkSynDotBrackSeqSliceGet m mDot arr (argslist:list) = + let notsliced=[ for arg in argslist do + match arg with + | SynIndexerArg.One x -> yield x + | _ -> () ] + if notsliced.Length = argslist.Length then + SynExpr.DotIndexedGet(arr,[SynIndexerArg.One (SynExpr.Tuple(notsliced,[],unionRanges (Seq.head notsliced).Range (Seq.last notsliced).Range))],mDot,m) + else + SynExpr.DotIndexedGet(arr,argslist,mDot,m) let mkSynDotParenGet lhsm dotm a b = match b with diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index 4f94a2f259..265a1cd5e9 100755 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -1013,12 +1013,12 @@ module AttributeHelpers = | _ -> None // Try to find an AssemblyVersion attribute - let TryFindVersionAttribute tcGlobals attrib attribs = + let TryFindVersionAttribute tcGlobals attrib attribName attribs = match TryFindStringAttribute tcGlobals attrib attribs with | Some versionString -> try Some(IL.parseILVersion versionString) with e -> - warning(Error(FSComp.SR.fscBadAssemblyVersion(versionString),Range.rangeStartup)); + warning(Error(FSComp.SR.fscBadAssemblyVersion(attribName, versionString),Range.rangeStartup)); None | _ -> None @@ -1206,12 +1206,12 @@ module MainModuleBuilder = | _ -> [] let fileVersion = - match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyFileVersionAttribute" topAttrs.assemblyAttrs with + match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyFileVersionAttribute" "AssemblyFileVersionAttribute" topAttrs.assemblyAttrs with | Some v -> v | None -> assemblyVersion let productVersion = - match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyInformationalVersionAttribute" topAttrs.assemblyAttrs with + match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyInformationalVersionAttribute" "AssemblyInformationalVersionAttribute" topAttrs.assemblyAttrs with | Some v -> v | None -> assemblyVersion @@ -1985,7 +1985,7 @@ let main1(tcGlobals,tcImports : TcImports,frameworkTcImports,generatedCcu,typedA // Try to find an AssemblyVersion attribute let assemVerFromAttrib = - match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyVersionAttribute" topAttrs.assemblyAttrs with + match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyVersionAttribute" "AssemblyVersionAttribute" topAttrs.assemblyAttrs with | Some v -> match tcConfig.version with | VersionNone -> Some v @@ -2187,6 +2187,7 @@ let typecheckAndCompile(argv,bannerAlreadyPrinted,exiter:Exiter, errorLoggerProv |> main4 let mainCompile (argv,bannerAlreadyPrinted,exiter:Exiter) = + System.Runtime.GCSettings.LatencyMode <- System.Runtime.GCLatencyMode.Batch typecheckAndCompile(argv, bannerAlreadyPrinted, exiter, DefaultLoggerProvider()) type CompilationOutput = diff --git a/src/fsharp/opt.fs b/src/fsharp/opt.fs index 339ffa86d8..96342bcbf2 100755 --- a/src/fsharp/opt.fs +++ b/src/fsharp/opt.fs @@ -36,29 +36,24 @@ open Microsoft.FSharp.Compiler.Infos open System.Collections.Generic - - -let verboseOptimizationInfo = #if BUILDING_PROTO +let verboseOptimizationInfo = try not (System.String.IsNullOrEmpty (System.Environment.GetEnvironmentVariable "FSHARP_verboseOptimizationInfo")) with _ -> false -#else - false -#endif let verboseOptimizations = -#if BUILDING_PROTO try not (System.String.IsNullOrEmpty (System.Environment.GetEnvironmentVariable "FSHARP_verboseOptimizations")) with _ -> false #else - false +let [] verboseOptimizationInfo = false +let [] verboseOptimizations = false #endif let i_ldlen = [ I_ldlen; (AI_conv DT_I4) ] -let callSize = 1 // size of a function call -let forAndWhileLoopSize = 5 // size of a for/while loop -let tryCatchSize = 5 // size of a try/catch -let tryFinallySize = 5 // size of a try/finally -let closureTotalSize = 10 // Total cost of a closure. Each closure adds a class definition -let methodDefnTotalSize = 1 // Total cost of a method definition +let [] callSize = 1 // size of a function call +let [] forAndWhileLoopSize = 5 // size of a for/while loop +let [] tryCatchSize = 5 // size of a try/catch +let [] tryFinallySize = 5 // size of a try/finally +let [] closureTotalSize = 10 // Total cost of a closure. Each closure adds a class definition +let [] methodDefnTotalSize = 1 // Total cost of a method definition //------------------------------------------------------------------------- // Partial information about an expression. @@ -244,9 +239,9 @@ let BoundValueInfoBySize vinfo = // What we know about the world //------------------------------------------------------------------------- -let jitOptDefault = true -let localOptDefault = true -let crossModuleOptDefault = true +let [] jitOptDefault = true +let [] localOptDefault = true +let [] crossModuleOptDefault = true type OptimizationSettings = { abstractBigTargets : bool; @@ -933,7 +928,7 @@ let mkAssemblyCodeValueInfo g instrs argvals tys = // Size constants and combinators //------------------------------------------------------------------------- -let localVarSize = 1 +let [] localVarSize = 1 let rec AddTotalSizesAux acc l = match l with [] -> acc | h::t -> AddTotalSizesAux (h.TotalSize + acc) t let AddTotalSizes l = AddTotalSizesAux 0 l @@ -1209,7 +1204,7 @@ let AbstractAndRemapModulInfo msg g m (repackage,hidden) info = //------------------------------------------------------------------------- // Mark some variables (the ones we introduce via abstractBigTargets) as don't-eliminate -let suffixForVariablesThatMayNotBeEliminated = "$cont" +let [] suffixForVariablesThatMayNotBeEliminated = "$cont" /// Type applications of F# "type functions" may cause side effects, e.g. /// let x<'a> = printfn "hello"; typeof<'a> diff --git a/src/fsharp/pars.fsy b/src/fsharp/pars.fsy index 35324dfe3c..0ffdee03ba 100755 --- a/src/fsharp/pars.fsy +++ b/src/fsharp/pars.fsy @@ -2907,7 +2907,7 @@ typedSeqExpr: | seqExpr { $1 } seqExpr: - | declExpr seps seqExpr + | declExpr seps seqExpr { SynExpr.Sequential(SequencePointsAtSeq,true,$1,$3,unionRanges $1.Range $3.Range) } | declExpr seps { $1 } @@ -3573,21 +3573,19 @@ atomicExprQualification: mlCompatWarning (FSComp.SR.parsParenFormIsForML()) (lhs parseState); mkSynDotParenGet lhsm dotm e $2) } - | LBRACK typedSeqExpr RBRACK + | LBRACK typedSeqExpr RBRACK { (fun e lhsm dotm -> mkSynDotBrackGet lhsm dotm e $2) } - + | LBRACK typedSeqExpr recover { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedBracket()); (fun e lhsm dotm -> exprFromParseError (mkSynDotBrackGet lhsm dotm e $2)) } - | LBRACK optRange RBRACK - { (fun e lhsm dotm -> mkSynDotBrackSliceGet lhsm dotm e $2) } - | LBRACK optRange COMMA optRange RBRACK %prec slice_comma - { (fun e lhsm dotm -> mkSynDotBrackSlice2Get lhsm dotm e $2 $4) } - | LBRACK optRange COMMA optRange COMMA optRange RBRACK %prec slice_comma - { (fun e lhsm dotm -> mkSynDotBrackSlice3Get lhsm dotm e $2 $4 $6) } - | LBRACK optRange COMMA optRange COMMA optRange COMMA optRange RBRACK %prec slice_comma - { (fun e lhsm dotm -> mkSynDotBrackSlice4Get lhsm dotm e $2 $4 $6 $8) } + | LBRACK optRangeSeqExpr RBRACK + { (fun e lhsm dotm -> mkSynDotBrackSeqSliceGet lhsm dotm e $2) } + + | LBRACK optRangeSeqExpr recover + { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedBracket()); + (fun e lhsm dotm -> exprFromParseError (mkSynDotBrackSeqSliceGet lhsm dotm e $2)) } | LBRACK error RBRACK { let mArg = rhs2 parseState 1 3 @@ -3598,6 +3596,9 @@ atomicExprQualification: let mArg = (rhs parseState 1).EndRange (fun e lhsm dotm -> exprFromParseError (mkSynDotBrackGet lhsm dotm e (arbExpr("indexerExpr2",mArg)))) } +optRangeSeqExpr: + | optRange COMMA optRangeSeqExpr %prec slice_comma { $1::$3 } + | optRange { [$1] } optRange: | declExpr DOT_DOT declExpr @@ -3610,7 +3611,6 @@ optRange: { SynIndexerArg.Two(mkSynOptionalExpr (rhs parseState 1) None, mkSynOptionalExpr (rhs parseState 1) None) } | declExpr %prec slice_expr { SynIndexerArg.One($1) } - /* the start et of atomicExprAfterType must not overlap with the valid postfix tokens of the type syntax, e.g. new List(...) */ atomicExprAfterType: @@ -4859,4 +4859,4 @@ ends_coming_soon_or_recover: | RBRACE_COMING_SOON { false } | RPAREN_COMING_SOON { false } | OBLOCKEND_COMING_SOON { false } - | recover { $1 } \ No newline at end of file + | recover { $1 } diff --git a/src/fsharp/pickle.fs b/src/fsharp/pickle.fs index 96ba01cb9d..c80d4aab63 100755 --- a/src/fsharp/pickle.fs +++ b/src/fsharp/pickle.fs @@ -1001,69 +1001,69 @@ let u_ILBasicType st = let u_ILVolatility st = (match u_int st with 0 -> Volatile | 1 -> Nonvolatile | _ -> ufailwith st "u_ILVolatility" ) let u_ILReadonly st = (match u_int st with 0 -> ReadonlyAddress | 1 -> NormalAddress | _ -> ufailwith st "u_ILReadonly" ) -let itag_nop = 0 -let itag_ldarg = 1 -let itag_ldnull = 2 -let itag_ilzero = 3 -let itag_call = 4 -let itag_add = 5 -let itag_sub = 6 -let itag_mul = 7 -let itag_div = 8 -let itag_div_un = 9 -let itag_rem = 10 -let itag_rem_un = 11 -let itag_and = 12 -let itag_or = 13 -let itag_xor = 14 -let itag_shl = 15 -let itag_shr = 16 -let itag_shr_un = 17 -let itag_neg = 18 -let itag_not = 19 -let itag_conv = 20 -let itag_conv_un = 21 -let itag_conv_ovf = 22 -let itag_conv_ovf_un = 23 -let itag_callvirt = 24 -let itag_ldobj = 25 -let itag_ldstr = 26 -let itag_castclass = 27 -let itag_isinst = 28 -let itag_unbox = 29 -let itag_throw = 30 -let itag_ldfld = 31 -let itag_ldflda = 32 -let itag_stfld = 33 -let itag_ldsfld = 34 -let itag_ldsflda = 35 -let itag_stsfld = 36 -let itag_stobj = 37 -let itag_box = 38 -let itag_newarr = 39 -let itag_ldlen = 40 -let itag_ldelema = 41 -let itag_ckfinite = 42 -let itag_ldtoken = 43 -let itag_add_ovf = 44 -let itag_add_ovf_un = 45 -let itag_mul_ovf = 46 -let itag_mul_ovf_un = 47 -let itag_sub_ovf = 48 -let itag_sub_ovf_un = 49 -let itag_ceq = 50 -let itag_cgt = 51 -let itag_cgt_un = 52 -let itag_clt = 53 -let itag_clt_un = 54 -let itag_ldvirtftn = 55 -let itag_localloc = 56 -let itag_rethrow = 57 -let itag_sizeof = 58 -let itag_ldelem_any = 59 -let itag_stelem_any = 60 -let itag_unbox_any = 61 -let itag_ldlen_multi = 62 +let [] itag_nop = 0 +let [] itag_ldarg = 1 +let [] itag_ldnull = 2 +let [] itag_ilzero = 3 +let [] itag_call = 4 +let [] itag_add = 5 +let [] itag_sub = 6 +let [] itag_mul = 7 +let [] itag_div = 8 +let [] itag_div_un = 9 +let [] itag_rem = 10 +let [] itag_rem_un = 11 +let [] itag_and = 12 +let [] itag_or = 13 +let [] itag_xor = 14 +let [] itag_shl = 15 +let [] itag_shr = 16 +let [] itag_shr_un = 17 +let [] itag_neg = 18 +let [] itag_not = 19 +let [] itag_conv = 20 +let [] itag_conv_un = 21 +let [] itag_conv_ovf = 22 +let [] itag_conv_ovf_un = 23 +let [] itag_callvirt = 24 +let [] itag_ldobj = 25 +let [] itag_ldstr = 26 +let [] itag_castclass = 27 +let [] itag_isinst = 28 +let [] itag_unbox = 29 +let [] itag_throw = 30 +let [] itag_ldfld = 31 +let [] itag_ldflda = 32 +let [] itag_stfld = 33 +let [] itag_ldsfld = 34 +let [] itag_ldsflda = 35 +let [] itag_stsfld = 36 +let [] itag_stobj = 37 +let [] itag_box = 38 +let [] itag_newarr = 39 +let [] itag_ldlen = 40 +let [] itag_ldelema = 41 +let [] itag_ckfinite = 42 +let [] itag_ldtoken = 43 +let [] itag_add_ovf = 44 +let [] itag_add_ovf_un = 45 +let [] itag_mul_ovf = 46 +let [] itag_mul_ovf_un = 47 +let [] itag_sub_ovf = 48 +let [] itag_sub_ovf_un = 49 +let [] itag_ceq = 50 +let [] itag_cgt = 51 +let [] itag_cgt_un = 52 +let [] itag_clt = 53 +let [] itag_clt_un = 54 +let [] itag_ldvirtftn = 55 +let [] itag_localloc = 56 +let [] itag_rethrow = 57 +let [] itag_sizeof = 58 +let [] itag_ldelem_any = 59 +let [] itag_stelem_any = 60 +let [] itag_unbox_any = 61 +let [] itag_ldlen_multi = 62 let simple_instrs = [ itag_add, AI_add; diff --git a/tests/config.bat b/tests/config.bat index 82117ac086..f736229faf 100644 --- a/tests/config.bat +++ b/tests/config.bat @@ -293,8 +293,8 @@ set FSCOREDLLPATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETF set FSCOREDLL20PATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETFramework\v2.0\2.3.0.0 set FSCOREDLLPORTABLEPATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETPortable\2.3.5.1 set FSCOREDLLNETCOREPATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETCore\3.3.1.0 -set FSCOREDLLNETCORE78PATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETCore\3.4.78.310 -set FSCOREDLLNETCORE259PATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETCore\3.4.259.310 +set FSCOREDLLNETCORE78PATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETCore\3.78.3.1 +set FSCOREDLLNETCORE259PATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETCore\3.259.3.1 set FSDATATPPATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.0.0\Type Providers REM == Check if using open build instead diff --git a/tests/fsharp/core/array/test.fsx b/tests/fsharp/core/array/test.fsx index 8fe0a43fbd..2816ad9378 100644 --- a/tests/fsharp/core/array/test.fsx +++ b/tests/fsharp/core/array/test.fsx @@ -1340,6 +1340,39 @@ module bug872632 = do check "bug872632" Foo.x.Length 8 +module manyIndexes = + open System + + // Bug in F# 3.1: Indexer Properties was incorrectly limited to 4 arguments. There were no limits in previous versions of F#, and shouldn't be in future versions + // Repro code for bug in F# 3.1. This compiles perfectly in F# 3.0 + + // ---------------------------------------------------------------------------- + type Test () = + /// Variable number of arguments with indexer property + member x.Item with get ([] objs: obj[]) = objs + + /// PASS: Variable number of arguments with member function + member x.Foo ([] objs: obj[]) = objs + + // ---------------------------------------------------------------------------- + let CompileIndexerTest = + let test = Test () + + // No problems with method having vaiable number of parameters + let u1 = test.Foo(null, null, null, null) + let u2 = test.Foo(null, null, null, null, null) + let u3 = test.Foo(null, null, null, null, null, null, null, null, null) + + // Bug was that the indexer Property was limited to 4 parameters (Issue introduced by matrix slicing code) + let u4 = test.[null] + let u5 = test.[null, null] + let u6 = test.[null, null, null] + let u7 = test.[null, null, null, null] + let u8 = test.[null, null, null, null, null] // Ensure that F# 3.1 is not unhappy with more than 4 arguments + let u9 = test.[null, null, null, null, null, null, null, null, null, null, null, null, null] // Ensure that F# 3.1 is not unhappy with many more than 4 arguments, 13 arguments would be really unlucky + 0 + + #if Portable #else // this overload of CreateInstance doesn't exist in portable module bug6447 = diff --git a/tests/fsharp/core/netcore/netcore259/build.bat b/tests/fsharp/core/netcore/netcore259/build.bat index 46c756313f..fef71f3e28 100644 --- a/tests/fsharp/core/netcore/netcore259/build.bat +++ b/tests/fsharp/core/netcore/netcore259/build.bat @@ -6,5 +6,5 @@ IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" ( exit /b 0 ) -"%MSBUILDTOOLSPATH%\msbuild.exe" ..\netcore.sln /p:Configuration=Debug +"%MSBUILDTOOLSPATH%\msbuild.exe" ..\netcore.sln /p:Configuration=Debug /p:TestProfile=Profile259 /t:Rebuild exit /b %ERRORLEVEL% \ No newline at end of file diff --git a/tests/fsharp/core/netcore/netcore259/run.bat b/tests/fsharp/core/netcore/netcore259/run.bat index 734ce70a3a..eebda71860 100644 --- a/tests/fsharp/core/netcore/netcore259/run.bat +++ b/tests/fsharp/core/netcore/netcore259/run.bat @@ -9,9 +9,9 @@ IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" ( exit /b 0 ) -set CONTROL_FAILURES_LOG=%~dp0\control_failures.log +set CONTROL_FAILURES_LOG=%~dp0..\ConsoleApplication1\bin\Debug\Profile259\control_failures.log -..\ConsoleApplication1\bin\Debug\profile359\PortableTestEntry.exe +..\ConsoleApplication1\bin\Debug\Profile259\PortableTestEntry.exe endlocal exit /b %ERRORLEVEL% diff --git a/tests/fsharp/core/netcore/netcore7/build.bat b/tests/fsharp/core/netcore/netcore7/build.bat index 46c756313f..b3a27a8b63 100644 --- a/tests/fsharp/core/netcore/netcore7/build.bat +++ b/tests/fsharp/core/netcore/netcore7/build.bat @@ -6,5 +6,5 @@ IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" ( exit /b 0 ) -"%MSBUILDTOOLSPATH%\msbuild.exe" ..\netcore.sln /p:Configuration=Debug +"%MSBUILDTOOLSPATH%\msbuild.exe" ..\netcore.sln /p:Configuration=Debug /p:TestProfile=Profile7 /t:Rebuild exit /b %ERRORLEVEL% \ No newline at end of file diff --git a/tests/fsharp/core/netcore/netcore7/run.bat b/tests/fsharp/core/netcore/netcore7/run.bat index fe9f64b828..0bf95bd616 100644 --- a/tests/fsharp/core/netcore/netcore7/run.bat +++ b/tests/fsharp/core/netcore/netcore7/run.bat @@ -5,7 +5,12 @@ setlocal call %~d0%~p0..\..\..\..\config.bat -set CONTROL_FAILURES_LOG=%~dp0\control_failures.log +IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" ( + echo Test not supported except on Ultimate + exit /b 0 +) + +set CONTROL_FAILURES_LOG=%~dp0..\ConsoleApplication1\bin\Debug\profile7\control_failures.log ..\ConsoleApplication1\bin\Debug\profile7\PortableTestEntry.exe endlocal diff --git a/tests/fsharp/core/netcore/netcore78/build.bat b/tests/fsharp/core/netcore/netcore78/build.bat index 46c756313f..33252b6fc1 100644 --- a/tests/fsharp/core/netcore/netcore78/build.bat +++ b/tests/fsharp/core/netcore/netcore78/build.bat @@ -6,5 +6,5 @@ IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" ( exit /b 0 ) -"%MSBUILDTOOLSPATH%\msbuild.exe" ..\netcore.sln /p:Configuration=Debug +"%MSBUILDTOOLSPATH%\msbuild.exe" ..\netcore.sln /p:Configuration=Debug /p:TestProfile=Profile78 /t:Rebuild exit /b %ERRORLEVEL% \ No newline at end of file diff --git a/tests/fsharp/core/netcore/netcore78/run.bat b/tests/fsharp/core/netcore/netcore78/run.bat index caf7c732b7..febb05de72 100644 --- a/tests/fsharp/core/netcore/netcore78/run.bat +++ b/tests/fsharp/core/netcore/netcore78/run.bat @@ -9,7 +9,7 @@ IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" ( exit /b 0 ) -set CONTROL_FAILURES_LOG=%~dp0\control_failures.log +set CONTROL_FAILURES_LOG=%~dp0..\ConsoleApplication1\bin\Debug\profile78\control_failures.log ..\ConsoleApplication1\bin\Debug\profile78\PortableTestEntry.exe endlocal diff --git a/tests/fsharp/core/netcore/netcoreautomationhelperlibrary/netcoreautomationhelperlibrary.fsproj b/tests/fsharp/core/netcore/netcoreautomationhelperlibrary/netcoreautomationhelperlibrary.fsproj index 1ce3c7b574..31ad3f9d26 100644 --- a/tests/fsharp/core/netcore/netcoreautomationhelperlibrary/netcoreautomationhelperlibrary.fsproj +++ b/tests/fsharp/core/netcore/netcoreautomationhelperlibrary/netcoreautomationhelperlibrary.fsproj @@ -17,19 +17,19 @@ SAK SAK - + Profile7 3.3.1.0 $(FSCOREDLLNETCOREPATH) Profile78 - 3.4.78.310 + 3.78.3.1 $(FSCOREDLLNETCORE78PATH) Profile259 - 3.4.259.310 + 3.259.3.1 $(FSCOREDLLNETCORE259PATH)