Skip to content

Commit 085aab5

Browse files
committed
---
yaml --- r: 97927 b: refs/heads/master c: 1ea0217 h: refs/heads/master i: 97925: 57b9759 97923: 6d08237 97919: fc3a7f5 v: v3
1 parent 7fe5025 commit 085aab5

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 77ec04487b9e9c2673ed78c88beddd469d5de7b7
2+
refs/heads/master: 1ea02170bddf9b9a684a1e22d5c5d9ff5af8bc71
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b6400f998497c3958f40997a71756ead344a776d
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36

trunk/doc/guide-testing.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
To create test functions, add a `#[test]` attribute like this:
66

7-
```rust
7+
~~~
88
fn return_two() -> int {
99
2
1010
}
@@ -14,17 +14,17 @@ fn return_two_test() {
1414
let x = return_two();
1515
assert!(x == 2);
1616
}
17-
```
17+
~~~
1818

1919
To run these tests, use `rustc --test`:
2020

21-
```
21+
~~~ {.notrust}
2222
$ rustc --test foo.rs; ./foo
2323
running 1 test
2424
test return_two_test ... ok
2525
2626
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
27-
```
27+
~~~
2828

2929
`rustc foo.rs` will *not* compile the tests, since `#[test]` implies
3030
`#[cfg(test)]`. The `--test` flag to `rustc` implies `--cfg test`.
@@ -35,12 +35,12 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
3535
Rust has built in support for simple unit testing. Functions can be
3636
marked as unit tests using the 'test' attribute.
3737

38-
```rust
38+
~~~
3939
#[test]
4040
fn return_none_if_empty() {
4141
// ... test code ...
4242
}
43-
```
43+
~~~
4444

4545
A test function's signature must have no arguments and no return
4646
value. To run the tests in a crate, it must be compiled with the
@@ -54,15 +54,15 @@ then the test fails.
5454
When compiling a crate with the '--test' flag '--cfg test' is also
5555
implied, so that tests can be conditionally compiled.
5656

57-
```rust
57+
~~~
5858
#[cfg(test)]
5959
mod tests {
6060
#[test]
6161
fn return_none_if_empty() {
6262
// ... test code ...
6363
}
6464
}
65-
```
65+
~~~
6666

6767
Additionally #[test] items behave as if they also have the
6868
#[cfg(test)] attribute, and will not be compiled when the --test flag
@@ -79,14 +79,14 @@ Tests that are intended to fail can be annotated with the
7979
task to fail then the test will be counted as successful; otherwise it
8080
will be counted as a failure. For example:
8181

82-
```rust
82+
~~~
8383
#[test]
8484
#[should_fail]
8585
fn test_out_of_bounds_failure() {
8686
let v: [int] = [];
8787
v[0];
8888
}
89-
```
89+
~~~
9090

9191
A test runner built with the '--test' flag supports a limited set of
9292
arguments to control which tests are run: the first free argument
@@ -126,7 +126,7 @@ amount.
126126

127127
For example:
128128

129-
```rust
129+
~~~
130130
extern mod extra;
131131
use std::vec;
132132
@@ -141,7 +141,7 @@ fn initialise_a_vector(b: &mut extra::test::BenchHarness) {
141141
b.iter(|| {vec::from_elem(1024, 0u64);} );
142142
b.bytes = 1024 * 8;
143143
}
144-
```
144+
~~~
145145

146146
The benchmark runner will calibrate measurement of the benchmark
147147
function to run the `iter` block "enough" times to get a reliable
@@ -168,7 +168,7 @@ test-runner. Benchmarks are compiled-in but not executed by default.
168168

169169
### Typical test run
170170

171-
```
171+
~~~ {.notrust}
172172
> mytests
173173
174174
running 30 tests
@@ -178,11 +178,11 @@ running driver::tests::mytest2 ... ignored
178178
running driver::tests::mytest30 ... ok
179179
180180
result: ok. 28 passed; 0 failed; 2 ignored
181-
```
181+
~~~ {.notrust}
182182
183183
### Test run with failures
184184
185-
```
185+
~~~ {.notrust}
186186
> mytests
187187
188188
running 30 tests
@@ -192,23 +192,23 @@ running driver::tests::mytest2 ... ignored
192192
running driver::tests::mytest30 ... FAILED
193193
194194
result: FAILED. 27 passed; 1 failed; 2 ignored
195-
```
195+
~~~
196196

197197
### Running ignored tests
198198

199-
```
199+
~~~ {.notrust}
200200
> mytests --ignored
201201
202202
running 2 tests
203203
running driver::tests::mytest2 ... failed
204204
running driver::tests::mytest10 ... ok
205205
206206
result: FAILED. 1 passed; 1 failed; 0 ignored
207-
```
207+
~~~
208208

209209
### Running a subset of tests
210210

211-
```
211+
~~~ {.notrust}
212212
> mytests mytest1
213213
214214
running 11 tests
@@ -218,19 +218,19 @@ running driver::tests::mytest10 ... ignored
218218
running driver::tests::mytest19 ... ok
219219
220220
result: ok. 11 passed; 0 failed; 1 ignored
221-
```
221+
~~~
222222

223223
### Running benchmarks
224224

225-
```
225+
~~~ {.notrust}
226226
> mytests --bench
227227
228228
running 2 tests
229229
test bench_sum_1024_ints ... bench: 709 ns/iter (+/- 82)
230230
test initialise_a_vector ... bench: 424 ns/iter (+/- 99) = 19320 MB/s
231231
232232
test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured
233-
```
233+
~~~
234234

235235
## Saving and ratcheting metrics
236236

0 commit comments

Comments
 (0)