Skip to content

Commit

Permalink
Merge master to feature/tasks (#9614)
Browse files Browse the repository at this point in the history
* Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576)

* Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (#9611)

* Migrated PreComputedTupleConstructor01.fs test case

* Migrated PreComputedTupleConstructor02.fs test case

* Migrated DU.fs and Record.fs test cases

* Allow notebook to discover location of shared framework (#9596)

Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com>
Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
Co-authored-by: Phillip Carter <pcarter@fastmail.com>
  • Loading branch information
4 people committed Jul 3, 2020
1 parent e4f9699 commit 0328e39
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<DependencyManagerAttribute>.GetTypeInfo().Assembly.Location
let assemblyLocation = typeof<Int32>.GetTypeInfo().Assembly.Location
Path.Combine(assemblyLocation, "../../..", dotnetApp)

if File.Exists(dotnetLocation) then
Expand Down
Original file line number Diff line number Diff line change
@@ -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

[<TestFixture>]
module ``PreComputedTupleConstructor Tests`` =

[<Test>]
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<int * string>) [| box 12; box "text" |] |> ignore)

Assert.DoesNotThrow testDelegate |> ignore

[<Test>]
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<int * string>) [| box "text"; box 12; |] |> ignore)

Assert.Throws<System.ArgumentException> testDelegate |> ignore
28 changes: 28 additions & 0 deletions tests/fsharp/Compiler/Libraries/Core/Reflection/SprintfTests.fs
Original file line number Diff line number Diff line change
@@ -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

[<TestFixture>]
module ``Sprintf Tests`` =

type MyR = {c:int;b:int;a:int}

[<Test>]
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

[<Test>]
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)
2 changes: 2 additions & 0 deletions tests/fsharp/FSharpSuite.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
<Compile Include="Compiler\Libraries\Core\Operators\RoundTests.fs" />
<Compile Include="Compiler\Libraries\Core\Operators\SignTests.fs" />
<Compile Include="Compiler\Libraries\Core\Operators\StringTests.fs" />
<Compile Include="Compiler\Libraries\Core\Reflection\SprintfTests.fs" />
<Compile Include="Compiler\Libraries\Core\Reflection\PreComputedTupleConstructorTests.fs" />
<Compile Include="Compiler\Libraries\Core\Unchecked\DefaultOfTests.fs" />
<None Include="app.config" />
<None Include="update.base.line.with.actuals.fsx" />
Expand Down
10 changes: 0 additions & 10 deletions tests/fsharpqa/Source/Libraries/Core/Reflection/DU.fs

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions tests/fsharpqa/Source/Libraries/Core/Reflection/Record.fs

This file was deleted.

4 changes: 0 additions & 4 deletions tests/fsharpqa/Source/Libraries/Core/Reflection/env.lst

This file was deleted.

0 comments on commit 0328e39

Please sign in to comment.