Make `make test` test the documentation examples too.

This commit is contained in:
Sébastien Crozet 2014-01-19 16:16:12 +01:00
parent 79008262cb
commit 5463da79ae
4 changed files with 35 additions and 31 deletions

View File

@ -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

View File

@ -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
```

View File

@ -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
```

View File

@ -113,12 +113,12 @@ pub fn perspective3d<N: Real + Cast<f32> + 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<V, M: Translation<V>>(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<V, M: Translation<V>>(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<V, M: Translation<V>>(m: &M, v: &V) -> M {
Translation::append_translation_cpy(m, v)
@ -164,7 +164,7 @@ pub fn append_translation<V, M: Translation<V>>(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<V, M: Translate<V>>(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<V, M: Translate<V>>(m: &M, v: &V) -> V {
@ -209,10 +209,10 @@ pub fn inv_translate<V, M: Translate<V>>(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<V, M: Rotation<V>>(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<V, M: Rotation<V>>(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<V, M: Rotation<V>>(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<V, M: Rotation<V>>(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<V, M: Rotate<V>>(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)]