Browse Source

Correctly run tuples

master
Adrian Heine 5 years ago
parent
commit
0a4019ea19
  1. 23
      src/setup.rs

23
src/setup.rs

@ -128,7 +128,9 @@ macro_rules! runnable_for_tuple {
#[allow(unused)]
fn run<_R: SymbolRunner>(&self, runner: &_R, force: bool) -> Result<bool, Box<dyn Error>> {
let ($($name,)*) = self;
Ok($(runner.run_symbol($name, force)? || )* false)
let mut result = false;
$(result = runner.run_symbol($name, force)? || result;)*
Ok(result)
}
}
);
@ -342,4 +344,23 @@ mod test {
setup.add(TestResource("A", "B")).unwrap();
assert_eq!(*count.borrow(), 0);
}
#[test]
fn correctly_handles_symbol_tuples() {
let (count, setup) = get_setup();
setup.run_symbol((TestSymbol { reached: false }, TestSymbol { reached: false }), false).unwrap();
assert_eq!(*count.borrow(), 2);
let (count, setup) = get_setup();
setup.run_symbol((TestSymbol { reached: true }, TestSymbol { reached: false }), false).unwrap();
assert_eq!(*count.borrow(), 1);
let (count, setup) = get_setup();
setup.run_symbol((TestSymbol { reached: false }, TestSymbol { reached: true }), false).unwrap();
assert_eq!(*count.borrow(), 1);
let (count, setup) = get_setup();
setup.run_symbol((TestSymbol { reached: true }, TestSymbol { reached: true }), true).unwrap();
assert_eq!(*count.borrow(), 2);
}
}
Loading…
Cancel
Save