Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions appveyor-build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ if '%TEST_NET40%' == '1' (
@if ERRORLEVEL 1 echo Error: library unittests build failed && goto :failure
)

%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=coreclr /p:Configuration=Release /p:RestorePackages=true
@if ERRORLEVEL 1 echo Error: library unittests build failed coreclr && goto :failure

if '%TEST_PORTABLE47%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable47 && goto :failure
Expand Down Expand Up @@ -345,6 +348,9 @@ rem tests for TEST_VS are not executed
call RunTests.cmd release fsharp coreclr
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreclr' failed && goto :failure

call RunTests.cmd release coreunitcoreclr
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunit' failed && goto :failure

popd

goto :eof
Expand Down
3 changes: 2 additions & 1 deletion packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<package id="NUnit.Runners" version="2.6.4" targetFramework="net45" />
<package id="NUnit" version="3.0.0" targetFramework="net45" />
<package id="NUnit.Console" version="3.0.0" targetFramework="net45" />
</packages>
<package id="NUnitLite" version="3.0.0" targetFramework="net45" />
</packages>
1 change: 1 addition & 0 deletions src/FSharpSource.targets
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<When Condition="'$(AssemblyName)' == 'FSharp.Core.Unittests'">
<PropertyGroup>
<OtherFlags>$(OtherFlags) --version:4.4.0.9055</OtherFlags>
<ExcludeSigningImport>true</ExcludeSigningImport>
</PropertyGroup>
</When>
<Otherwise>
Expand Down
29 changes: 21 additions & 8 deletions src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
<SchemaVersion>2.0</SchemaVersion>
<AllowCrossTargeting>true</AllowCrossTargeting>
<ReferenceVsAssemblies>true</ReferenceVsAssemblies>
<OutputType>Library</OutputType>
<OutputType Condition="'$(TargetFramework)' == 'coreclr'">Exe</OutputType>
<OutputType Condition="'$(TargetFramework)' != 'coreclr'">Library</OutputType>
<AssemblyName>FSharp.Core.Unittests</AssemblyName>
<TargetFrameworkVersion Condition=" '$(TargetFramework)' == 'net20' ">v3.5</TargetFrameworkVersion>
<Name>SystematicUnitTests</Name>
<!-- Prevent compiler from inlining calls to FSharp.Core to improve code coverage accuracy -->
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<TargetProfile Condition=" '$(TargetFramework)' == 'portable7' or '$(TargetFramework)' == 'portable78' or '$(TargetFramework)' == 'portable259' ">netcore</TargetProfile>
<TargetProfile Condition=" '$(TargetFramework)' == 'portable7' or '$(TargetFramework)' == 'portable78' or '$(TargetFramework)' == 'portable259' or '$(TargetFramework)' == 'coreclr' ">netcore</TargetProfile>
<NoWarn>$(NoWarn);217</NoWarn>
</PropertyGroup>
<PropertyGroup>
Expand All @@ -45,26 +46,38 @@
</PropertyGroup>
<ItemGroup>
<!-- need full name and SpecificVersion = true in order to convince msbuild to allow this reference when targeting portable47 -->
<Reference Include="nunit.framework, Version=$(NUnitFullVersion), Culture=neutral, PublicKeyToken=2638cd05610744eb" Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'">
<Reference Include="nunit.framework, Version=$(NUnitFullVersion), Culture=neutral, PublicKeyToken=2638cd05610744eb" Condition="'$(TargetFramework)' != 'coreclr'">
<SpecificVersion>true</SpecificVersion>
<Private>True</Private>
<HintPath>$(NUnitLibDir)\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="FsCheck, Version=$(FsCheckFullVersion)" Condition="'$(TargetFramework)' != 'portable47' AND '$(TargetFramework)' != 'net20'">
<Reference Include="FsCheck, Version=$(FsCheckFullVersion)" Condition="'$(TargetFramework)' != 'portable47'">
<SpecificVersion>true</SpecificVersion>
<Private>True</Private>
<HintPath Condition="'$(TargetFramework)' == 'net40'">$(FsCheckLibDir)\net45\FsCheck.dll</HintPath>
<HintPath Condition="'$(TargetFramework)' == 'portable7'">$(FsCheckLibDir)\portable-net45+netcore45\FsCheck.dll</HintPath>
<HintPath Condition="'$(TargetFramework)' == 'portable78'">$(FsCheckLibDir)\portable-net45+netcore45+wp8\FsCheck.dll</HintPath>
<HintPath Condition="'$(TargetFramework)' == 'portable259'">$(FsCheckLibDir)\portable-net45+netcore45+wpa81+wp8\FsCheck.dll</HintPath>
<HintPath Condition="'$(TargetFramework)' == 'portable259' OR '$(TargetFramework)' == 'coreclr'">$(FsCheckLibDir)\portable-net45+netcore45+wpa81+wp8\FsCheck.dll</HintPath>
</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'))">
<ItemGroup Condition="'$(TargetFramework)' == 'coreclr'">
<Reference Include="nunit.framework, Version=3.0.5797.27550, Culture=neutral, PublicKeyToken=2638cd05610744eb">
<SpecificVersion>true</SpecificVersion>
<Private>True</Private>
<HintPath>..\..\..\packages\NUnit.3.0.0\lib\portable-net45+win8+wp8+wpa81+Xamarin.Mac+MonoAndroid10+MonoTouch10+Xamarin.iOS10\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="nunitlite, Version=3.0.5797.27550, Culture=neutral, PublicKeyToken=2638cd05610744eb">
<SpecificVersion>true</SpecificVersion>
<Private>True</Private>
<HintPath>..\..\..\packages\NUnitLite.3.0.0\lib\portable-net45+win8+wp8+wpa81+Xamarin.Mac\nunitlite.dll</HintPath>
</Reference>
<None Include="project.json" />
</ItemGroup>
<ItemGroup Condition="(!$(TargetFramework.Contains('portable'))) and '$(TargetFramework)' != 'coreclr'">
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Numerics" Condition="'$(TargetFramework)' == 'net40'" />
Expand Down Expand Up @@ -117,8 +130,8 @@
<Compile Include="FSharp.Core\Microsoft.FSharp.Reflection\FSharpReflection.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Quotations\FSharpQuotations.fs" />
<Compile Include="TypeForwarding.fs" />
<Compile Include="NUnitFrameworkShims.fs" Condition="'$(TargetFramework)' == 'sl3-wp'" />
<Compile Include="SurfaceArea.$(TargetFramework).fs" />
<Compile Include="Program.fs" Condition="'$(TargetFramework)' == 'coreclr'" />
<CustomCopyLocal Include="FSharp.Core.Unittests.dll.config">
<TargetFilename>FSharp.Core.Unittests.dll.config</TargetFilename>
</CustomCopyLocal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ type ListModule() =

Assert.AreEqual([null], List.distinct [null])
let list = new System.Collections.Generic.List<int>()
Assert.AreEqual([null, list], List.distinct [null, list])
Assert.IsTrue([null, list] = List.distinct [null, list])

[<Test>]
member this.distinctBy() =
Expand All @@ -185,7 +185,7 @@ type ListModule() =

Assert.AreEqual([null], List.distinctBy id [null])
let list = new System.Collections.Generic.List<int>()
Assert.AreEqual([null, list], List.distinctBy id [null, list])
Assert.IsTrue([null, list] = List.distinctBy id [null, list])

[<Test>]
member this.Take() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ type AsyncModule() =
#if FSHARP_CORE_2_0
// nothing
#else
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
//nothing
#else
// we are on the desktop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type AsyncType() =
member this.CreateTask () =
let s = "Hello tasks!"
let a = async { return s }
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t : Task<string> =
#else
use t : Task<string> =
Expand All @@ -140,7 +140,7 @@ type AsyncType() =
member this.StartTask () =
let s = "Hello tasks!"
let a = async { return s }
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand All @@ -155,7 +155,7 @@ type AsyncType() =
let a = async {
do raise (Exception ())
}
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand All @@ -174,7 +174,7 @@ type AsyncType() =
let a = async {
while true do ()
}
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand All @@ -199,7 +199,7 @@ type AsyncType() =
}
let cts = new CancellationTokenSource()
let token = cts.Token
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand All @@ -221,7 +221,7 @@ type AsyncType() =
[<Test>]
member this.TaskAsyncValue () =
let s = "Test"
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand All @@ -235,7 +235,7 @@ type AsyncType() =

[<Test>]
member this.TaskAsyncValueException () =
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand All @@ -254,7 +254,7 @@ type AsyncType() =
use ewh = new ManualResetEvent(false)
let cts = new CancellationTokenSource()
let token = cts.Token
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t : Task<unit>=
#else
use t : Task<unit>=
Expand All @@ -273,7 +273,7 @@ type AsyncType() =
[<Test>]
member this.NonGenericTaskAsyncValue () =
let hasBeenCalled = ref false
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand All @@ -288,7 +288,7 @@ type AsyncType() =

[<Test>]
member this.NonGenericTaskAsyncValueException () =
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand All @@ -307,7 +307,7 @@ type AsyncType() =
use ewh = new ManualResetEvent(false)
let cts = new CancellationTokenSource()
let token = cts.Token
#if FSHARP_CORE_NETCORE_PORTABLE
#if FSHARP_CORE_NETCORE_PORTABLE || coreclr
let t =
#else
use t =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ type FSharpValueTests() =
member this.GetExceptionFields() =

// int
Assert.AreEqual(FSharpValue.GetExceptionFields(exInt),[|1|])
Assert.AreEqual(FSharpValue.GetExceptionFields(exInt), ([|1|] : obj []))

// dataless
Assert.AreEqual(FSharpValue.GetExceptionFields(exDataless),[||])
Expand Down Expand Up @@ -257,7 +257,7 @@ type FSharpValueTests() =
member this.GetUnionFields() =
// single case union
let (singlecaseinfo,singlevaluearray) = FSharpValue.GetUnionFields(singlecaseunion1,typeof<SingleCaseDiscUnion>)
Assert.AreEqual(singlevaluearray, [|1.0;2.0;3.0|])
Assert.AreEqual(singlevaluearray, ([|1.0;2.0;3.0|] : obj []))

// DiscUnionType
let (duCaseinfo, duValueArray) = FSharpValue.GetUnionFields(discUniontypeB,typeof<DiscUnionType<int>>)
Expand Down Expand Up @@ -762,6 +762,9 @@ type FSharpTypeTests() =
()

[<Test>]
#if coreclr
[<Ignore("Failing in coreclr")>]
#endif
member this.IsModule() =

let getasm (t : Type) = t.Assembly
Expand Down
10 changes: 5 additions & 5 deletions src/fsharp/FSharp.Core.Unittests/FSharp.Core/PrimTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ type LanguagePrimitivesModule() =

// null reference
let resultNul = LanguagePrimitives.GenericMaximum null null
Assert.AreEqual(null, resultNul)
Assert.IsNull(resultNul)

let resultNul = LanguagePrimitives.GenericMaximum null "ABCDE"
Assert.AreEqual("ABCDE", resultNul)
Expand All @@ -360,13 +360,13 @@ type LanguagePrimitivesModule() =

// null reference
let resultNul = LanguagePrimitives.GenericMinimum null null
Assert.AreEqual(null, resultNul)
Assert.IsNull(resultNul)

let resultNul = LanguagePrimitives.GenericMinimum null "ABC"
Assert.AreEqual(null, resultNul)
Assert.IsNull(resultNul)

let resultNul = LanguagePrimitives.GenericMinimum "ABC" null
Assert.AreEqual(null, resultNul)
Assert.IsNull(resultNul)

[<Test>]
member this.GenericOne() =
Expand Down Expand Up @@ -425,7 +425,7 @@ type LanguagePrimitivesModule() =
Assert.AreEqual(-100000000000000000L, resultValue)

let resultValue = LanguagePrimitives.ParseInt64 "0"
Assert.AreEqual(0, resultValue)
Assert.AreEqual(0L, resultValue)

CheckThrowsFormatException(fun () -> LanguagePrimitives.ParseInt64 "" |> ignore)

Expand Down
6 changes: 3 additions & 3 deletions src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ module SurfaceArea =

// get current fsharp.core
let asm =
#if portable7 || portable78 || portable259
#if portable7 || portable78 || portable259 || coreclr
typeof<int list>.GetTypeInfo().Assembly
#else
typeof<int list>.Assembly
#endif

// public types only
let types =
#if portable7 || portable78 || portable259
#if portable7 || portable78 || portable259 || coreclr
asm.ExportedTypes |> Seq.filter (fun ty -> let ti = ty.GetTypeInfo() in ti.IsPublic || ti.IsNestedPublic) |> Array.ofSeq
#else
asm.GetExportedTypes()
Expand All @@ -96,7 +96,7 @@ module SurfaceArea =
// extract canonical string form for every public member of every type
let getTypeMemberStrings (t : Type) =
// for System.Runtime-based profiles, need to do lots of manual work
#if portable7 || portable78 || portable259
#if portable7 || portable78 || portable259 || coreclr
let getMembers (t : Type) =
let ti = t.GetTypeInfo()
let cast (info : #MemberInfo) = (t, info :> MemberInfo)
Expand Down
11 changes: 11 additions & 0 deletions src/fsharp/FSharp.Core.Unittests/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Program

open System
open System.Reflection
open NUnitLite

type HelperType() = inherit System.Object()

[<EntryPoint>]
let main argv =
AutoRun().Execute(typeof<HelperType>.GetTypeInfo().Assembly, Console.Out, Console.In, argv)
Loading