Skip to content

Commit d3f1ef2

Browse files
tshepangmark-i-m
authored andcommitted
follow 4-space indent idiom
1 parent ce08bcc commit d3f1ef2

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/test-implementation.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ you have to do is mark a function as a test and include some asserts like so:
55
```rust,ignore
66
#[test]
77
fn my_test() {
8-
assert!(2+2 == 4);
8+
assert!(2+2 == 4);
99
}
1010
```
1111

@@ -16,14 +16,15 @@ can even put tests inside private modules:
1616

1717
```rust,ignore
1818
mod my_priv_mod {
19-
fn my_priv_func() -> bool {}
19+
fn my_priv_func() -> bool {}
2020
21-
#[test]
22-
fn test_priv_func() {
23-
assert!(my_priv_func());
24-
}
21+
#[test]
22+
fn test_priv_func() {
23+
assert!(my_priv_func());
24+
}
2525
}
2626
```
27+
2728
Private items can thus be easily tested without worrying about how to expose
2829
them to any sort of external testing apparatus. This is key to the
2930
ergonomics of testing in Rust. Semantically, however, it's rather odd.
@@ -44,15 +45,15 @@ the above example into:
4445

4546
```rust,ignore
4647
mod my_priv_mod {
47-
fn my_priv_func() -> bool {}
48+
fn my_priv_func() -> bool {}
4849
49-
pub fn test_priv_func() {
50-
assert!(my_priv_func());
51-
}
50+
pub fn test_priv_func() {
51+
assert!(my_priv_func());
52+
}
5253
53-
pub mod __test_reexports {
54-
pub use super::test_priv_func;
55-
}
54+
pub mod __test_reexports {
55+
pub use super::test_priv_func;
56+
}
5657
}
5758
```
5859

@@ -83,8 +84,8 @@ something with them. `librustc_ast` generates a module like so:
8384
```rust,ignore
8485
#[main]
8586
pub fn main() {
86-
extern crate test;
87-
test::test_main_static(&[&path::to::test1, /*...*/]);
87+
extern crate test;
88+
test::test_main_static(&[&path::to::test1, /*...*/]);
8889
}
8990
```
9091

@@ -108,7 +109,7 @@ looks something like this:
108109
#[test]
109110
#[should_panic]
110111
fn foo() {
111-
panic!("intentional");
112+
panic!("intentional");
112113
}
113114
```
114115

0 commit comments

Comments
 (0)