未验证 提交 bead0343 编写于 作者: K Kevin Ransom (msft) 提交者: GitHub

Tests for coreclr (#6151)

* Add coreclr test suite

* tests for linux

* No compiler on linux

* feedback
上级 b0292b8a
<Project> <Project>
<PropertyGroup>
<BUILD_IN_FSHARP_REPOSITORY>true</BUILD_IN_FSHARP_REPOSITORY>
</PropertyGroup>
<PropertyGroup Condition="'$(FSharpTestCompilerVersion)' == 'net40'"> <PropertyGroup Condition="'$(FSharpTestCompilerVersion)' == 'net40'">
<DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath> <DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
......
...@@ -39,8 +39,8 @@ build: proto restore ...@@ -39,8 +39,8 @@ build: proto restore
$(DotNetExe) build -c $(Configuration) -f netcoreapp2.0 tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj $(DotNetExe) build -c $(Configuration) -f netcoreapp2.0 tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj
test: build test: build
$(DotNetExe) test -f netcoreapp2.1 -c $(Configuration) --no-restore --no-build tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj -l "trx;LogFileName=$(CURDIR)/tests/TestResults/FSharp.Core.UnitTests.coreclr.trx" $(DotNetExe) test -f netcoreapp2.0 -c $(Configuration) --no-restore --no-build tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj -l "trx;LogFileName=$(CURDIR)/tests/TestResults/FSharp.Core.UnitTests.coreclr.trx"
$(DotNetExe) test -f netcoreapp2.1 -c $(Configuration) --no-restore --no-build tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj -l "trx;LogFileName=$(CURDIR)/tests/TestResults/FSharp.Build.UnitTests.coreclr.trx" $(DotNetExe) test -f netcoreapp2.0 -c $(Configuration) --no-restore --no-build tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj -l "trx;LogFileName=$(CURDIR)/tests/TestResults/FSharp.Build.UnitTests.coreclr.trx"
clean: clean:
rm -rf $(CURDIR)/artifacts rm -rf $(CURDIR)/artifacts
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
<FSLanguageVersion>4.5</FSLanguageVersion> <FSLanguageVersion>4.5</FSLanguageVersion>
<FSCoreMajorVersion>$(FSLanguageVersion)</FSCoreMajorVersion> <FSCoreMajorVersion>$(FSLanguageVersion)</FSCoreMajorVersion>
<FSCorePackageVersion>$(FSCoreMajorVersion).5</FSCorePackageVersion> <FSCorePackageVersion>$(FSCoreMajorVersion).4</FSCorePackageVersion>
<FSCoreVersion>$(FSCoreMajorVersion).0.0</FSCoreVersion> <FSCoreVersion>$(FSCoreMajorVersion).0.0</FSCoreVersion>
<FSCoreUnitTestsPackageVersion>$(FSCorePackageVersion).0</FSCoreUnitTestsPackageVersion>
<FSPackageMajorVersion>10.2</FSPackageMajorVersion> <FSPackageMajorVersion>10.2</FSPackageMajorVersion>
<FSPackageVersion>$(FSPackageMajorVersion).3</FSPackageVersion> <FSPackageVersion>$(FSPackageMajorVersion).3</FSPackageVersion>
......
<Project> <Project>
<ItemGroup> <ItemGroup>
<PackageReference Include="XliffTasks" Version="$(XliffTasksPackageVersion)" /> <PackageReference Include="XliffTasks" Version="$(XliffTasksPackageVersion)" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
</Project> </Project>
<Project> <Project>
<ItemGroup> <ItemGroup>
<PackageReference Include="Pdb2Pdb" Version="$(Pdb2PdbPackageVersion)" /> <PackageReference Include="Pdb2Pdb" Version="$(Pdb2PdbPackageVersion)" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<Target Name="ConvertPortablePdbs" <Target Name="ConvertPortablePdbs"
......
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
<MicrosoftVisualFSharpCoreRedistPackageVersion>1.0.0</MicrosoftVisualFSharpCoreRedistPackageVersion> <MicrosoftVisualFSharpCoreRedistPackageVersion>1.0.0</MicrosoftVisualFSharpCoreRedistPackageVersion>
<!-- other packages --> <!-- other packages -->
<FsCheckPackageVersion>3.0.0-alpha3</FsCheckPackageVersion> <FsCheckPackageVersion>3.0.0-alpha4</FsCheckPackageVersion>
<MicrosoftCompositionPackageVersion>1.0.30</MicrosoftCompositionPackageVersion> <MicrosoftCompositionPackageVersion>1.0.30</MicrosoftCompositionPackageVersion>
<Pdb2PdbPackageVersion>1.1.0-beta1-63314-01</Pdb2PdbPackageVersion> <Pdb2PdbPackageVersion>1.1.0-beta1-63314-01</Pdb2PdbPackageVersion>
<MicrosoftMSXMLPackageVersion>8.0.0-alpha</MicrosoftMSXMLPackageVersion> <MicrosoftMSXMLPackageVersion>8.0.0-alpha</MicrosoftMSXMLPackageVersion>
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
<TestCompiler Condition="'$(TEST_NET40_COMPILERUNIT_SUITE)' == '1'">true</TestCompiler> <TestCompiler Condition="'$(TEST_NET40_COMPILERUNIT_SUITE)' == '1'">true</TestCompiler>
<TestCompiler Condition="'$(TEST_CORECLR_COREUNIT_SUITE)' == '1'">true</TestCompiler> <TestCompiler Condition="'$(TEST_CORECLR_COREUNIT_SUITE)' == '1'">true</TestCompiler>
<TestFSharpSuite Condition="'$(TEST_NET40_FSHARP_SUITE)' == '1'">true</TestFSharpSuite> <TestFSharpSuite Condition="'$(TEST_NET40_FSHARP_SUITE)' == '1'">true</TestFSharpSuite>
<TestFSharpCoreUnitTest Condition="'$(TEST_NET40_COREUNIT_SUITE)' == '1'">true</TestFSharpCoreUnitTest>
<TestFSharpSuite Condition="'$(TEST_CORECLR_FSHARP_SUITE)' == '1'">true</TestFSharpSuite> <TestFSharpSuite Condition="'$(TEST_CORECLR_FSHARP_SUITE)' == '1'">true</TestFSharpSuite>
<TestFSharpQASuite Condition="'$(TEST_NET40_FSHARPQA_SUITE)' == '1'">true</TestFSharpQASuite> <TestFSharpQASuite Condition="'$(TEST_NET40_FSHARPQA_SUITE)' == '1'">true</TestFSharpQASuite>
<TestFCS Condition="'$(TEST_FCS)' == '1'">true</TestFCS> <TestFCS Condition="'$(TEST_FCS)' == '1'">true</TestFCS>
...@@ -107,7 +108,7 @@ ...@@ -107,7 +108,7 @@
<ItemGroup Condition="'$(BuildNuget)' == 'true' OR '$(_RunningRestore)' == 'true'"> <ItemGroup Condition="'$(BuildNuget)' == 'true' OR '$(_RunningRestore)' == 'true'">
<NugetProjects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.nuget\Microsoft.FSharp.Compiler.csproj" /> <NugetProjects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.nuget\Microsoft.FSharp.Compiler.csproj" />
<NugetProjects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.nuget\Microsoft.FSharp.Compiler.Prerelease.csproj" /> <NugetProjects Include="$(MSBuildThisFileDirectory)tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(BuildSetup)' == 'true' OR '$(_RunningRestore)' == 'true'"> <ItemGroup Condition="'$(BuildSetup)' == 'true' OR '$(_RunningRestore)' == 'true'">
...@@ -115,8 +116,7 @@ ...@@ -115,8 +116,7 @@
</ItemGroup> </ItemGroup>
<!-- test binaries --> <!-- test binaries -->
<ItemGroup Condition="'$(TestCompiler)' == 'true' OR '$(BuildNuget)' == 'true' OR '$(_RunningRestore)' == 'true'">
<ItemGroup Condition="'$(TestCompiler)' == 'true' OR '$(_RunningRestore)' == 'true'">
<Projects Include="$(MSBuildThisFileDirectory)tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" /> <Projects Include="$(MSBuildThisFileDirectory)tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" />
<Projects Include="$(MSBuildThisFileDirectory)tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" /> <Projects Include="$(MSBuildThisFileDirectory)tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" />
<Projects Include="$(MSBuildThisFileDirectory)tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" /> <Projects Include="$(MSBuildThisFileDirectory)tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" />
...@@ -127,7 +127,6 @@ ...@@ -127,7 +127,6 @@
<Projects Include="$(MSBuildThisFileDirectory)tests\fsharp\SDKTests\AllSdkTargetsTests.proj" /> <Projects Include="$(MSBuildThisFileDirectory)tests\fsharp\SDKTests\AllSdkTargetsTests.proj" />
<Projects Include="$(MSBuildThisFileDirectory)tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj" /> <Projects Include="$(MSBuildThisFileDirectory)tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj" />
<Projects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.nuget\Testing.FSharp.Compiler.csproj" /> <Projects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.nuget\Testing.FSharp.Compiler.csproj" />
<NugetProjects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.nuget\Testing.FSharp.Compiler.csproj" /> <NugetProjects Include="$(MSBuildThisFileDirectory)src\fsharp\FSharp.Compiler.nuget\Testing.FSharp.Compiler.csproj" />
</ItemGroup> </ItemGroup>
......
...@@ -340,7 +340,7 @@ this file. ...@@ -340,7 +340,7 @@ this file.
fragment into a temporary source file for the compiler. fragment into a temporary source file for the compiler.
============================================================ ============================================================
--> -->
<!-- <!--
============================================================ ============================================================
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<PackageId>Microsoft.FSharp.Compiler</PackageId> <PackageId>Microsoft.FSharp.Compiler</PackageId>
<PreRelease>false</PreRelease> <PreRelease>true</PreRelease>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
...@@ -68,6 +68,6 @@ ...@@ -68,6 +68,6 @@
<!-- resources --> <!-- resources -->
<file src="$artifactsbindir$\FSharp.Core\$configuration$\netstandard1.6\**\FSharp.Core.resources.dll" target="lib\netstandard1.6" /> <file src="$artifactsbindir$\FSharp.Core\$configuration$\netstandard1.6\**\FSharp.Core.resources.dll" target="lib\netstandard1.6" />
<file src="$artifactsbindir$\FSharp.Core\$configuration$\**\FSharp.Core.resources.dll" target="lib\net45" /> <file src="$artifactsbindir$\FSharp.Core\$configuration$\net45\**\FSharp.Core.resources.dll" target="lib\net45" />
</files> </files>
</package> </package>
...@@ -11,11 +11,14 @@ ...@@ -11,11 +11,14 @@
<ItemGroup> <ItemGroup>
<Compile Include="BasicProvider.Tests.fs" /> <Compile Include="BasicProvider.Tests.fs" />
<None Include="xunit.runner.json"> <None Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<Content Include="$(MSBuildProjectDirectory)\**\*.*"
Exclude="$(MSBuildProjectDirectory)\bin\**\*.*;$(MSBuildProjectDirectory)\obj\**\*.*;$(MSBuildProjectDirectory)\FSharp.Core\SampleTuples\**\*.*;$(MSBuildProjectDirectory)\Directory.Build.props;$(MSBuildProjectDirectory)\Directory.Build.targets;">
<Pack>true</Pack>
<PackagePath>content\myfiles\</PackagePath>
</Content>
<PackageReference Include="BasicProvider" Version="1.0.0" /> <PackageReference Include="BasicProvider" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170517-02" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170517-02" />
<PackageReference Include="xunit" Version="2.2.0" /> <PackageReference Include="xunit" Version="2.2.0" />
......
...@@ -39,7 +39,14 @@ module ILChecker = ...@@ -39,7 +39,14 @@ module ILChecker =
/// Compile the source and check to see if the expected IL exists. /// Compile the source and check to see if the expected IL exists.
/// The first line of each expected IL string is found first. /// The first line of each expected IL string is found first.
let check source expectedIL = let check source expectedIL =
let packagesDir = Environment.GetEnvironmentVariable("USERPROFILE") ++ ".nuget" ++ "packages" let packagesDir =
// On Unix the user profile directory is in the variable HOME
// On windows it's called USERPROFILE
let userProfile =
let profile = Environment.GetEnvironmentVariable("USERPROFILE")
if not (String.IsNullOrEmpty(profile)) then profile
else Environment.GetEnvironmentVariable("HOME")
userProfile ++ ".nuget" ++ "packages"
let Is64BitOperatingSystem = sizeof<nativeint> = 8 let Is64BitOperatingSystem = sizeof<nativeint> = 8
let architectureMoniker = if Is64BitOperatingSystem then "x64" else "x86" let architectureMoniker = if Is64BitOperatingSystem then "x64" else "x86"
let ildasmExe = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.ILDAsm") ++ "2.0.3" ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "ildasm.exe") let ildasmExe = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.ILDAsm") ++ "2.0.3" ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "ildasm.exe")
......
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="FSharp.Core.UnitTests.TestApp.App"
>
<Application.Resources>
</Application.Resources>
</Application>
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Silverlight.Testing;
using Microsoft.Silverlight.Testing.UnitTesting.Metadata.NUnit;
namespace FSharp.Core.UnitTests.TestApp
{
public partial class App : Application
{
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
NUnit.Framework.Assert.IsTrue(true); // force NUnitFarmework.dll to load
UnitTestSystem.RegisterUnitTestProvider(new NUnitProvider());
UnitTestSettings settings = UnitTestSystem.CreateDefaultSettings();
settings.TestAssemblies.Add(typeof(global::FSharp.Core.UnitTests.LibraryTestFx).Assembly);
RootVisual = UnitTestSystem.CreateTestPage(settings);
}
private void Application_Exit(object sender, EventArgs e)
{
}
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
if (!System.Diagnostics.Debugger.IsAttached)
{
// NOTE: This will allow the application to continue running after an exception has been thrown
// but not handled.
// For production applications this error handling should be replaced with something that will
// report the error to the website and stop the application.
e.Handled = true;
Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
}
}
private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
{
try
{
string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg + "\");");
}
catch (Exception)
{
}
}
}
}
<!-- Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -->
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<FSharpSourcesRoot>$(MSBuildProjectDirectory)\..\..\src</FSharpSourcesRoot>
</PropertyGroup>
<PropertyGroup>
<NUnit>$(FSharpSourcesRoot)\..\tools\nUnit.Silverlight</NUnit>
<TargetFrameworkDirectory>$(FSharpSourcesRoot)\..\tools\Silverlight 2.0.30523.8</TargetFrameworkDirectory>
<SilverlightRuntimeVersion>2.0</SilverlightRuntimeVersion>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6E8DFF3E-E450-41BF-9E6D-7B3CA2758779}</ProjectGuid>
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FSharp.Core.UnitTests.TestApp</RootNamespace>
<AssemblyName>FSharp.Core.UnitTests.TestApp</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>FSharp.Core.UnitTests.TestApp.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>FSharp.Core.UnitTests.TestApp.App</SilverlightAppEntry>
<TestPageFileName>TestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>false</ThrowErrorsInValidation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>$(FSharpSourcesRoot)\..\Silverlight\built\$(AssemblyName)\</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Core, Version=1.9.6.16, Culture=neutral, PublicKeyToken=99cf57b64b44bf93, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(OutputPath)\..\bin\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="FSharp.Core.UnitTests, Version=1.9.6.16, Culture=neutral, PublicKeyToken=99cf57b64b44bf93, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(OutputPath)\..\bin\FSharp.Core.UnitTests.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Silverlight.Testing, Version=2.0.21103.1925, Culture=neutral, PublicKeyToken=2c5c654d367bf4a7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(NUnit)\Microsoft.Silverlight.Testing.dll</HintPath>
</Reference>
<Reference Include="NUnitFramework, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(NUnit)\NUnitFramework.dll</HintPath>
</Reference>
<Reference Include="NUnitSilverlight, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(NUnit)\NUnitSilverlight.dll</HintPath>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" >
<Private>true</Private>
</Reference>
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:MarkupCompilePass1</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AppManifest.xml" />
</ItemGroup>
<Import Project="$(FSharpSourcesRoot)\..\tools\.NET Framework 3.5\Microsoft.CSharp.targets" />
<Import Project="$(FSharpSourcesRoot)\..\tools\Silverlight 2.0.30523.8\Microsoft.Silverlight.Common.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
<SilverlightProjectProperties />
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -->
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="2.0.0.0-FSCoreVersion" newVersion="FSCoreVersion" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
...@@ -5,14 +5,29 @@ ...@@ -5,14 +5,29 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks> <TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AssemblyName>FSharp.Core.UnitTests</AssemblyName>
<PackageId>Microsoft.FSharp.Core.UnitTests</PackageId>
<PackageVersion>$(FSCoreUnitTestsPackageVersion)</PackageVersion>
<PreRelease>true</PreRelease>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference> <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<UnitTestType>nunit</UnitTestType> <UnitTestType>xunit</UnitTestType>
<IsTestProject>true</IsTestProject>
<IsPackable>true</IsPackable>
<!-- must be false so FsCheck can be loaded --> <!-- must be false so FsCheck can be loaded -->
<SignAssembly>false</SignAssembly> <SignAssembly>false</SignAssembly>
<TailCalls>true</TailCalls>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="'$(UnitTestType)' == 'xunit'">$(DefineConstants);XUNIT</DefineConstants>
<DefineConstants Condition="'$(UnitTestType)' != 'xunit'">$(DefineConstants);NUNIT</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="NUnitFrameworkShims.fs" />
<Compile Include="LibraryTestFx.fs" /> <Compile Include="LibraryTestFx.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\Utils.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Collections\Utils.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ArrayModule.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ArrayModule.fs" />
...@@ -51,9 +66,9 @@ ...@@ -51,9 +66,9 @@
<Compile Include="FSharp.Core\Microsoft.FSharp.Core\PrintfTests.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Core\PrintfTests.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Core\ResultTests.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Core\ResultTests.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Core\ExtraTopLevelOperatorsTests.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Core\ExtraTopLevelOperatorsTests.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Control\LazyType.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Control\Cancellation.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Control\Cancellation.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Control\AsyncType.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Control\AsyncType.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Control\LazyType.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Control\MailboxProcessorType.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Control\MailboxProcessorType.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Control\AsyncModule.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Control\AsyncModule.fs" />
<Compile Include="FSharp.Core\Microsoft.FSharp.Control\ObservableModule.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Control\ObservableModule.fs" />
...@@ -62,21 +77,33 @@ ...@@ -62,21 +77,33 @@
<Compile Include="FSharp.Core\Microsoft.FSharp.Quotations\FSharpQuotations.fs" /> <Compile Include="FSharp.Core\Microsoft.FSharp.Quotations\FSharpQuotations.fs" />
<Compile Include="TypeForwarding.fs" /> <Compile Include="TypeForwarding.fs" />
<Compile Include="StructTuples.fs" /> <Compile Include="StructTuples.fs" />
<Compile Include="SurfaceArea.coreclr.fs" Condition="$(TargetFramework.StartsWith('netcoreapp'))" /> <Compile Include="SurfaceArea.coreclr.fs" Condition="$(TargetFramework.StartsWith('netcoreapp')) and '$(FX_VERIFY_SURFACEAREA)' == 'true'" />
<Compile Include="SurfaceArea.net40.fs" Condition="$(TargetFramework.StartsWith('net4'))" /> <Compile Include="SurfaceArea.net40.fs" Condition="$(TargetFramework.StartsWith('net4')) and '$(FX_VERIFY_SURFACEAREA)' == 'true'" />
<CopyAndSubstituteText Include="FSharp.Core.UnitTests.dll.config">
<TargetFilename>FSharp.Core.UnitTests.dll.config</TargetFilename>
<Pattern1>FSCoreVersion</Pattern1>
<Replacement1>$(FSCoreVersion)</Replacement1>
</CopyAndSubstituteText>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj" /> <Content Include="**/*" Exclude="**/*.bak;Directory.Build.Props;Directory.Build.targets" CopyToOutputDirectory="never" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup Condition="'$(BUILD_IN_FSHARP_REPOSITORY)' == 'true'">
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj" />
<PackageReference Include="FsCheck" Version="$(FsCheckPackageVersion)" /> <PackageReference Include="FsCheck" Version="$(FsCheckPackageVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(BUILD_IN_FSHARP_REPOSITORY)' != 'true'">
<PackageReference Include="FSharp.Core" Version="4.6.0" />
<PackageReference Include="FsCheck" Version="3.0.0-alpha4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(UnitTestType)' == 'xunit'">
<PackageReference Include="xunit" Version="2.4.1" PrivateAssets="All" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(UnitTestType)' != 'xunit'">
<PackageReference Include="nunit" Version="3.11.0" PrivateAssets="All" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.0" PrivateAssets="All" />
</ItemGroup>
</Project> </Project>
...@@ -1628,7 +1628,7 @@ module ComparersRegression = ...@@ -1628,7 +1628,7 @@ module ComparersRegression =
static member I = inlinable static member I = inlinable
static member N = noninlinable static member N = noninlinable
#if !NETSTANDARD1_6 #if !NETSTANDARD1_6 && !NETCOREAPP
let create<'a,'b when 'b : equality> name operation (f:IOperation<'a>) (items:array<'a>) = let create<'a,'b when 'b : equality> name operation (f:IOperation<'a>) (items:array<'a>) =
printf """ [<Test>] printf """ [<Test>]
member __.``%s %s``() = member __.``%s %s``() =
...@@ -1217,12 +1217,14 @@ let unfold<'a,'b when 'b : equality> f (start:'a) = ...@@ -1217,12 +1217,14 @@ let unfold<'a,'b when 'b : equality> f (start:'a) =
let ``unfold is consistent`` () = let ``unfold is consistent`` () =
smallerSizeCheck unfold<int,int> smallerSizeCheck unfold<int,int>
#if EXPENSIVE
[<Test; Category("Expensive"); Explicit>] [<Test; Category("Expensive"); Explicit>]
let ``unfold is consistent full`` () = let ``unfold is consistent full`` () =
smallerSizeCheck unfold<int,int> smallerSizeCheck unfold<int,int>
smallerSizeCheck unfold<string,string> smallerSizeCheck unfold<string,string>
smallerSizeCheck unfold<float,int> smallerSizeCheck unfold<float,int>
smallerSizeCheck unfold<float,string> smallerSizeCheck unfold<float,string>
#endif
let unzip<'a when 'a : equality> (xs:('a*'a) []) = let unzip<'a when 'a : equality> (xs:('a*'a) []) =
// no seq version // no seq version
......
...@@ -134,7 +134,7 @@ module ChoiceUtils = ...@@ -134,7 +134,7 @@ module ChoiceUtils =
if not <| List.isEmpty ops then if not <| List.isEmpty ops then
let minTimeout = getMinTime() let minTimeout = getMinTime()
let minTimeoutOps = ops |> Seq.filter (fun op -> op.Timeout <= minTimeout) |> Seq.length let minTimeoutOps = ops |> Seq.filter (fun op -> op.Timeout <= minTimeout) |> Seq.length
Assert.LessOrEqual(!completed, minTimeoutOps) Assert.IsTrue(!completed <= minTimeoutOps)
module LeakUtils = module LeakUtils =
// when testing for liveness, the things that we want to observe must always be created in // when testing for liveness, the things that we want to observe must always be created in
...@@ -161,18 +161,10 @@ type AsyncModule() = ...@@ -161,18 +161,10 @@ type AsyncModule() =
do! Async.Sleep(20) do! Async.Sleep(20)
return !tickstamps return !tickstamps
} }
let wait (wh : #System.Threading.WaitHandle) (timeoutMilliseconds : int) = let wait (wh : System.Threading.WaitHandle) (timeoutMilliseconds : int) =
#if FX_NO_WAITONE_MILLISECONDS
wh.WaitOne(TimeSpan.FromMilliseconds (float timeoutMilliseconds))
#else
#if FX_NO_EXIT_CONTEXT_FLAGS
wh.WaitOne(timeoutMilliseconds)
#else
wh.WaitOne(timeoutMilliseconds, exitContext=false) wh.WaitOne(timeoutMilliseconds, exitContext=false)
#endif
#endif
let dispose(d : #IDisposable) = d.Dispose() let dispose(d : #IDisposable) = d.Dispose()
...@@ -266,7 +258,7 @@ type AsyncModule() = ...@@ -266,7 +258,7 @@ type AsyncModule() =
// wait 10 seconds for completion // wait 10 seconds for completion
let ok = wait barrier 10000 let ok = wait barrier 10000
if not ok then Assert.Fail("Async computation was not completed in given time") if not ok then Assert.Fail("Async computation was not completed in given time")
[<Test>] [<Test>]
member this.``AwaitWaitHandle.DisposedWaitHandle1``() = member this.``AwaitWaitHandle.DisposedWaitHandle1``() =
let wh = new System.Threading.ManualResetEvent(false) let wh = new System.Threading.ManualResetEvent(false)
...@@ -349,7 +341,7 @@ type AsyncModule() = ...@@ -349,7 +341,7 @@ type AsyncModule() =
for _i = 1 to 3 do test() for _i = 1 to 3 do test()
#if EXPENSIVE
[<Test; Category("Expensive"); Explicit>] [<Test; Category("Expensive"); Explicit>]
member this.``Async.AwaitWaitHandle does not leak memory`` () = member this.``Async.AwaitWaitHandle does not leak memory`` () =
// This test checks that AwaitWaitHandle does not leak continuations (described in #131), // This test checks that AwaitWaitHandle does not leak continuations (described in #131),
...@@ -383,7 +375,8 @@ type AsyncModule() = ...@@ -383,7 +375,8 @@ type AsyncModule() =
// The leak hangs on a race condition which is really hard to trigger in F# 3.0, hence the 100000 runs... // The leak hangs on a race condition which is really hard to trigger in F# 3.0, hence the 100000 runs...
for _ in 1..10 do tryToLeak() for _ in 1..10 do tryToLeak()
#endif
[<Test>] [<Test>]
member this.``AwaitWaitHandle.DisposedWaitHandle2``() = member this.``AwaitWaitHandle.DisposedWaitHandle2``() =
let wh = new System.Threading.ManualResetEvent(false) let wh = new System.Threading.ManualResetEvent(false)
...@@ -441,11 +434,13 @@ type AsyncModule() = ...@@ -441,11 +434,13 @@ type AsyncModule() =
member this.``RaceBetweenCancellationAndError.Sleep``() = member this.``RaceBetweenCancellationAndError.Sleep``() =
testErrorAndCancelRace (Async.Sleep (-5)) testErrorAndCancelRace (Async.Sleep (-5))
#if EXPENSIVE
#if NET46 #if NET46
[<Test; Category("Expensive"); Explicit>] // takes 3 minutes! [<Test; Category("Expensive"); Explicit>] // takes 3 minutes!
member this.``Async.Choice specification test``() = member this.``Async.Choice specification test``() =
ThreadPool.SetMinThreads(100,100) |> ignore ThreadPool.SetMinThreads(100,100) |> ignore
Check.One ({Config.QuickThrowOnFailure with EndSize = 20}, normalize >> runChoice) Check.One ({Config.QuickThrowOnFailure with EndSize = 20}, normalize >> runChoice)
#endif
#endif #endif
[<Test>] [<Test>]
...@@ -565,6 +560,7 @@ type AsyncModule() = ...@@ -565,6 +560,7 @@ type AsyncModule() =
Assert.AreEqual("boom", !r) Assert.AreEqual("boom", !r)
#if IGNORED
[<Test; Ignore("See https://github.com/Microsoft/visualfsharp/issues/4887")>] [<Test; Ignore("See https://github.com/Microsoft/visualfsharp/issues/4887")>]
member this.``SleepContinuations``() = member this.``SleepContinuations``() =
let okCount = ref 0 let okCount = ref 0
...@@ -591,6 +587,7 @@ type AsyncModule() = ...@@ -591,6 +587,7 @@ type AsyncModule() =
for i = 1 to 3 do test() for i = 1 to 3 do test()
Assert.AreEqual(0, !okCount) Assert.AreEqual(0, !okCount)
Assert.AreEqual(0, !errCount) Assert.AreEqual(0, !errCount)
#endif
[<Test>] [<Test>]
member this.``Async caching should work``() = member this.``Async caching should work``() =
......
...@@ -86,9 +86,7 @@ type AsyncType() = ...@@ -86,9 +86,7 @@ type AsyncType() =
// In such case TimeoutException is raised // In such case TimeoutException is raised
// since ThreadPool cannot provide 1000 threads in 1 second // since ThreadPool cannot provide 1000 threads in 1 second
// (the number of threads in ThreadPool is adjusted slowly). // (the number of threads in ThreadPool is adjusted slowly).
Assert.DoesNotThrow(fun () -> Async.RunSynchronously(computation, timeout = 1000) |> ignore
Async.RunSynchronously(computation, timeout = 1000)
|> ignore)
[<Test>] [<Test>]
member this.AsyncSleepCancellation1() = member this.AsyncSleepCancellation1() =
...@@ -317,7 +315,8 @@ type AsyncType() = ...@@ -317,7 +315,8 @@ type AsyncType() =
e -> exceptionThrown <- true e -> exceptionThrown <- true
Assert.IsTrue (t.IsFaulted) Assert.IsTrue (t.IsFaulted)
Assert.IsTrue(exceptionThrown) Assert.IsTrue(exceptionThrown)
#if IGNORED
[<Test>] [<Test>]
[<Ignore("https://github.com/Microsoft/visualfsharp/issues/4337")>] [<Ignore("https://github.com/Microsoft/visualfsharp/issues/4337")>]
member this.CancellationPropagatesToImmediateTask () = member this.CancellationPropagatesToImmediateTask () =
...@@ -337,7 +336,9 @@ type AsyncType() = ...@@ -337,7 +336,9 @@ type AsyncType() =
with e -> exceptionThrown <- true with e -> exceptionThrown <- true
Assert.IsTrue (exceptionThrown) Assert.IsTrue (exceptionThrown)
Assert.IsTrue(t.IsCanceled) Assert.IsTrue(t.IsCanceled)
#endif
#if IGNORED
[<Test>] [<Test>]
[<Ignore("https://github.com/Microsoft/visualfsharp/issues/4337")>] [<Ignore("https://github.com/Microsoft/visualfsharp/issues/4337")>]
member this.CancellationPropagatesToGroupImmediate () = member this.CancellationPropagatesToGroupImmediate () =
...@@ -350,11 +351,7 @@ type AsyncType() = ...@@ -350,11 +351,7 @@ type AsyncType() =
} }
let cts = new CancellationTokenSource() let cts = new CancellationTokenSource()
let token = cts.Token let token = cts.Token
#if !NET46
let t =
#else
use t = use t =
#endif
Async.StartImmediateAsTask(a, cancellationToken=token) Async.StartImmediateAsTask(a, cancellationToken=token)
// printfn "%A" t.Status // printfn "%A" t.Status
ewh.WaitOne() |> Assert.IsTrue ewh.WaitOne() |> Assert.IsTrue
...@@ -367,7 +364,7 @@ type AsyncType() = ...@@ -367,7 +364,7 @@ type AsyncType() =
Assert.IsTrue (exceptionThrown) Assert.IsTrue (exceptionThrown)
Assert.IsTrue(t.IsCanceled) Assert.IsTrue(t.IsCanceled)
Assert.IsTrue(!cancelled) Assert.IsTrue(!cancelled)
#endif
[<Test>] [<Test>]
member this.TaskAsyncValue () = member this.TaskAsyncValue () =
......
...@@ -199,7 +199,6 @@ type CancellationType() = ...@@ -199,7 +199,6 @@ type CancellationType() =
let asyncs = seq { for i in 1..1000 do yield async { cts.Cancel() } } let asyncs = seq { for i in 1..1000 do yield async { cts.Cancel() } }
asyncs |> Async.Parallel |> Async.RunSynchronously |> ignore asyncs |> Async.Parallel |> Async.RunSynchronously |> ignore
Assert.IsTrue(!callbackRun, "Callback should run at least once") Assert.IsTrue(!callbackRun, "Callback should run at least once")
[<Test>] [<Test>]
member this.TestRegistrationRace() = member this.TestRegistrationRace() =
...@@ -215,7 +214,7 @@ type CancellationType() = ...@@ -215,7 +214,7 @@ type CancellationType() =
} }
} }
(asyncs |> Async.Parallel |> Async.RunSynchronously |> ignore) (asyncs |> Async.Parallel |> Async.RunSynchronously |> ignore)
[<Test>] [<Test>]
member this.LinkedSourceCancellationRace() = member this.LinkedSourceCancellationRace() =
let asyncs = let asyncs =
......
...@@ -747,6 +747,7 @@ type OperatorsModule1() = ...@@ -747,6 +747,7 @@ type OperatorsModule1() =
let boundenum = Operators.enum<System.ConsoleColor> normalarg let boundenum = Operators.enum<System.ConsoleColor> normalarg
Assert.AreEqual(boundenum, System.ConsoleColor.Blue) Assert.AreEqual(boundenum, System.ConsoleColor.Blue)
#if IGNORED
[<Test;Ignore("See FSB #3826 ? Need way to validate Operators.exit function.")>] [<Test;Ignore("See FSB #3826 ? Need way to validate Operators.exit function.")>]
member this.exit() = member this.exit() =
// zero // zero
...@@ -764,7 +765,8 @@ type OperatorsModule1() = ...@@ -764,7 +765,8 @@ type OperatorsModule1() =
// normal value // normal value
let boundexit = Operators.exit 100 let boundexit = Operators.exit 100
Assert.AreEqual(boundexit, 0) Assert.AreEqual(boundexit, 0)
#endif
[<Test>] [<Test>]
member this.exp() = member this.exp() =
// zero // zero
...@@ -880,7 +882,8 @@ type OperatorsModule1() = ...@@ -880,7 +882,8 @@ type OperatorsModule1() =
Assert.AreEqual(result,null) Assert.AreEqual(result,null)
() ()
#if IGNORED
[<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>] [<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>]
member this.incr() = member this.incr() =
// legit value // legit value
...@@ -893,7 +896,8 @@ type OperatorsModule1() = ...@@ -893,7 +896,8 @@ type OperatorsModule1() =
CheckThrowsOverflowException(fun() -> Operators.incr result |> ignore) CheckThrowsOverflowException(fun() -> Operators.incr result |> ignore)
() ()
#endif
[<Test>] [<Test>]
member this.infinity() = member this.infinity() =
......
...@@ -13,6 +13,7 @@ open Microsoft.FSharp.Core.Operators.Checked ...@@ -13,6 +13,7 @@ open Microsoft.FSharp.Core.Operators.Checked
[<TestFixture>] [<TestFixture>]
type OperatorsModule2() = type OperatorsModule2() =
#if IGNORED
[<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>] [<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>]
member this.int() = member this.int() =
// int // int
...@@ -39,7 +40,9 @@ type OperatorsModule2() = ...@@ -39,7 +40,9 @@ type OperatorsModule2() =
CheckThrowsOverflowException(fun() -> Operators.int System.Double.MaxValue |>ignore) CheckThrowsOverflowException(fun() -> Operators.int System.Double.MaxValue |>ignore)
() ()
#endif
#if IGNORED
[<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>] [<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>]
member this.int16() = member this.int16() =
// int // int
...@@ -64,9 +67,10 @@ type OperatorsModule2() = ...@@ -64,9 +67,10 @@ type OperatorsModule2() =
// overflow // overflow
CheckThrowsOverflowException(fun() -> Operators.int16 System.Double.MaxValue |>ignore) CheckThrowsOverflowException(fun() -> Operators.int16 System.Double.MaxValue |>ignore)
() ()
#endif
#if IGNORED
[<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>] [<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>]
member this.int32() = member this.int32() =
// int // int
...@@ -91,9 +95,10 @@ type OperatorsModule2() = ...@@ -91,9 +95,10 @@ type OperatorsModule2() =
// overflow // overflow
CheckThrowsOverflowException(fun() -> Operators.int32 System.Double.MaxValue |>ignore) CheckThrowsOverflowException(fun() -> Operators.int32 System.Double.MaxValue |>ignore)
() ()
#endif
#if IGNORED
[<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>] [<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>]
member this.int64() = member this.int64() =
// int // int
...@@ -118,9 +123,9 @@ type OperatorsModule2() = ...@@ -118,9 +123,9 @@ type OperatorsModule2() =
// overflow // overflow
CheckThrowsOverflowException(fun() -> Operators.int64 System.Double.MaxValue |>ignore) CheckThrowsOverflowException(fun() -> Operators.int64 System.Double.MaxValue |>ignore)
() ()
#endif
// [<Test>] // [<Test>]
// member this.invalidArg() = // member this.invalidArg() =
// CheckThrowsArgumentException(fun() -> Operators.invalidArg "A" "B" |>ignore ) // CheckThrowsArgumentException(fun() -> Operators.invalidArg "A" "B" |>ignore )
...@@ -243,7 +248,8 @@ type OperatorsModule2() = ...@@ -243,7 +248,8 @@ type OperatorsModule2() =
Assert.AreEqual(result,System.Single.NaN) Assert.AreEqual(result,System.Single.NaN)
() ()
#if IGNORED
[<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>] [<Test; Ignore( "[FSharp Bugs 1.0] #3842 - OverflowException does not pop up on Operators.int int16 int 32 int64 ")>]
member this.nativeint() = member this.nativeint() =
// int // int
...@@ -270,7 +276,8 @@ type OperatorsModule2() = ...@@ -270,7 +276,8 @@ type OperatorsModule2() =
CheckThrowsOverflowException(fun() -> Operators.nativeint System.Double.MaxValue |>ignore) CheckThrowsOverflowException(fun() -> Operators.nativeint System.Double.MaxValue |>ignore)
() ()
#endif
[<Test>] [<Test>]
member this.not() = member this.not() =
let result = Operators.not true let result = Operators.not true
......
...@@ -106,7 +106,7 @@ type LanguagePrimitivesModule() = ...@@ -106,7 +106,7 @@ type LanguagePrimitivesModule() =
Assert.AreEqual(1, resultRef) Assert.AreEqual(1, resultRef)
#if NETSTANDARD1_6 #if NETSTANDARD1_6 || NETCOREAPP
// TODO named #define ? // TODO named #define ?
#else #else
[<Test>] [<Test>]
...@@ -602,9 +602,8 @@ type UnitType() = ...@@ -602,9 +602,8 @@ type UnitType() =
member this.ObjectEquals() = member this.ObjectEquals() =
let u:Unit = () let u:Unit = ()
CheckThrowsNullRefException(fun() ->u.Equals(null) |>ignore) CheckThrowsNullRefException(fun() ->u.Equals(null) |>ignore)
#if NETSTANDARD1_6 #if NETSTANDARD1_6 || NETCOREAPP
// TODO named #define ? // TODO named #define ?
#else #else
[<TestFixture>] [<TestFixture>]
......
...@@ -52,7 +52,7 @@ let CheckThrowsFormatException f = CheckThrowsExn<FormatException> ...@@ -52,7 +52,7 @@ let CheckThrowsFormatException f = CheckThrowsExn<FormatException>
// Verifies two sequences are equal (same length, equiv elements) // Verifies two sequences are equal (same length, equiv elements)
let VerifySeqsEqual (seq1 : seq<'T>) (seq2 : seq<'T>) = let VerifySeqsEqual (seq1 : seq<'T>) (seq2 : seq<'T>) =
CollectionAssert.AreEqual (seq1, seq2) CollectionAssert.AreEqual(seq1, seq2)
let sleep(n : int32) = let sleep(n : int32) =
#if FX_NO_THREAD #if FX_NO_THREAD
...@@ -61,6 +61,7 @@ let sleep(n : int32) = ...@@ -61,6 +61,7 @@ let sleep(n : int32) =
System.Threading.Thread.Sleep(n) System.Threading.Thread.Sleep(n)
#endif #endif
#if VERIFY_SURFACEAREA
module SurfaceArea = module SurfaceArea =
open System.Reflection open System.Reflection
open System open System
...@@ -172,3 +173,4 @@ module SurfaceArea = ...@@ -172,3 +173,4 @@ module SurfaceArea =
sb.ToString () sb.ToString ()
Assert.Fail msg Assert.Fail msg
#endif
\ No newline at end of file
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace NUnit.Framework namespace NUnit.Framework
open System open System
open System.Collections.Generic
open System.Linq
#if XUNIT
open Xunit
(* The threading tests under XUnit seem prone to be verey Flakey *)
[<assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)>]
do ()
type TestAttribute() =
inherit FactAttribute()
type TestFixtureAttribute() = type TestFixtureAttribute() =
inherit System.Attribute() inherit System.Attribute()
type TestAttribute() = type Explicit() =
inherit System.Attribute() inherit System.Attribute()
type SetUpAttribute() = type SetUpAttribute() =
inherit System.Attribute() inherit System.Attribute()
[<AttributeUsage(AttributeTargets.All, AllowMultiple = true)>]
type Category(_categories:string) =
inherit System.Attribute()
type TearDownAttribute() = type TearDownAttribute() =
inherit System.Attribute() inherit System.Attribute()
type IgnoreAttribute (_comment:string) =
inherit System.Attribute ()
#endif
// Alias NUnit and XUnit Assert as LocalAssert
type TestFrameworkAssert = Assert
exception AssertionException of string exception AssertionException of string
module private Impl = module private Impl =
let rec equals (expected:obj) (actual:obj) = open FsCheck.Arb
let rec equals (expected:obj) (actual:obj) =
// get length expected
let toArray (o:obj) =
match o with
| :? seq<bigint> as seq -> seq |> Seq.toArray :>obj
| :? seq<decimal> as seq -> seq |> Seq.toArray :>obj
| :? seq<float> as seq -> seq |> Seq.toArray :>obj
| :? seq<float32> as seq -> seq |> Seq.toArray :>obj
| :? seq<uint64> as seq -> seq |> Seq.toArray :>obj
| :? seq<int64> as seq -> seq |> Seq.toArray :>obj
| :? seq<uint32> as seq -> seq |> Seq.toArray :>obj
| :? seq<int32> as seq -> seq |> Seq.toArray :>obj
| :? seq<uint16> as seq -> seq |> Seq.toArray :>obj
| :? seq<int16> as seq -> seq |> Seq.toArray :>obj
| :? seq<sbyte> as seq -> Enumerable.ToArray(seq) :>obj
| :? seq<byte> as seq -> seq |> Seq.toArray :>obj
| :? seq<char> as seq -> seq |> Seq.toArray :>obj
| :? seq<bool> as seq -> seq |> Seq.toArray :>obj
| :? seq<string> as seq -> seq |> Seq.toArray :>obj
| :? seq<IntPtr> as seq -> seq |> Seq.toArray :>obj
| :? seq<UIntPtr> as seq -> seq |> Seq.toArray :>obj
| :? seq<obj> as seq -> seq |> Seq.toArray :>obj
| _ -> o
// get length expected
let expected = toArray expected
let actual = toArray actual
match expected, actual with match expected, actual with
| (:? Array as a1), (:? Array as a2) -> | (:? Array as a1), (:? Array as a2) ->
if a1.Rank > 1 then failwith "Rank > 1 not supported" if a1.Rank > 1 then failwith "Rank > 1 not supported"
...@@ -32,9 +87,7 @@ module private Impl = ...@@ -32,9 +87,7 @@ module private Impl =
| _ -> | _ ->
Object.Equals(expected, actual) Object.Equals(expected, actual)
type Assert = type Assert =
static member AreEqual(expected : obj, actual : obj, message : string) = static member AreEqual(expected : obj, actual : obj, message : string) =
if not (Impl.equals expected actual) then if not (Impl.equals expected actual) then
let message = sprintf "%s: Expected %A but got %A" message expected actual let message = sprintf "%s: Expected %A but got %A" message expected actual
...@@ -45,7 +98,6 @@ type Assert = ...@@ -45,7 +98,6 @@ type Assert =
let message = sprintf "%s: Expected not %A but got %A" message expected actual let message = sprintf "%s: Expected not %A but got %A" message expected actual
AssertionException message |> raise AssertionException message |> raise
static member AreEqual(expected : obj, actual : obj) = Assert.AreEqual(expected, actual, "Assertion") static member AreEqual(expected : obj, actual : obj) = Assert.AreEqual(expected, actual, "Assertion")
static member AreNotEqual(expected : obj, actual : obj) = Assert.AreNotEqual(expected, actual, "Assertion") static member AreNotEqual(expected : obj, actual : obj) = Assert.AreNotEqual(expected, actual, "Assertion")
...@@ -58,14 +110,29 @@ type Assert = ...@@ -58,14 +110,29 @@ type Assert =
static member IsTrue(x : bool) = Assert.IsTrue(x, "") static member IsTrue(x : bool) = Assert.IsTrue(x, "")
static member True(x : bool) = Assert.IsTrue(x)
static member IsFalse(x : bool, message : string) = static member IsFalse(x : bool, message : string) =
if x then if x then
AssertionException(message) |> raise AssertionException(message) |> raise
static member IsFalse(x : bool) = Assert.IsFalse(x, "") static member IsFalse(x : bool) = Assert.IsFalse(x, "")
static member False(x : bool) = Assert.IsFalse(x)
static member Fail(message : string) = AssertionException(message) |> raise static member Fail(message : string) = AssertionException(message) |> raise
static member Fail() = Assert.Fail("") static member Fail() = Assert.Fail("")
static member Fail(message : string, args : obj[]) = Assert.Fail(String.Format(message,args)) static member Fail(message : string, args : obj[]) = Assert.Fail(String.Format(message,args))
\ No newline at end of file
#if XUNIT
static member Throws(except:Type, func: unit -> unit ) = TestFrameworkAssert.Throws(except, new Action(func))
#else
static member Throws(except:Type, func: unit -> unit ) = TestFrameworkAssert.Throws(except, TestDelegate(func))
#endif
type CollectionAssert =
static member AreEqual(expected, actual) =
Assert.AreEqual(expected, actual)
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("D87CB4EC-9844-4f98-9FEC-14DB50729D65")]
<Project> <Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('FSharp.Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" /> <Import Project="$([MSBuild]::GetPathOfFileAbove('FSharp.Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<PackageOutputPath>$(ArtifactsPackagesDir)\$(Configuration)</PackageOutputPath>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);FX_VERIFY_SURFACEAREA</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<PackageLicenceUrl Condition="'$(PackageLicenceUrl)' == ''">https://github.com/Microsoft/visualfsharp/blob/master/License.txt</PackageLicenceUrl>
<PackageProjectUrl Condition="'$(PackageProjectUrl)' == ''">https://github.com/Microsoft/visualfsharp</PackageProjectUrl>
<PackageAuthors Condition="'$(PackageAuthors)' == ''" >Microsoft and F# Software Foundation</PackageAuthors>
<PackageOwners Condition="'$(PackageOwners)' == ''" >Microsoft and F# Software Foundation</PackageOwners>
<PackageTags Condition="'$(PackageTags)' == ''" >Visual F# Compiler FSharp functional programming</PackageTags>
<PackageCopyright Condition="'$(PackageCopyright)' == ''" >(C) Microsoft Corporation. All rights reserved.</PackageCopyright>
<!-- can't have &lt; and &gt; which happens when building locally -->
<NormalizedGitHeadSha>$(GitHeadSha)</NormalizedGitHeadSha>
<NormalizedGitHeadSha Condition="'$(NormalizedGitHeadSha)' == '&lt;developer build&gt;'">[developer build]</NormalizedGitHeadSha>
<NuspecProperties>
licenseUrl=$(PackageLicenceUrl);
authors=$(PackageAuthors);
owners=$(PackageOwners);
projectUrl=$(PackageProjectUrl);
copyright=$(PackageCopyright);
tags=$(PackageTags);
githeadsha=$(NormalizedGitHeadSha);
configuration=$(Configuration);
artifactsbindir=$(ArtifactsBinDir);
</NuspecProperties>
</PropertyGroup>
</Project> </Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册