follow 4-space indent idiom
This commit is contained in:
parent
08c37897c0
commit
32c8cd6a2d
|
|
@ -5,7 +5,7 @@ you have to do is mark a function as a test and include some asserts like so:
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
#[test]
|
#[test]
|
||||||
fn my_test() {
|
fn my_test() {
|
||||||
assert!(2+2 == 4);
|
assert!(2+2 == 4);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -16,14 +16,15 @@ can even put tests inside private modules:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
mod my_priv_mod {
|
mod my_priv_mod {
|
||||||
fn my_priv_func() -> bool {}
|
fn my_priv_func() -> bool {}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_priv_func() {
|
fn test_priv_func() {
|
||||||
assert!(my_priv_func());
|
assert!(my_priv_func());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Private items can thus be easily tested without worrying about how to expose
|
Private items can thus be easily tested without worrying about how to expose
|
||||||
them to any sort of external testing apparatus. This is key to the
|
them to any sort of external testing apparatus. This is key to the
|
||||||
ergonomics of testing in Rust. Semantically, however, it's rather odd.
|
ergonomics of testing in Rust. Semantically, however, it's rather odd.
|
||||||
|
|
@ -44,15 +45,15 @@ the above example into:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
mod my_priv_mod {
|
mod my_priv_mod {
|
||||||
fn my_priv_func() -> bool {}
|
fn my_priv_func() -> bool {}
|
||||||
|
|
||||||
pub fn test_priv_func() {
|
pub fn test_priv_func() {
|
||||||
assert!(my_priv_func());
|
assert!(my_priv_func());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod __test_reexports {
|
pub mod __test_reexports {
|
||||||
pub use super::test_priv_func;
|
pub use super::test_priv_func;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -83,8 +84,8 @@ something with them. `librustc_ast` generates a module like so:
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
#[main]
|
#[main]
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
extern crate test;
|
extern crate test;
|
||||||
test::test_main_static(&[&path::to::test1, /*...*/]);
|
test::test_main_static(&[&path::to::test1, /*...*/]);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -108,7 +109,7 @@ looks something like this:
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn foo() {
|
fn foo() {
|
||||||
panic!("intentional");
|
panic!("intentional");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue