Skip to content

Commit 6571347

Browse files
committed
---
yaml --- r: 170763 b: refs/heads/try c: cd85f0a h: refs/heads/master i: 170761: f380279 170759: e78d886 v: v3
1 parent c762246 commit 6571347

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 73a25f55ad748b4d3516417c711b99ce446591af
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
5-
refs/heads/try: 20fa7cbfc0b5143f6c88e288772fc0f65610c2ec
5+
refs/heads/try: cd85f0a56a790f24bb1c1928fbc37c9d24dd2937
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/guide-testing.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,12 @@ extern crate test;
556556
# fn main() {
557557
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let b = X;
558558
b.iter(|| {
559-
test::black_box(range(0u, 1000).fold(0, |old, new| old ^ new));
560-
});
559+
let mut n = 1000_u32;
560+
561+
test::black_box(&mut n); // pretend to modify `n`
562+
563+
range(0, n).fold(0, |a, b| a ^ b)
564+
})
561565
# }
562566
```
563567

@@ -573,3 +577,6 @@ test bench_xor_1000_ints ... bench: 1 ns/iter (+/- 0)
573577
574578
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
575579
```
580+
581+
However, the optimizer can still modify a testcase in an undesirable manner
582+
even when using either of the above.

0 commit comments

Comments
 (0)