From 4515c9f7e039eb3526b666e8e20293c2dccf53ab Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sat, 1 Dec 2012 22:55:14 +1000 Subject: [PATCH] Remove unwrap operators --- src/test/test_angle.rs | 68 +++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/test/test_angle.rs b/src/test/test_angle.rs index a2750b9..3624899 100644 --- a/src/test/test_angle.rs +++ b/src/test/test_angle.rs @@ -7,35 +7,35 @@ use vec::{Vec3, Vec4}; #[test] fn test_radians() { assert Radians(0.0).to_degrees() == Degrees(0.0); - assert *Radians(pi / 4.0).to_degrees() == *Degrees(45.0); // Removing the unwrap operators causes an ICE. - assert *Radians(pi / 2.0).to_degrees() == *Degrees(90.0); // I think it only happens on operations where - assert *Radians(pi).to_degrees() == *Degrees(180.0); // Rust has to do a bit of type inference. - assert *Radians(2.0 * pi).to_degrees() == *Degrees(360.0); - assert *Radians(5.0 * pi).to_degrees() == *Degrees(900.0); - assert *Radians(-pi).to_degrees() == *Degrees(-180.0); + assert Radians(pi / 4.0).to_degrees() == Degrees(45.0); + assert Radians(pi / 2.0).to_degrees() == Degrees(90.0); + assert Radians(pi).to_degrees() == Degrees(180.0); + assert Radians(2.0 * pi).to_degrees() == Degrees(360.0); + assert Radians(5.0 * pi).to_degrees() == Degrees(900.0); + assert Radians(-pi).to_degrees() == Degrees(-180.0); assert Radians(0.0).to_radians() == Radians(0.0); - assert *Radians(5.0 * pi).to_radians() == *Radians(5.0 * pi); - assert *Radians(-pi).to_radians() == *Radians(-pi); + assert Radians(5.0 * pi).to_radians() == Radians(5.0 * pi); + assert Radians(-pi).to_radians() == Radians(-pi); - assert *Radians(pi).wrap() == *Radians(pi); - assert *Radians(3.0 * pi).wrap() == *Radians(pi); - assert *Radians(2.0 * pi).wrap() == *Radians(0.0); - assert *Radians(-pi).wrap() == *Radians(-pi); // FIXME: should be in the domain of 0 to two_pi - assert *Radians(-3.0 * pi).wrap() == *Radians(-pi); // FIXME: should be in the domain of 0 to two_pi - assert *Radians(-2.0 * pi).wrap() == *Radians(0.0); + assert Radians(pi).wrap() == Radians(pi); + assert Radians(3.0 * pi).wrap() == Radians(pi); + assert Radians(2.0 * pi).wrap() == Radians(0.0); + assert Radians(-pi).wrap() == Radians(-pi); // FIXME: should be in the domain of 0 to two_pi + assert Radians(-3.0 * pi).wrap() == Radians(-pi); // FIXME: should be in the domain of 0 to two_pi + assert Radians(-2.0 * pi).wrap() == Radians(0.0); - assert *Radians(0.0).opposite() == *Radians(pi as float); - assert *Radians(pi / 2.0).opposite() == *Radians((pi / 2.0) * 3.0); - assert *Radians(pi * 3.0).opposite() == *Radians(0.0); - assert *Radians(-2.0 * pi).opposite() == *Radians(-pi); // FIXME: should be in the domain of 0 to two_pi + assert Radians(0.0).opposite() == Radians(pi as float); + assert Radians(pi / 2.0).opposite() == Radians((pi / 2.0) * 3.0); + assert Radians(pi * 3.0).opposite() == Radians(0.0); + assert Radians(-2.0 * pi).opposite() == Radians(-pi); // FIXME: should be in the domain of 0 to two_pi - assert *(Radians(pi) + Radians(pi)) == *Radians(2.0 * pi); - assert *(Radians(2.0 * pi) - Radians(pi)) == *Radians(pi); - assert *(Radians(pi) * 2.0) == *Radians(2.0 * pi); - assert *(Radians(pi) / 2.0) == *Radians(pi / 2.0); - assert *(Radians(3.0 * pi) % (2.0 * pi)) == *Radians(pi); - assert *(-Radians(pi)) == *Radians(-pi); + assert Radians(pi) + Radians(pi) == Radians(2.0 * pi); + assert Radians(2.0 * pi) - Radians(pi) == Radians(pi); + assert Radians(pi) * 2.0 == Radians(2.0 * pi); + assert Radians(pi) / 2.0 == Radians(pi / 2.0); + assert Radians(3.0 * pi) % (2.0 * pi) == Radians(pi); + assert -Radians(pi) == Radians(-pi); assert fmt!("%s", Radians(1).to_str()) == ~"1 rad"; } @@ -61,17 +61,17 @@ fn test_degrees() { assert Degrees(-450.0).wrap() == Degrees(-90.0); // FIXME: should be in the domain of 0 to 360 assert Degrees(-360.0).wrap() == Degrees(0.0); - assert Degrees(0.0).opposite() == Degrees(180.0); - assert Degrees(90.0).opposite() == Degrees(270.0); - assert Degrees(540.0).opposite() == Degrees(0.0); - assert Degrees(-360.0).opposite() == Degrees(-180.0); // FIXME: should be in the domain of 0 to 360 + assert Degrees(0.0).opposite() == Degrees(180.0); + assert Degrees(90.0).opposite() == Degrees(270.0); + assert Degrees(540.0).opposite() == Degrees(0.0); + assert Degrees(-360.0).opposite() == Degrees(-180.0); // FIXME: should be in the domain of 0 to 360 - assert (Degrees(180.0) + Degrees(180.0)) == Degrees(360.0); - assert (Degrees(360.0) - Degrees(180.0)) == Degrees(180.0); - assert (Degrees(360.0) * 2.0) == Degrees(720.0); - assert (Degrees(180.0) / 2.0) == Degrees(90.0); - assert (Degrees(540.0) % (360.0)) == Degrees(180.0); - assert (-Degrees(180.0)) == Degrees(-180.0); + assert Degrees(180.0) + Degrees(180.0) == Degrees(360.0); + assert Degrees(360.0) - Degrees(180.0) == Degrees(180.0); + assert Degrees(360.0) * 2.0 == Degrees(720.0); + assert Degrees(180.0) / 2.0 == Degrees(90.0); + assert Degrees(540.0) % (360.0) == Degrees(180.0); + assert -Degrees(180.0) == Degrees(-180.0); assert fmt!("%s", Degrees(180.0).to_str()) == ~"180°"; }