From 5463da79ae8ee3c99b44b8fdeeedfb19834a9bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 19 Jan 2014 16:16:12 +0100 Subject: [PATCH] Make `make test` test the documentation examples too. --- Makefile | 1 + README.md | 4 ++-- src/lib.rs | 4 ++-- src/na.rs | 57 ++++++++++++++++++++++++++++-------------------------- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index b778ea53..ae50943b 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ test: mkdir -p $(nalgebra_lib_path) rustc --test src/lib.rs --opt-level 3 -o test~ && ./test~ rm test~ + rustdoc --test -L lib src/lib.rs bench: rustc --test src/lib.rs --opt-level 3 -o bench~ && ./bench~ --bench diff --git a/README.md b/README.md index 7fed2991..c1fc801b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ out-of-place modifications. * You can import the whole prelude using: -```.rust +``` use nalgebra::na::*; ``` @@ -81,7 +81,7 @@ If you encounter problems, make sure you have the last version before creating a You can build the documentation on the `doc` folder using: -```.rust +``` make doc ``` diff --git a/src/lib.rs b/src/lib.rs index 001b2e0d..b7a79884 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ out-of-place modifications. * You can import the whole prelude using: -```.rust +``` use nalgebra::na::*; ``` @@ -82,7 +82,7 @@ If you encounter problems, make sure you have the last version before creating a You can build the documentation on the `doc` folder using: -```.rust +``` make doc ``` diff --git a/src/na.rs b/src/na.rs index feee5fb9..567f17d5 100644 --- a/src/na.rs +++ b/src/na.rs @@ -113,12 +113,12 @@ pub fn perspective3d + Zero + One>(width: N, height: N, fov: /// /// ```rust /// extern mod nalgebra; -/// use nalgebra::types::{Vec3, Iso3}; +/// use nalgebra::na::{Vec3, Iso3}; /// use nalgebra::na; /// -/// pub main() { +/// fn main() { /// let t = Iso3::new(Vec3::new(1.0, 1.0, 1.0), na::zero()); -/// let trans = na::translation(t); +/// let trans = na::translation(&t); /// /// assert!(trans == Vec3::new(1.0, 1.0, 1.0)); /// } @@ -132,12 +132,12 @@ pub fn translation>(m: &M) -> V { /// /// ```rust /// extern mod nalgebra; -/// use nalgebra::types::{Vec3, Iso3}; +/// use nalgebra::na::{Vec3, Iso3}; /// use nalgebra::na; /// -/// pub main() { +/// fn main() { /// let t = Iso3::new(Vec3::new(1.0, 1.0, 1.0), na::zero()); -/// let itrans = na::inv_translation(t); +/// let itrans = na::inv_translation(&t); /// /// assert!(itrans == Vec3::new(-1.0, -1.0, -1.0)); /// } @@ -147,7 +147,7 @@ pub fn inv_translation>(m: &M) -> V { m.inv_translation() } -/// Appied the translation `v` to a copy of `m`. +/// Applies the translation `v` to a copy of `m`. #[inline(always)] pub fn append_translation>(m: &M, v: &V) -> M { Translation::append_translation_cpy(m, v) @@ -164,7 +164,7 @@ pub fn append_translation>(m: &M, v: &V) -> M { /// use nalgebra::na::{Vec3, Iso3}; /// use nalgebra::na; /// -/// pub main() { +/// fn main() { /// let t = Iso3::new(Vec3::new(1.0, 1.0, 1.0), na::zero()); /// let v = Vec3::new(2.0, 2.0, 2.0); /// @@ -185,13 +185,13 @@ pub fn translate>(m: &M, v: &V) -> V { /// use nalgebra::na::{Vec3, Iso3}; /// use nalgebra::na; /// -/// pub main() { +/// fn main() { /// let t = Iso3::new(Vec3::new(1.0, 1.0, 1.0), na::zero()); /// let v = Vec3::new(2.0, 2.0, 2.0); /// /// let tv = na::translate(&t, &v); /// -/// assert!(tv == Vec3::new(1.0, 1.0, 1.0)) +/// assert!(tv == Vec3::new(3.0, 3.0, 3.0)) /// } #[inline(always)] pub fn inv_translate>(m: &M, v: &V) -> V { @@ -209,10 +209,10 @@ pub fn inv_translate>(m: &M, v: &V) -> V { /// use nalgebra::na::{Vec3, Rot3}; /// use nalgebra::na; /// -/// pub main() { +/// fn main() { /// let t = Rot3::new(Vec3::new(1.0, 1.0, 1.0)); /// -/// assert!(na::rotation(t) == Vec3::new(1.0, 1.0, 1.0)); +/// assert!(na::approx_eq(&na::rotation(&t), &Vec3::new(1.0, 1.0, 1.0))); /// } /// ``` #[inline(always)] @@ -228,10 +228,10 @@ pub fn rotation>(m: &M) -> V { /// use nalgebra::na::{Vec3, Rot3}; /// use nalgebra::na; /// -/// pub main() { +/// fn main() { /// let t = Rot3::new(Vec3::new(1.0, 1.0, 1.0)); /// -/// assert!(na::inv_rotation(t) == Vec3::new(-1.0, -1.0, -1.0)); +/// assert!(na::approx_eq(&na::inv_rotation(&t), &Vec3::new(-1.0, -1.0, -1.0))); /// } /// ``` #[inline(always)] @@ -247,12 +247,12 @@ pub fn inv_rotation>(m: &M) -> V { /// use nalgebra::na::{Vec3, Rot3}; /// use nalgebra::na; /// -/// pub main() { +/// fn main() { /// let t = Rot3::new(Vec3::new(0.0, 0.0, 0.0)); /// let v = Vec3::new(1.0, 1.0, 1.0); /// let rt = na::append_rotation(&t, &v); /// -/// assert!(na::rotation(&rt) == Vec3::new(1.0, 1.0, 1.0)) +/// assert!(na::approx_eq(&na::rotation(&rt), &Vec3::new(1.0, 1.0, 1.0))) /// } /// ``` #[inline(always)] @@ -268,12 +268,12 @@ pub fn append_rotation>(m: &M, v: &V) -> M { /// use nalgebra::na::{Vec3, Rot3}; /// use nalgebra::na; /// -/// pub main() { +/// fn main() { /// let t = Rot3::new(Vec3::new(0.0, 0.0, 0.0)); /// let v = Vec3::new(1.0, 1.0, 1.0); /// let rt = na::prepend_rotation(&t, &v); /// -/// assert!(na::rotation(&rt) == Vec3::new(1.0, 1.0, 1.0)) +/// assert!(na::approx_eq(&na::rotation(&rt), &Vec3::new(1.0, 1.0, 1.0))) /// } /// ``` #[inline(always)] @@ -289,16 +289,17 @@ pub fn prepend_rotation>(m: &M, v: &V) -> M { /// /// ```rust /// extern mod nalgebra; +/// use std::num::Real; /// use nalgebra::na::{Rot3, Vec3}; /// use nalgebra::na; /// -/// pub main() { -/// let t = Rot3::new(Vec3::new(1.0, 0.0, 0.0)); -/// let v = Vec3::new(0.0, 0.0, na::pi() / 2.0); +/// fn main() { +/// let t = Rot3::new(Vec3::new(0.0, 0.0, 0.5 * Real::pi())); +/// let v = Vec3::new(1.0, 0.0, 0.0); /// /// let tv = na::rotate(&t, &v); /// -/// assert!(tv == Vec3::new(0.0, 1.0, 0.0)) +/// assert!(na::approx_eq(&tv, &Vec3::new(0.0, 1.0, 0.0))) /// } /// ``` #[inline(always)] @@ -311,15 +312,17 @@ pub fn rotate>(m: &M, v: &V) -> V { /// /// ```rust /// extern mod nalgebra; +/// use std::num::Real; +/// use nalgebra::na::{Rot3, Vec3}; /// use nalgebra::na; /// -/// pub main() { -/// let t = Rot3::new(Vec3::new(1.0, 0.0, 0.0)); -/// let v = Vec3::new(0.0, 0.0, na::pi() / 2.0); +/// fn main() { +/// let t = Rot3::new(Vec3::new(0.0, 0.0, 0.5 * Real::pi())); +/// let v = Vec3::new(1.0, 0.0, 0.0); /// -/// let tv = na::rotate(&t, &v); +/// let tv = na::inv_rotate(&t, &v); /// -/// assert!(tv == Vec3::new(0.0, -1.0, 0.0)) +/// assert!(na::approx_eq(&tv, &Vec3::new(0.0, -1.0, 0.0))) /// } /// ``` #[inline(always)]