smoketest that libtest doesn't panic in #[bench]

This commit is contained in:
Thom Chiovoloni 2022-10-31 04:21:14 -07:00
parent b56cb9e032
commit 8c71820e17
No known key found for this signature in database
GPG Key ID: D7733D1D7A775F0A
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,9 @@
include ../../run-make-fulldeps/tools.mk
all:
# Smoke-test that `#[bench]` isn't entirely broken.
$(RUSTC) --test smokebench.rs -O
$(call RUN,smokebench --bench)
$(call RUN,smokebench --bench noiter)
$(call RUN,smokebench --bench yesiter)
$(call RUN,smokebench)

View File

@ -0,0 +1,14 @@
#![feature(test)]
extern crate test;
#[bench]
fn smoke_yesiter(b: &mut test::Bencher) {
let mut i = 0usize;
b.iter(|| {
i = i.wrapping_add(1);
i
})
}
#[bench]
fn smoke_noiter(_: &mut test::Bencher) {}