Remove unwrap operators
This commit is contained in:
parent
4ce43ff18e
commit
4515c9f7e0
1 changed files with 34 additions and 34 deletions
|
@ -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";
|
||||
}
|
||||
|
@ -66,12 +66,12 @@ fn test_degrees() {
|
|||
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°";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue