mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 01:45:29 +00:00
Split FsCheck data generators into a helper library (#716)
* Move generators and assertions to helper library. * Add example usage to bezier curve tests. * Add FsCheck to OpenTK.Tests.Math via paket. * Tweak fsharp msbuild settings for OpenTK.Tests.Generators.
This commit is contained in:
parent
0a5c346c52
commit
6ad8b92c84
|
@ -41,6 +41,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests.Integration",
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Tests.Math", "tests\OpenTK.Tests.Math\OpenTK.Tests.Math.csproj", "{C2B07CD9-B388-4FC3-AF31-C648F7EA904E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Tests.Math", "tests\OpenTK.Tests.Math\OpenTK.Tests.Math.csproj", "{C2B07CD9-B388-4FC3-AF31-C648F7EA904E}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OpenTK.Tests.Generators", "tests\OpenTK.Tests.Generators\OpenTK.Tests.Generators.fsproj", "{2B11AAEB-D8AC-4356-938F-532D720E0C30}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -91,6 +93,10 @@ Global
|
||||||
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2B11AAEB-D8AC-4356-938F-532D720E0C30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2B11AAEB-D8AC-4356-938F-532D720E0C30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2B11AAEB-D8AC-4356-938F-532D720E0C30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2B11AAEB-D8AC-4356-938F-532D720E0C30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -99,5 +105,6 @@ Global
|
||||||
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
{6801C263-ADDA-4A7B-979D-649BCB5A1DF7} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
||||||
{522D9279-3ED6-475F-867A-6AE69A53C24A} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
{522D9279-3ED6-475F-867A-6AE69A53C24A} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
||||||
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
{C2B07CD9-B388-4FC3-AF31-C648F7EA904E} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
||||||
|
{2B11AAEB-D8AC-4356-938F-532D720E0C30} = {1857BB8E-1A35-4EBF-9F6D-685F11DC025B}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace OpenTK.Tests
|
namespace OpenTK.Tests.Generators
|
||||||
|
|
||||||
open Xunit
|
open Xunit
|
||||||
open FsCheck
|
open FsCheck
|
||||||
|
@ -7,7 +7,7 @@ open System
|
||||||
open OpenTK
|
open OpenTK
|
||||||
|
|
||||||
[<AutoOpen>]
|
[<AutoOpen>]
|
||||||
module private AssertHelpers =
|
module public AssertHelpers =
|
||||||
[<Literal>]
|
[<Literal>]
|
||||||
let private BitAccuracy = 16
|
let private BitAccuracy = 16
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ module private AssertHelpers =
|
||||||
|
|
||||||
/// We use a full type here instead of a module, as the overloading semantics are more suitable for our desired goal.
|
/// We use a full type here instead of a module, as the overloading semantics are more suitable for our desired goal.
|
||||||
[<Sealed>]
|
[<Sealed>]
|
||||||
type internal Assert =
|
type public Assert =
|
||||||
|
|
||||||
static member ApproximatelyEquivalent(a : Vector2,b : Vector2) =
|
static member ApproximatelyEquivalent(a : Vector2,b : Vector2) =
|
||||||
if not <| approxEq a.X b.X && approxEq a.Y b.Y then raise <| new Xunit.Sdk.EqualException(a,b)
|
if not <| approxEq a.X b.X && approxEq a.Y b.Y then raise <| new Xunit.Sdk.EqualException(a,b)
|
|
@ -1,8 +1,6 @@
|
||||||
namespace OpenTK.Tests
|
namespace OpenTK.Tests.Generators
|
||||||
|
|
||||||
open Xunit
|
|
||||||
open FsCheck
|
open FsCheck
|
||||||
open FsCheck.Xunit
|
|
||||||
open System
|
open System
|
||||||
open OpenTK
|
open OpenTK
|
||||||
|
|
||||||
|
@ -66,7 +64,7 @@ module private Generators =
|
||||||
|> Gen.map Matrix4
|
|> Gen.map Matrix4
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|
|
||||||
type OpenTKGen =
|
type public OpenTKGen =
|
||||||
static member Single() = single
|
static member Single() = single
|
||||||
static member float32() = single
|
static member float32() = single
|
||||||
static member Double() = double
|
static member Double() = double
|
1538
tests/OpenTK.Tests.Generators/OpenTK.Tests.Generators.fsproj
Normal file
1538
tests/OpenTK.Tests.Generators/OpenTK.Tests.Generators.fsproj
Normal file
File diff suppressed because it is too large
Load diff
2
tests/OpenTK.Tests.Generators/paket.references
Normal file
2
tests/OpenTK.Tests.Generators/paket.references
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
xunit
|
||||||
|
FsCheck.XUnit
|
|
@ -1,8 +1,29 @@
|
||||||
using Xunit;
|
using FsCheck.Xunit;
|
||||||
|
using OpenTK.Tests.Generators;
|
||||||
|
using Xunit;
|
||||||
|
using Assert = Xunit.Assert;
|
||||||
|
|
||||||
namespace OpenTK.Tests.Unit
|
namespace OpenTK.Tests.Math
|
||||||
{
|
{
|
||||||
public class BezierCurveTests
|
public class BezierCurveTests
|
||||||
|
{
|
||||||
|
[Properties(Arbitrary = new[] { typeof(OpenTKGen) })]
|
||||||
|
public class Constructor
|
||||||
|
{
|
||||||
|
[Property]
|
||||||
|
public void AcceptingVector2EnumerableCreatesCurveContainingThePointsInTheEnumerable
|
||||||
|
(Vector2 a, Vector2 b, Vector2 c, Vector2 d)
|
||||||
|
{
|
||||||
|
var expected = new[] { a, b, c, d };
|
||||||
|
|
||||||
|
var curve = new BezierCurve(expected);
|
||||||
|
|
||||||
|
var actual = curve.Points;
|
||||||
|
Assert.Equal(expected, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CalculatePoint
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void StraightLine()
|
public void StraightLine()
|
||||||
|
@ -14,3 +35,4 @@ namespace OpenTK.Tests.Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,3 +4,4 @@ xunit
|
||||||
xunit.abstractions
|
xunit.abstractions
|
||||||
xunit.extensibility.core
|
xunit.extensibility.core
|
||||||
xunit.extensibility.execution
|
xunit.extensibility.execution
|
||||||
|
FsCheck.XUnit
|
|
@ -5,6 +5,7 @@ open FsCheck
|
||||||
open FsCheck.Xunit
|
open FsCheck.Xunit
|
||||||
open System
|
open System
|
||||||
open OpenTK
|
open OpenTK
|
||||||
|
open OpenTK.Tests.Generators
|
||||||
|
|
||||||
module MathHelper =
|
module MathHelper =
|
||||||
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
||||||
|
|
|
@ -5,6 +5,7 @@ open FsCheck
|
||||||
open FsCheck.Xunit
|
open FsCheck.Xunit
|
||||||
open System
|
open System
|
||||||
open OpenTK
|
open OpenTK
|
||||||
|
open OpenTK.Tests.Generators
|
||||||
|
|
||||||
module Matrix4 =
|
module Matrix4 =
|
||||||
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
||||||
|
|
|
@ -62,8 +62,6 @@
|
||||||
-->
|
-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AssemblyInfo.fs" />
|
<Compile Include="AssemblyInfo.fs" />
|
||||||
<Compile Include="Assertions.fs" />
|
|
||||||
<Compile Include="Generators.fs" />
|
|
||||||
<Compile Include="MathHelperTests.fs" />
|
<Compile Include="MathHelperTests.fs" />
|
||||||
<Compile Include="Matrix4Tests.fs" />
|
<Compile Include="Matrix4Tests.fs" />
|
||||||
<Compile Include="Vector2Tests.fs" />
|
<Compile Include="Vector2Tests.fs" />
|
||||||
|
@ -74,6 +72,10 @@
|
||||||
<None Include="paket.references" />
|
<None Include="paket.references" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\OpenTK.Tests.Generators\OpenTK.Tests.Generators.fsproj">
|
||||||
|
<Project>{2b11aaeb-d8ac-4356-938f-532d720e0c30}</Project>
|
||||||
|
<Name>OpenTK.Tests.Generators</Name>
|
||||||
|
</ProjectReference>
|
||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
|
|
@ -6,6 +6,7 @@ open FsCheck.Xunit
|
||||||
open System
|
open System
|
||||||
open System.Runtime.InteropServices
|
open System.Runtime.InteropServices
|
||||||
open OpenTK
|
open OpenTK
|
||||||
|
open OpenTK.Tests.Generators
|
||||||
|
|
||||||
module Vector2 =
|
module Vector2 =
|
||||||
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
||||||
|
|
|
@ -6,6 +6,7 @@ open FsCheck.Xunit
|
||||||
open System
|
open System
|
||||||
open System.Runtime.InteropServices
|
open System.Runtime.InteropServices
|
||||||
open OpenTK
|
open OpenTK
|
||||||
|
open OpenTK.Tests.Generators
|
||||||
|
|
||||||
module Vector3 =
|
module Vector3 =
|
||||||
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
||||||
|
|
|
@ -6,6 +6,7 @@ open FsCheck.Xunit
|
||||||
open System
|
open System
|
||||||
open System.Runtime.InteropServices
|
open System.Runtime.InteropServices
|
||||||
open OpenTK
|
open OpenTK
|
||||||
|
open OpenTK.Tests.Generators
|
||||||
|
|
||||||
module Vector4 =
|
module Vector4 =
|
||||||
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
[<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
|
||||||
|
|
Loading…
Reference in a new issue