diff --git a/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs b/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs index d6aad41fe5d..e16dacc71f6 100644 --- a/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs +++ b/src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Utilities.fs @@ -126,12 +126,12 @@ module internal Utilities = | value when not (String.IsNullOrEmpty(value)) -> Some value // Value set externally | _ -> - // Probe for netsdk install + // Probe for netsdk install, dotnet. and dotnet.exe is a constant offset from the location of System.Int32 let dotnetLocation = let dotnetApp = let platform = Environment.OSVersion.Platform if platform = PlatformID.Unix then "dotnet" else "dotnet.exe" - let assemblyLocation = typeof.GetTypeInfo().Assembly.Location + let assemblyLocation = typeof.GetTypeInfo().Assembly.Location Path.Combine(assemblyLocation, "../../..", dotnetApp) if File.Exists(dotnetLocation) then diff --git a/tests/fsharp/Compiler/Libraries/Core/Reflection/PreComputedTupleConstructorTests.fs b/tests/fsharp/Compiler/Libraries/Core/Reflection/PreComputedTupleConstructorTests.fs new file mode 100644 index 00000000000..cd24ea20106 --- /dev/null +++ b/tests/fsharp/Compiler/Libraries/Core/Reflection/PreComputedTupleConstructorTests.fs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework + +[] +module ``PreComputedTupleConstructor Tests`` = + + [] + let ``PreComputedTupleConstructor of int and string``() = + // Regression test for FSHARP1.0:5113 + // MT DCR: Reflection.FSharpValue.PreComputeTupleConstructor fails when executed for NetFx 2.0 by a Dev10 compiler + + let testDelegate = TestDelegate (fun () -> + Reflection.FSharpValue.PreComputeTupleConstructor(typeof) [| box 12; box "text" |] |> ignore) + + Assert.DoesNotThrow testDelegate |> ignore + + [] + let ``PreComputedTupleConstructor with wrong order of arguments``() = + // Regression test for FSHARP1.0:5113 + // MT DCR: Reflection.FSharpValue.PreComputeTupleConstructor fails when executed for NetFx 2.0 by a Dev10 compiler + + let testDelegate = TestDelegate (fun () -> + Reflection.FSharpValue.PreComputeTupleConstructor(typeof) [| box "text"; box 12; |] |> ignore) + + Assert.Throws testDelegate |> ignore \ No newline at end of file diff --git a/tests/fsharp/Compiler/Libraries/Core/Reflection/SprintfTests.fs b/tests/fsharp/Compiler/Libraries/Core/Reflection/SprintfTests.fs new file mode 100644 index 00000000000..67ea1baa1bb --- /dev/null +++ b/tests/fsharp/Compiler/Libraries/Core/Reflection/SprintfTests.fs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework + +[] +module ``Sprintf Tests`` = + + type MyR = {c:int;b:int;a:int} + + [] + let ``Sprintf %A of record type``() = + // Regression test for FSHARP1.0:5113 + + let s1 = sprintf "%A" {a=1;b=2;c=3} + let s2 = sprintf "%A" {c=3;b=2;a=1} + + Assert.areEqual s1 s2 + + type MyT = MyC of int * string * bool + + [] + let ``Sprintf %A of discriminated union type``() = + // Regression test for FSHARP1.0:5113 + + let DU = MyC (1,"2",true) + Assert.areEqual "MyC (1, \"2\", true)" (sprintf "%A" DU) \ No newline at end of file diff --git a/tests/fsharp/Compiler/Libraries/Core/Unchecked/DefaultOfTests.fs b/tests/fsharp/Compiler/Libraries/Core/Unchecked/DefaultOfTests.fs new file mode 100644 index 00000000000..7c732e479ad --- /dev/null +++ b/tests/fsharp/Compiler/Libraries/Core/Unchecked/DefaultOfTests.fs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework + +[] +module ``DefaultOf Tests`` = + + type DUType = + | A + | B of int + | C of DUType * DUType + + type RecordType = { A : int; B : string; C : DUType } + + type ClassType = string + + type InterfaceType = + abstract DoStuff : unit -> unit + + type EnumType = + | A = 1 + | B = 2 + | C = 4 + + type StructType = struct + val m_ivalue : int + val m_svalue : string + member this.IValue = this.m_ivalue + member this.SValue = this.m_svalue + end + + [] + let `` Unchecked defaultof reference types``() = + Assert.areEqual Unchecked.defaultof null + Assert.areEqual (box Unchecked.defaultof) null + Assert.areEqual (box Unchecked.defaultof) null + Assert.areEqual (box Unchecked.defaultof) null + + [] + let ``Unchecked defaultof stack types``() = + Assert.areEqual Unchecked.defaultof 0 + Assert.areEqual Unchecked.defaultof 0.0 + Assert.areEqual Unchecked.defaultof (enum 0) + Assert.areEqual Unchecked.defaultof.IValue 0 + Assert.areEqual Unchecked.defaultof.SValue null + + type R = { x : int; y : string } + type U = | A of int | B of string + type S = struct val mutable x : int end + type C() = class end + + [] + let ``Unchecked defaultof and equality``() = + // FSharp1.0:5417 - Unchecked.defaultof<_> on records/unions can cause structural equality check to throw + // Check that Unchecked.defaultof<_> works correctly on various types, mostly structs/unions/records + + Assert.areEqual Unchecked.defaultof Unchecked.defaultof + Assert.areEqual Unchecked.defaultof Unchecked.defaultof + Assert.areEqual Unchecked.defaultof Unchecked.defaultof + Assert.areEqual Unchecked.defaultof Unchecked.defaultof + Assert.areEqual Unchecked.defaultof Unchecked.defaultof \ No newline at end of file diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index b06425e88dc..a9d05e1fb76 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -75,6 +75,9 @@ + + + diff --git a/tests/fsharpqa/Source/Libraries/Core/Reflection/DU.fs b/tests/fsharpqa/Source/Libraries/Core/Reflection/DU.fs deleted file mode 100644 index 74f709d760e..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/Reflection/DU.fs +++ /dev/null @@ -1,10 +0,0 @@ -// #Regression #Libraries #Reflection -// Regression test for FSHARP1.0:5113 - -type MyT = MyC of int * string * bool - -let DU = MyC (1,"2",true) - -printfn "%A" DU - -(if (sprintf "%A" DU) = "MyC (1, \"2\", true)" then 0 else 1) |> exit diff --git a/tests/fsharpqa/Source/Libraries/Core/Reflection/PreComputeTupleConstructor01.fs b/tests/fsharpqa/Source/Libraries/Core/Reflection/PreComputeTupleConstructor01.fs deleted file mode 100644 index 0b179241cec..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/Reflection/PreComputeTupleConstructor01.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Regression #Libraries #Reflection -// Regression test for FSHARP1.0:5113 -// MT DCR: Reflection.FSharpValue.PreComputeTupleConstructor fails when executed for NetFx 2.0 by a Dev10 compiler - -let test1 = try - Reflection.FSharpValue.PreComputeTupleConstructor(typeof) [| box 12; box "text" |] |> ignore - true - with - | _ -> false - - -(if test1 then 0 else 1) |> exit diff --git a/tests/fsharpqa/Source/Libraries/Core/Reflection/PreComputeTupleConstructor02.fs b/tests/fsharpqa/Source/Libraries/Core/Reflection/PreComputeTupleConstructor02.fs deleted file mode 100644 index 50b1d7bad63..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/Reflection/PreComputeTupleConstructor02.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Regression #Libraries #Reflection -// Regression test for FSHARP1.0:5113 -// MT DCR: Reflection.FSharpValue.PreComputeTupleConstructor fails when executed for NetFx 2.0 by a Dev10 compiler - -let test1 = try - Reflection.FSharpValue.PreComputeTupleConstructor(typeof) [| box "text"; box 12; |] |> ignore - false - with - | _ -> true // yes, we expect the call above to throw since the types are swapped! - - -(if test1 then 0 else 1) |> exit diff --git a/tests/fsharpqa/Source/Libraries/Core/Reflection/Record.fs b/tests/fsharpqa/Source/Libraries/Core/Reflection/Record.fs deleted file mode 100644 index 8c780033a77..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/Reflection/Record.fs +++ /dev/null @@ -1,10 +0,0 @@ -// #Regression #Libraries #Reflection -// Regression test for FSHARP1.0:5113 - -type MyR = {c:int;b:int;a:int} - -let s1 = sprintf "%A" {a=1;b=2;c=3} -let s2 = sprintf "%A" {c=3;b=2;a=1} - -(if s1 = s2 then 0 else 1) |> exit - diff --git a/tests/fsharpqa/Source/Libraries/Core/Reflection/env.lst b/tests/fsharpqa/Source/Libraries/Core/Reflection/env.lst deleted file mode 100644 index bf3361d68e3..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/Reflection/env.lst +++ /dev/null @@ -1,4 +0,0 @@ - SOURCE=DU.fs # DU.fs - SOURCE=PreComputeTupleConstructor01.fs # PreComputeTupleConstructor01.fs - SOURCE=PreComputeTupleConstructor02.fs # PreComputeTupleConstructor02.fs - SOURCE=Record.fs # Record.fs diff --git a/tests/fsharpqa/Source/Libraries/Core/Unchecked/DefaultOf01.fs b/tests/fsharpqa/Source/Libraries/Core/Unchecked/DefaultOf01.fs deleted file mode 100644 index 196448fc4bf..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/Unchecked/DefaultOf01.fs +++ /dev/null @@ -1,51 +0,0 @@ -// #Regression #Libraries #Unchecked -#light - -// 1760, Implement Unchecked.defaultof<_> (delete LanguagePrimitives.DefaultValueUnchecked) - -// Test the 'defaultof<_>' function - -// Reference types --------------------------- -type DUType = - | A - | B of int - | C of DUType * DUType - -type RecordType = { A : int; B : string; C : DUType } - -type ClassType = string - -type InterfaceType = - abstract DoStuff : unit -> unit - -// Stack types ------------------------------- -type EnumType = - | A = 1 - | B = 2 - | C = 4 - -type StructType = struct - val m_ivalue : int - val m_svalue : string - member this.IValue = this.m_ivalue - member this.SValue = this.m_svalue -end - -// Test reference types -if Unchecked.defaultof <> null then exit 1 -// This behaivor for DU, Records, and Interfaces is bey design (need to box to get null) -if box(Unchecked.defaultof) <> null then exit 1 -if box(Unchecked.defaultof) <> null then exit 1 -if box(Unchecked.defaultof) <> null then exit 1 - -let p = Unchecked.defaultof - -// Test stack types -if Unchecked.defaultof <> 0 then exit 1 -if Unchecked.defaultof <> 0.0 then exit 1 -if Unchecked.defaultof <> enum 0 then exit 1 - -if (Unchecked.defaultof).IValue <> 0 then exit 1 -if (Unchecked.defaultof).SValue <> null then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Libraries/Core/Unchecked/DefaultOf02.fs b/tests/fsharpqa/Source/Libraries/Core/Unchecked/DefaultOf02.fs deleted file mode 100644 index 00414dd8cc8..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/Unchecked/DefaultOf02.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Regression #Libraries #Unchecked -#light - -// FSharp1.0:5417 - Unchecked.defaultof<_> on records/unions can cause structural equality check to throw -// Check that Unchecked.defaultof<_> works correctly on various types, mostly structs/unions/records - -type R = { x : int; y : string } -type U = | A of int | B of string -type S = struct val mutable x : int end -type C() = class end - -let shouldBeTrue = - Unchecked.defaultof = Unchecked.defaultof // Records as null - && Unchecked.defaultof = Unchecked.defaultof // Unions as null - && Unchecked.defaultof = Unchecked.defaultof // Structs as null - && Unchecked.defaultof = Unchecked.defaultof // Classes as null - && Unchecked.defaultof = Unchecked.defaultof diff --git a/tests/fsharpqa/Source/Libraries/Core/Unchecked/env.lst b/tests/fsharpqa/Source/Libraries/Core/Unchecked/env.lst deleted file mode 100644 index b5cefff3c2e..00000000000 --- a/tests/fsharpqa/Source/Libraries/Core/Unchecked/env.lst +++ /dev/null @@ -1,2 +0,0 @@ - SOURCE=DefaultOf01.fs # DefaultOf01 - SOURCE=DefaultOf02.fs # DefaultOf02 \ No newline at end of file