2017-03-19 13:35:46 +00:00
|
|
|
namespace OpenTK.Tests
|
|
|
|
|
|
|
|
open Xunit
|
|
|
|
open FsCheck
|
|
|
|
open FsCheck.Xunit
|
|
|
|
open System
|
|
|
|
open OpenTK
|
|
|
|
|
|
|
|
[<AutoOpen>]
|
2017-06-01 19:12:59 +00:00
|
|
|
module private Generators =
|
2017-03-19 13:35:46 +00:00
|
|
|
let private isValidFloat f = not (Single.IsNaN f || Single.IsInfinity f || Single.IsInfinity (f * f) || f = Single.MinValue || f = Single.MaxValue )
|
|
|
|
let private isValidDouble d = not (Double.IsNaN d || Double.IsInfinity d || Double.IsInfinity (d * d)|| d = Double.MinValue || d = Double.MaxValue)
|
|
|
|
let singleArb = Arb.Default.Float32() |> Arb.toGen |> Gen.filter isValidFloat
|
|
|
|
let single = singleArb |> Arb.fromGen
|
2017-06-01 19:12:59 +00:00
|
|
|
|
|
|
|
let double =
|
2017-03-19 13:35:46 +00:00
|
|
|
Arb.Default.Float() |> Arb.toGen
|
|
|
|
|> Gen.filter isValidDouble
|
|
|
|
|> Arb.fromGen
|
2017-06-01 19:12:59 +00:00
|
|
|
|
|
|
|
let vec2 =
|
2017-03-19 13:35:46 +00:00
|
|
|
singleArb
|
|
|
|
|> Gen.two
|
|
|
|
|> Gen.map Vector2
|
|
|
|
|> Arb.fromGen
|
2017-06-01 19:12:59 +00:00
|
|
|
|
|
|
|
let vec3 =
|
2017-03-19 13:35:46 +00:00
|
|
|
singleArb
|
|
|
|
|> Gen.three
|
|
|
|
|> Gen.map Vector3
|
|
|
|
|> Arb.fromGen
|
2017-06-01 19:12:59 +00:00
|
|
|
|
|
|
|
let vec4 =
|
2017-03-19 13:35:46 +00:00
|
|
|
singleArb
|
|
|
|
|> Gen.four
|
|
|
|
|> Gen.map Vector4
|
|
|
|
|> Arb.fromGen
|
2017-06-01 19:12:59 +00:00
|
|
|
|
|
|
|
let quat =
|
2017-03-19 13:35:46 +00:00
|
|
|
singleArb
|
2017-06-01 21:22:57 +00:00
|
|
|
|> Gen.three
|
|
|
|
|> Gen.map (fun (x,y,z) -> Quaternion(x,y,z,0.0f) |> Quaternion.Normalize)
|
2017-06-02 08:39:13 +00:00
|
|
|
|> Gen.filter (fun q -> not <| (Single.IsNaN q.Length || Single.IsInfinity q.Length ))
|
2017-03-19 13:35:46 +00:00
|
|
|
|> Arb.fromGen
|
2017-06-01 19:12:59 +00:00
|
|
|
|
|
|
|
let mat2 =
|
2017-03-19 13:35:46 +00:00
|
|
|
singleArb
|
|
|
|
|> Gen.four
|
|
|
|
|> Gen.map Matrix2
|
|
|
|
|> Arb.fromGen
|
2017-06-01 19:12:59 +00:00
|
|
|
|
|
|
|
let mat3 =
|
2017-03-19 13:35:46 +00:00
|
|
|
vec3
|
|
|
|
|> Arb.toGen
|
|
|
|
|> Gen.three
|
|
|
|
|> Gen.map Matrix3
|
|
|
|
|> Arb.fromGen
|
2017-06-01 19:12:59 +00:00
|
|
|
|
|
|
|
let mat4 =
|
2017-03-19 13:35:46 +00:00
|
|
|
vec4
|
|
|
|
|> Arb.toGen
|
|
|
|
|> Gen.four
|
|
|
|
|> Gen.map Matrix4
|
|
|
|
|> Arb.fromGen
|
|
|
|
|
2017-06-01 19:12:59 +00:00
|
|
|
type OpenTKGen =
|
2017-03-19 13:35:46 +00:00
|
|
|
static member Single() = single
|
|
|
|
static member float32() = single
|
|
|
|
static member Double() = double
|
|
|
|
static member float() = double
|
|
|
|
static member Vector2() = vec2
|
|
|
|
static member Vector3() = vec3
|
|
|
|
static member Vector4() = vec4
|
|
|
|
static member Quaternion() = quat
|
|
|
|
static member Matrix2() = mat2
|
|
|
|
static member Matrix3() = mat3
|
|
|
|
static member Matrix4() = mat4
|