#![feature(plugin, core, test)]
#![plugin(speculate)]

extern crate test;

speculate! {
    bench "noop" |b| {
        b.iter(|| ());
    }

    describe "xor" {
        context "0 to 1000" {
            before {
                let limit = 1000u32;
            }

            bench "using `fold`" |b| {
                b.iter(|| (0..limit).fold(0, |a, b| a ^ b));
            }

            bench "using `for`" |b| {
                b.iter(|| {
                    let mut ret = 0;
                    for i in 0..limit {
                        ret ^= i;
                    }
                    ret
                });
            }

            after {
                assert_eq!(limit, 1000);
            }
        }
    }
}

#![feature(plugin, test)]
#![plugin(speculate)]

extern crate test;

speculate! {
    bench "noop" |b| {
        b.iter(|| ());
    }

    describe "xor" {
        context "0 to 1000" {
            before {
                let limit = 1000u32;
            }

            bench "using `fold`" |b| {
                b.iter(|| (0..limit).fold(0, |a, b| a ^ b));
            }

            bench "using `for`" |b| {
                b.iter(|| {
                    let mut ret = 0;
                    for i in 0..limit {
                        ret ^= i;
                    }
                    ret
                });
            }

            after {
                assert_eq!(limit, 1000);
            }
        }
    }
}

Fix a warning in benches.
Fix a warning in benches.
