diff --git a/src/cgmath.rs b/src/cgmath.rs index 6009a7f..b57986f 100644 --- a/src/cgmath.rs +++ b/src/cgmath.rs @@ -15,7 +15,7 @@ #![crate_type = "rlib"] #![crate_type = "dylib"] -#![feature(old_impl_check, plugin)] +#![feature(old_impl_check, plugin, core, std_misc)] //! Computer graphics-centric math. //! diff --git a/tests/aabb.rs b/tests/aabb.rs index f2386cf..3bc0870 100644 --- a/tests/aabb.rs +++ b/tests/aabb.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - - extern crate cgmath; use cgmath::{Aabb, Aabb2, Aabb3}; @@ -24,46 +22,46 @@ use cgmath::{Ray, Intersect}; #[test] fn test_aabb() { - let aabb = Aabb2::new(Point2::new(-20i, 30i), Point2::new(10i, -10i)); - assert_eq!(aabb.min(), &Point2::new(-20i, -10i)); - assert_eq!(aabb.max(), &Point2::new(10i, 30i)); - assert_eq!(aabb.dim(), Vector2::new(30i, 40i)); - assert_eq!(aabb.volume(), 30i * 40i); - assert_eq!(aabb.center(), Point2::new(-5i, 10i)); + let aabb = Aabb2::new(Point2::new(-20is, 30is), Point2::new(10is, -10is)); + assert_eq!(aabb.min(), &Point2::new(-20is, -10is)); + assert_eq!(aabb.max(), &Point2::new(10is, 30is)); + assert_eq!(aabb.dim(), Vector2::new(30is, 40is)); + assert_eq!(aabb.volume(), 30is * 40is); + assert_eq!(aabb.center(), Point2::new(-5is, 10is)); - assert!(aabb.contains(&Point2::new(0i, 0i))); - assert!(!aabb.contains(&Point2::new(-50i, -50i))); - assert!(!aabb.contains(&Point2::new(50i, 50i))); + assert!(aabb.contains(&Point2::new(0is, 0is))); + assert!(!aabb.contains(&Point2::new(-50is, -50is))); + assert!(!aabb.contains(&Point2::new(50is, 50is))); - assert_eq!(aabb.grow(&Point2::new(0i, 0i)), aabb); - assert_eq!(aabb.grow(&Point2::new(100i, 100i)), - Aabb2::new(Point2::new(-20i, -10i), Point2::new(100i, 100i))); - assert_eq!(aabb.grow(&Point2::new(-100i, -100i)), - Aabb2::new(Point2::new(-100i, -100i), Point2::new(10i, 30i))); + assert_eq!(aabb.grow(&Point2::new(0is, 0is)), aabb); + assert_eq!(aabb.grow(&Point2::new(100is, 100is)), + Aabb2::new(Point2::new(-20is, -10is), Point2::new(100is, 100is))); + assert_eq!(aabb.grow(&Point2::new(-100is, -100is)), + Aabb2::new(Point2::new(-100is, -100is), Point2::new(10is, 30is))); - let aabb = Aabb3::new(Point3::new(-20i, 30i, 5i), Point3::new(10i, -10i, -5i)); - assert_eq!(aabb.min(), &Point3::new(-20i, -10i, -5i)); - assert_eq!(aabb.max(), &Point3::new(10i, 30i, 5i)); - assert_eq!(aabb.dim(), Vector3::new(30i, 40i, 10i)); - assert_eq!(aabb.volume(), 30i * 40i * 10i); - assert_eq!(aabb.center(), Point3::new(-5i, 10i, 0i)); + let aabb = Aabb3::new(Point3::new(-20is, 30is, 5is), Point3::new(10is, -10is, -5is)); + assert_eq!(aabb.min(), &Point3::new(-20is, -10is, -5is)); + assert_eq!(aabb.max(), &Point3::new(10is, 30is, 5is)); + assert_eq!(aabb.dim(), Vector3::new(30is, 40is, 10is)); + assert_eq!(aabb.volume(), 30is * 40is * 10is); + assert_eq!(aabb.center(), Point3::new(-5is, 10is, 0is)); - assert!(aabb.contains(&Point3::new(0i, 0i, 0i))); - assert!(!aabb.contains(&Point3::new(-100i, 0i, 0i))); - assert!(!aabb.contains(&Point3::new(100i, 0i, 0i))); - assert!(aabb.contains(&Point3::new(9i, 29i, -1i))); - assert!(!aabb.contains(&Point3::new(10i, 30i, 5i))); - assert!(aabb.contains(&Point3::new(-20i, -10i, -5i))); - assert!(!aabb.contains(&Point3::new(-21i, -11i, -6i))); + assert!(aabb.contains(&Point3::new(0is, 0is, 0is))); + assert!(!aabb.contains(&Point3::new(-100is, 0is, 0is))); + assert!(!aabb.contains(&Point3::new(100is, 0is, 0is))); + assert!(aabb.contains(&Point3::new(9is, 29is, -1is))); + assert!(!aabb.contains(&Point3::new(10is, 30is, 5is))); + assert!(aabb.contains(&Point3::new(-20is, -10is, -5is))); + assert!(!aabb.contains(&Point3::new(-21is, -11is, -6is))); - assert_eq!(aabb.add_v(&Vector3::new(1i, 2i, 3i)), - Aabb3::new(Point3::new(-19i, 32i, 8i), Point3::new(11i, -8i, -2i))); + assert_eq!(aabb.add_v(&Vector3::new(1is, 2is, 3is)), + Aabb3::new(Point3::new(-19is, 32is, 8is), Point3::new(11is, -8is, -2is))); - assert_eq!(aabb.mul_s(2i), - Aabb3::new(Point3::new(-40i, -20i, -10i), Point3::new(20i, 60i, 10i))); + assert_eq!(aabb.mul_s(2is), + Aabb3::new(Point3::new(-40is, -20is, -10is), Point3::new(20is, 60is, 10is))); - assert_eq!(aabb.mul_v(&Vector3::new(1i, 2i, 3i)), - Aabb3::new(Point3::new(-20i, -20i, -15i), Point3::new(10i, 60i, 15i))); + assert_eq!(aabb.mul_v(&Vector3::new(1is, 2is, 3is)), + Aabb3::new(Point3::new(-20is, -20is, -15is), Point3::new(10is, 60is, 15is))); } #[test] diff --git a/tests/angle.rs b/tests/angle.rs index b07e9bf..8e2b028 100644 --- a/tests/angle.rs +++ b/tests/angle.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - - extern crate cgmath; use cgmath::{Angle, Rad, Deg, rad, deg}; diff --git a/tests/approx.rs b/tests/approx.rs index c4964f7..c5194cc 100644 --- a/tests/approx.rs +++ b/tests/approx.rs @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - #[macro_use] extern crate cgmath; diff --git a/tests/line.rs b/tests/line.rs index 8f9611d..280b38a 100644 --- a/tests/line.rs +++ b/tests/line.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::*; diff --git a/tests/matrix.rs b/tests/matrix.rs index 163de3d..5e698cb 100644 --- a/tests/matrix.rs +++ b/tests/matrix.rs @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(core)] extern crate cgmath; diff --git a/tests/plane.rs b/tests/plane.rs index 11861a2..48ab8b8 100644 --- a/tests/plane.rs +++ b/tests/plane.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::*; diff --git a/tests/point.rs b/tests/point.rs index 6247eae..93f8047 100644 --- a/tests/point.rs +++ b/tests/point.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::Point3; diff --git a/tests/projection.rs b/tests/projection.rs index 7e4d788..94cf3f8 100644 --- a/tests/projection.rs +++ b/tests/projection.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(core)] + extern crate cgmath; use cgmath::{Vector4, ortho, Matrix, Matrix4, Vector}; diff --git a/tests/quaternion.rs b/tests/quaternion.rs index 6440ed1..b0bb90b 100644 --- a/tests/quaternion.rs +++ b/tests/quaternion.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::{ToMatrix4, ToMatrix3}; diff --git a/tests/sphere.rs b/tests/sphere.rs index c12e611..b54ab83 100644 --- a/tests/sphere.rs +++ b/tests/sphere.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::*; diff --git a/tests/transform.rs b/tests/transform.rs index fb0d85c..25d68f9 100644 --- a/tests/transform.rs +++ b/tests/transform.rs @@ -14,7 +14,6 @@ // limitations under the License. - extern crate cgmath; use cgmath::*; diff --git a/tests/vector.rs b/tests/vector.rs index 9c5a36c..848e963 100644 --- a/tests/vector.rs +++ b/tests/vector.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(core)] + #[macro_use] extern crate cgmath; @@ -29,23 +31,23 @@ fn test_constructor() { #[test] fn test_from_value() { - assert_eq!(Vector2::from_value(102i), Vector2::new(102i, 102i)); - assert_eq!(Vector3::from_value(22i), Vector3::new(22i, 22i, 22i)); + assert_eq!(Vector2::from_value(102is), Vector2::new(102is, 102is)); + assert_eq!(Vector3::from_value(22is), Vector3::new(22is, 22is, 22is)); assert_eq!(Vector4::from_value(76.5f64), Vector4::new(76.5f64, 76.5f64, 76.5f64, 76.5f64)); } #[test] fn test_dot() { - assert_eq!(Vector2::new(1i, 2i).dot(&Vector2::new(3i, 4i)), 11i); - assert_eq!(Vector3::new(1i, 2i, 3i).dot(&Vector3::new(4i, 5i, 6i)), 32i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).dot(&Vector4::new(5i, 6i, 7i, 8i)), 70i); + assert_eq!(Vector2::new(1is, 2is).dot(&Vector2::new(3is, 4is)), 11is); + assert_eq!(Vector3::new(1is, 2is, 3is).dot(&Vector3::new(4is, 5is, 6is)), 32is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).dot(&Vector4::new(5is, 6is, 7is, 8is)), 70is); } #[test] fn test_comp_add() { - assert_eq!(Vector2::new(1i, 2i).comp_add(), 3i); - assert_eq!(Vector3::new(1i, 2i, 3i).comp_add(), 6i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).comp_add(), 10i); + assert_eq!(Vector2::new(1is, 2is).comp_add(), 3is); + assert_eq!(Vector3::new(1is, 2is, 3is).comp_add(), 6is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).comp_add(), 10is); assert_eq!(Vector2::new(3.0f64, 4.0f64).comp_add(), 7.0f64); assert_eq!(Vector3::new(4.0f64, 5.0f64, 6.0f64).comp_add(), 15.0f64); @@ -54,9 +56,9 @@ fn test_comp_add() { #[test] fn test_comp_mul() { - assert_eq!(Vector2::new(1i, 2i).comp_mul(), 2i); - assert_eq!(Vector3::new(1i, 2i, 3i).comp_mul(), 6i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).comp_mul(), 24i); + assert_eq!(Vector2::new(1is, 2is).comp_mul(), 2is); + assert_eq!(Vector3::new(1is, 2is, 3is).comp_mul(), 6is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).comp_mul(), 24is); assert_eq!(Vector2::new(3.0f64, 4.0f64).comp_mul(), 12.0f64); assert_eq!(Vector3::new(4.0f64, 5.0f64, 6.0f64).comp_mul(), 120.0f64); @@ -65,9 +67,9 @@ fn test_comp_mul() { #[test] fn test_comp_min() { - assert_eq!(Vector2::new(1i, 2i).comp_min(), 1i); - assert_eq!(Vector3::new(1i, 2i, 3i).comp_min(), 1i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).comp_min(), 1i); + assert_eq!(Vector2::new(1is, 2is).comp_min(), 1is); + assert_eq!(Vector3::new(1is, 2is, 3is).comp_min(), 1is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).comp_min(), 1is); assert_eq!(Vector2::new(3.0f64, 4.0f64).comp_min(), 3.0f64); assert_eq!(Vector3::new(4.0f64, 5.0f64, 6.0f64).comp_min(), 4.0f64); @@ -76,9 +78,9 @@ fn test_comp_min() { #[test] fn test_comp_max() { - assert_eq!(Vector2::new(1i, 2i).comp_max(), 2i); - assert_eq!(Vector3::new(1i, 2i, 3i).comp_max(), 3i); - assert_eq!(Vector4::new(1i, 2i, 3i, 4i).comp_max(), 4i); + assert_eq!(Vector2::new(1is, 2is).comp_max(), 2is); + assert_eq!(Vector3::new(1is, 2is, 3is).comp_max(), 3is); + assert_eq!(Vector4::new(1is, 2is, 3is, 4is).comp_max(), 4is); assert_eq!(Vector2::new(3.0f64, 4.0f64).comp_max(), 4.0f64); assert_eq!(Vector3::new(4.0f64, 5.0f64, 6.0f64).comp_max(), 6.0f64); @@ -87,9 +89,9 @@ fn test_comp_max() { #[test] fn test_cross() { - let a = Vector3::new(1i, 2i, 3i); - let b = Vector3::new(4i, 5i, 6i); - let r = Vector3::new(-3i, 6i, -3i); + let a = Vector3::new(1is, 2is, 3is); + let b = Vector3::new(4is, 5is, 6is); + let r = Vector3::new(-3is, 6is, -3is); assert_eq!(a.cross(&b), r); let mut a = a; @@ -110,8 +112,8 @@ mod test_length { #[test] fn test_vector2(){ - let (a, a_res) = (Vector2::new(3.0f64, 4.0f64), 5.0f64); // (3i, 4i, 5i) Pythagorean triple - let (b, b_res) = (Vector2::new(5.0f64, 12.0f64), 13.0f64); // (5i, 12i, 13i) Pythagorean triple + let (a, a_res) = (Vector2::new(3.0f64, 4.0f64), 5.0f64); // (3is, 4is, 5is) Pythagorean triple + let (b, b_res) = (Vector2::new(5.0f64, 12.0f64), 13.0f64); // (5is, 12is, 13is) Pythagorean triple assert_eq!(a.length2(), a_res * a_res); assert_eq!(b.length2(), b_res * b_res); @@ -122,8 +124,8 @@ mod test_length { #[test] fn test_vector3(){ - let (a, a_res) = (Vector3::new(2.0f64, 3.0f64, 6.0f64), 7.0f64); // (2i, 3i, 6i, 7i) Pythagorean quadruple - let (b, b_res) = (Vector3::new(1.0f64, 4.0f64, 8.0f64), 9.0f64); // (1i, 4i, 8i, 9i) Pythagorean quadruple + let (a, a_res) = (Vector3::new(2.0f64, 3.0f64, 6.0f64), 7.0f64); // (2is, 3is, 6is, 7is) Pythagorean quadruple + let (b, b_res) = (Vector3::new(1.0f64, 4.0f64, 8.0f64), 9.0f64); // (1is, 4is, 8is, 9is) Pythagorean quadruple assert_eq!(a.length2(), a_res * a_res); assert_eq!(b.length2(), b_res * b_res); @@ -134,8 +136,8 @@ mod test_length { #[test] fn test_vector4(){ - let (a, a_res) = (Vector4::new(1.0f64, 2.0f64, 4.0f64, 10.0f64), 11.0f64); // (1i, 2i, 4i, 10i, 11i) Pythagorean quintuple - let (b, b_res) = (Vector4::new(1.0f64, 2.0f64, 8.0f64, 10.0f64), 13.0f64); // (1i, 2i, 8i, 10i, 13i) Pythagorean quintuple + let (a, a_res) = (Vector4::new(1.0f64, 2.0f64, 4.0f64, 10.0f64), 11.0f64); // (1is, 2is, 4is, 10is, 11is) Pythagorean quintuple + let (b, b_res) = (Vector4::new(1.0f64, 2.0f64, 8.0f64, 10.0f64), 13.0f64); // (1is, 2is, 8is, 10is, 13is) Pythagorean quintuple assert_eq!(a.length2(), a_res * a_res); assert_eq!(b.length2(), b_res * b_res);