From 87dcb3144a85e5c397c188b17c7a2f50d46cf3ca Mon Sep 17 00:00:00 2001 From: varon Date: Fri, 2 Jun 2017 13:48:29 +0200 Subject: [PATCH] Fix compile inference error under VS2015 --- tests/OpenTK.Tests/Assertions.fs | 3 +++ tests/OpenTK.Tests/Matrix4Tests.fs | 28 ++++++++++++++++------------ tests/OpenTK.Tests/Vector2Tests.fs | 19 ++++--------------- tests/OpenTK.Tests/Vector3Tests.fs | 8 ++++---- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/tests/OpenTK.Tests/Assertions.fs b/tests/OpenTK.Tests/Assertions.fs index e4e1c41..f47e7ee 100644 --- a/tests/OpenTK.Tests/Assertions.fs +++ b/tests/OpenTK.Tests/Assertions.fs @@ -29,3 +29,6 @@ type internal Assert = static member ApproximatelyEqual(a : float32,b : float32) = if not <| approxEq a b then raise <| new Xunit.Sdk.EqualException(a,b) + + + static member ThrowsIndexExn(f:unit -> unit) = Assert.Throws(f) |> ignore diff --git a/tests/OpenTK.Tests/Matrix4Tests.fs b/tests/OpenTK.Tests/Matrix4Tests.fs index a025d7e..706a839 100644 --- a/tests/OpenTK.Tests/Matrix4Tests.fs +++ b/tests/OpenTK.Tests/Matrix4Tests.fs @@ -333,31 +333,35 @@ module Matrix4 = Assert.Equal(o, A.[3, 2]) Assert.Equal(p, A.[3, 3]) + [] let ``Indexed set operator throws exception for negative indices`` (b : Matrix4, x : float32) = let mutable a = b - (fun() -> a.[-1, 2] <- x) |> Assert.Throws |> ignore - (fun() -> a.[1, -2] <- x) |> Assert.Throws |> ignore - (fun() -> a.[-1, -2] <- x) |> Assert.Throws |> ignore + + + + (fun() -> a.[-1, 2] <- x) |> Assert.ThrowsIndexExn + (fun() -> a.[1, -2] <- x) |> Assert.ThrowsIndexExn + (fun() -> a.[-1, -2] <- x) |> Assert.ThrowsIndexExn [] let ``Indexed get operator throws exception for negative indices`` (a : Matrix4) = - (fun() -> a.[-1, 2] |> ignore) |> Assert.Throws |> ignore - (fun() -> a.[1, -2] |> ignore) |> Assert.Throws |> ignore - (fun() -> a.[-1, -2] |> ignore) |> Assert.Throws |> ignore + (fun() -> a.[-1, 2] |> ignore) |> Assert.ThrowsIndexExn + (fun() -> a.[1, -2] |> ignore) |> Assert.ThrowsIndexExn + (fun() -> a.[-1, -2] |> ignore) |> Assert.ThrowsIndexExn [] let ``Indexed set operator throws exception for large indices`` (a : Matrix4, x : float32) = let mutable b = a - (fun() -> b.[5, 2] <- x) |> Assert.Throws |> ignore - (fun() -> b.[1, 6] <- x) |> Assert.Throws |> ignore - (fun() -> b.[7, 12] <- x) |> Assert.Throws |> ignore + (fun() -> b.[5, 2] <- x) |> Assert.ThrowsIndexExn + (fun() -> b.[1, 6] <- x) |> Assert.ThrowsIndexExn + (fun() -> b.[7, 12] <- x) |> Assert.ThrowsIndexExn [] let ``Indexed get operator throws exception for large indices`` (a : Matrix4) = - (fun() -> a.[5, 2] |> ignore) |> Assert.Throws |> ignore - (fun() -> a.[1, 6] |> ignore) |> Assert.Throws |> ignore - (fun() -> a.[7, 12] |> ignore) |> Assert.Throws |> ignore + (fun() -> a.[5, 2] |> ignore) |> Assert.ThrowsIndexExn + (fun() -> a.[1, 6] |> ignore) |> Assert.ThrowsIndexExn + (fun() -> a.[7, 12] |> ignore) |> Assert.ThrowsIndexExn [ |])>] module ``Row and column properties`` = diff --git a/tests/OpenTK.Tests/Vector2Tests.fs b/tests/OpenTK.Tests/Vector2Tests.fs index fccdbc6..724bc55 100644 --- a/tests/OpenTK.Tests/Vector2Tests.fs +++ b/tests/OpenTK.Tests/Vector2Tests.fs @@ -106,25 +106,25 @@ module Vector2 = let ``Indexed set operator throws exception for negative indices`` (x, y) = let mutable v = Vector2(x, y) - (fun() -> v.[-1] <- x) |> Assert.Throws |> ignore + (fun() -> v.[-1] <- x) |> Assert.ThrowsIndexExn [] let ``Indexed get operator throws exception for negative indices`` (x, y) = let mutable v = Vector2(x, y) - (fun() -> v.[-1] |> ignore) |> Assert.Throws |> ignore + (fun() -> v.[-1] |> ignore) |> Assert.ThrowsIndexExn [] let ``Indexed set operator throws exception for large indices`` (x, y) = let mutable v = Vector2(x, y) - (fun() -> v.[2] <- x) |> Assert.Throws |> ignore + (fun() -> v.[2] <- x) |> Assert.ThrowsIndexExn [] let ``Indexed get operator throws exception for large indices`` (x, y) = let mutable v = Vector2(x, y) - (fun() -> v.[2] |> ignore) |> Assert.Throws |> ignore + (fun() -> v.[2] |> ignore) |> Assert.ThrowsIndexExn [ |])>] module ``Simple Properties`` = @@ -574,17 +574,6 @@ module Vector2 = Assert.Equal(transformedVector, Vector2.Transform(ref v, ref q)) -// TODO: Implement multiplication operator for Vector2 and Quaternion -// [] -// let ``Transformation by quaternion by multiplication using right-handed notation is the same as multiplication by quaternion and its conjugate`` (v : Vector2, q : Quaternion) = -// let vectorQuat = Quaternion(v.X, v.Y, 0.0f, 0.0f) -// let inverse = Quaternion.Invert(q) -// -// let transformedQuat = q * vectorQuat * inverse -// let transformedVector = Vector2(transformedQuat.X, transformedQuat.Y) -// -// Assert.Equal(transformedVector, q * v) - [ |])>] module Serialization = // diff --git a/tests/OpenTK.Tests/Vector3Tests.fs b/tests/OpenTK.Tests/Vector3Tests.fs index 851358c..9f89ba4 100644 --- a/tests/OpenTK.Tests/Vector3Tests.fs +++ b/tests/OpenTK.Tests/Vector3Tests.fs @@ -80,25 +80,25 @@ module Vector3 = let ``Indexed set operator throws exception for negative indices`` (x, y, z) = let mutable v = Vector3(x, y, z) - (fun() -> v.[-1] <- x) |> Assert.Throws |> ignore + (fun() -> v.[-1] <- x) |> Assert.ThrowsIndexExn [] let ``Indexed get operator throws exception for negative indices`` (x, y, z) = let mutable v = Vector3(x, y, z) - (fun() -> v.[-1] |> ignore) |> Assert.Throws |> ignore + (fun() -> v.[-1] |> ignore) |> Assert.ThrowsIndexExn [] let ``Indexed set operator throws exception for large indices`` (x, y, z) = let mutable v = Vector3(x, y, z) - (fun() -> v.[4] <- x) |> Assert.Throws |> ignore + (fun() -> v.[4] <- x) |> Assert.ThrowsIndexExn [] let ``Indexed get operator throws exception for large indices`` (x, y, z) = let mutable v = Vector3(x, y, z) - (fun() -> v.[4] |> ignore) |> Assert.Throws |> ignore + (fun() -> v.[4] |> ignore) |> Assert.ThrowsIndexExn [ |])>] module Length = -- 2.7.4